Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
/*
 * Decode the page title in a URL to Unicode
 *
 * Based on code from:
 * http://www.webtoolkit.info/javascript-url-decode-encode.htmland
 * http://www.albionresearch.com/misc/urlencode.php
 */

function interwikititle_decode_wikiurl(encoded)
{
	var HEXCHARS = "0123456789ABCDEFabcdef"; 
	var decoded = "";
	var i = 0;
	while (i < encoded.length) {
		var ch = encoded.charAt(i);
		if (ch == "+") {
			decoded += " ";
			i++;
		}
		else if (ch == "%") {
			if (i < (encoded.length-2) && HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 && HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				decoded += unescape(encoded.substr(i,3));
				i += 3;
			}
			else {
				decoded += "?";
				i++;
			}
		}
		else {
			decoded += ch;
			i++;
		}
	}
	var raw = decoded;
	var utf8 = "";
	i = 0;
	var c = c1 = c2 = 0;
	while ( i < raw.length ) {
		c = raw.charCodeAt(i);
		if (c < 128) {
			utf8 += String.fromCharCode(c);
			i++;
		}
		else if((c > 191) && (c < 224)) {
			c2 = raw.charCodeAt(i+1);
			utf8 += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
			i += 2;
		}
		else {
			c2 = raw.charCodeAt(i+1);
			c3 = raw.charCodeAt(i+2);
			utf8 += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
			i += 3;
		}
	}
	return utf8.replace(/_/g, " ");
}

/*
 * Replace interwiki links
 *
 * Default format is:
 *	English [this is a link]
 * 
 * This is converted to:
 *	English (en) [this is bold]
 *      Page title in other wiki [this is a link]
 */

function interwikititle_replace() {
	// Find all <li> items
	for each (var li in document.getElementsByTagName("li")) {
		var className = li.className;
		// We're looking for class names starting with "interwiki-"
		if (className && className.search("^interwiki-(.*)$") > -1) {
			// Get language code
			var languagecode = RegExp.$1;
			
			// Save a few things
			var a = li.childNodes[0];
			var textnode = a.childNodes[0];
			var language = textnode.nodeValue
			
			// Allow wrapping of link
			a.style.wordWrap = "break-word";
			a.style.whiteSpace = "normal";
			
			// Regexp to get page title
			a.href.match(".*/wiki/(.*)$");
			var pagetitle = interwikititle_decode_wikiurl(RegExp.$1);
			
			// Change link text to page title
			textnode.nodeValue = pagetitle;
			
			// Add language name and code in <strong> tag
			var strong = document.createElement("strong");
			strong.appendChild(document.createTextNode(language + " (" + languagecode + ")"));
			li.insertBefore(strong, a);
			
			// Also add a line break
			li.insertBefore(document.createElement("br"), a);
		}
	}
}

addOnloadHook (interwikititle_replace);