MediaWiki:OldwikisourceInterwiki.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/*
* Script that makes every link to oldwikisource, in the form of [[oldwikisource:Foo]], look like a regular interwiki link,
* that shows up in the left sidebar, at the beginning of the section "In other languages", with the name "Multilingual".
*
* PLEASE NOTE: currently [[oldwikisource:Foo]] and [[:oldwikisource:Foo]] are producing the same result (an inline link),
* so if you adopt this script on your wiki, you can't use inline links to oldwikisource any more: they will all display as interwiki links.
* You will still be able to link to oldwikisource using [http://wikisource.org/wiki/Foo link], of course.
* So before adopting this script, it's probably a good idea to look for every link [[oldwikisource:Foo|something]]
* and change it to [http://wikisource.org/wiki/Foo something] when needed.
* Or you can include this script only inside certain namespace, for example ns0, Page, Index, and Author.
*
* This probably works only on Vector skin
*/
$(document).ready(function() {
//check if there are links to oldwikisource in the page
if ($('a.extiw[title^="oldwikisource:"]').length > 0) {
//if there isn't an "other languages" section in the sidebar, first create it
if ($('#p-lang div.body ul').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($('#p-lang div.body ul'))
.wrapAll('<li class="interwiki-oldwikisource" />')
.removeClass('extiw')
.attr('title', title)
.html("Multilingual")
})
}
})