User:Frog23/MyInterwikiLinks.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Frog23/MyInterwikiLinks. |
/*
(English Description see below)
Script My_Interwiki_Links für Wikipedia
=======================================
Dies ist ein Script, das die Interwiki-Links zu den Sprachen, die
man selbst versteht, an den Anfang der Interwiki-Linkliste setzt.
Konfiguration:
Füge diese Zeile in die JavaScript-Seite deiner Skin ein, bevor du
dieses Script einbindest:
var myInterwikiLinks_languages = new Array("en","fr","it");
In diesem Beispiel werden die Interwiki-Links zu Sprachen Englisch,
Französisch und Italienisch an den Anfang der Interwiki-Linkliste
gesetzt. Die Sprachkürzel können durch beliebige andere ersetzt und
es können beliebig viele anderen hinzugefügt oder entfernt werden.
Script My_Interwiki_Links for Wikipedia
=======================================
A script which puts the interwiki links to languages you understand
at the beginning of the list of interwiki links.
Configuration:
Add a line like the following to the JavaScript-Page of your Skin
before you call this script:
var myInterwikiLinks_languages = new Array("de","fr","it");
In this example the interwiki-links for the languages German, French
and Italian are placed at the beginning of the list of interwiki-links.
You can change the languages, add or remove as many as you like.
Author: Frog23 <http://de.wikipedia.org/wiki/Benutzer:Frog23>
Copyright (C) 2010
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if(!MyInterwikiLinks) var MyInterwikiLinks = {};
MyInterwikiLinks = {
// with the default setting without configuration just the English interwiki link will be displayed seperately
languages:new Array("en"),
changeLinkOrder: function(){
//check if
if (typeof myInterwikiLinks_languages === 'undefined') {
myInterwikiLinks_languages = MyInterwikiLinks.languages;
}
MyInterwikiLinks.languages = myInterwikiLinks_languages;
var firstItemReplaced = false
//get the list of interwiki links
var plang = document.evaluate("id('p-lang')//ul", document, null, 9, null).singleNodeValue;
if(plang){
var length = MyInterwikiLinks.languages.length;
for (var i = 0; i < length; i++) {
//search for the links in the specified languages
var interwikiLink = document.evaluate("id('p-lang')//li[starts-with(@class, 'interwiki-"+MyInterwikiLinks.languages[length-1-i]+"')]", document, null, 9, null).singleNodeValue;
if(interwikiLink){
//place the language link at the beginning of the list of interwiki links
plang.insertBefore(interwikiLink,plang.firstChild);
if(!firstItemReplaced){
firstItemReplaced = true;
//show a little spacer to the rest of the interwiki links
interwikiLink.style.paddingBottom = "15px";
}
}
}
}
}
};
$(MyInterwikiLinks.changeLinkOrder);