« Utilisateur:DeirdreAnne/common.js » : différence entre les versions

Contenu supprimé Contenu ajouté
Testing script by Candalua
(Aucune différence)

Version du 18 août 2011 à 14:44

//makes every link to oldwikisource, in the form of [[oldwikisource:Foo]], look like a regular interwiki link
$(document).ready(function() {
 
  //if there are links to oldwikisource, but there isn't an "other languages" section in the sidebar, first create it
  if ($('div#p-lang div.body ul').length == 0 && $('a.extiw[title^="oldwikisource:"]').length > 0) {
    $('div#mw-panel').append(
      '<div class="portal expanded" id="p-lang"><h5 tabindex="10">In other languages</h5><div class="body" style="display: block; "><ul></ul></div></div>')
  }
 
  //loop through every oldwiki link and move them to the sidebar
  $($('a.extiw[title^="oldwikisource:"]').get().reverse()).each(function(i) {
    title = $(this).attr('title').replace('oldwikisource:', '')
    $(this).prependTo($('div#p-lang div.body ul'))
      .wrapAll('<li class="interwiki-oldwikisource" />')
      .removeClass('extiw')
      .attr('title', title)
      .html("Old Wikisource")
  }) 
})