https://de.wikipedia.org/w/index.php?action=history&feed=atom&title=Benutzer%3ADapete%2Finterwikititle.js Benutzer:Dapete/interwikititle.js - Versionsgeschichte 2025-05-18T22:14:40Z Versionsgeschichte dieser Seite in Wikipedia MediaWiki 1.45.0-wmf.1 https://de.wikipedia.org/w/index.php?title=Benutzer:Dapete/interwikititle.js&diff=48542994&oldid=prev Dapete: Erweiterte Interwiki-Links 2008-07-18T18:48:56Z <p>Erweiterte Interwiki-Links</p> <p><b>Neue Seite</b></p><div>/*<br /> * Decode the page title in a URL to Unicode<br /> *<br /> * Based on code from:<br /> * http://www.webtoolkit.info/javascript-url-decode-encode.htmland<br /> * http://www.albionresearch.com/misc/urlencode.php<br /> */<br /> <br /> function interwikititle_decode_wikiurl(encoded)<br /> {<br /> var HEXCHARS = &quot;0123456789ABCDEFabcdef&quot;; <br /> var decoded = &quot;&quot;;<br /> var i = 0;<br /> while (i &lt; encoded.length) {<br /> var ch = encoded.charAt(i);<br /> if (ch == &quot;+&quot;) {<br /> decoded += &quot; &quot;;<br /> i++;<br /> }<br /> else if (ch == &quot;%&quot;) {<br /> if (i &lt; (encoded.length-2) &amp;&amp; HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 &amp;&amp; HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {<br /> decoded += unescape(encoded.substr(i,3));<br /> i += 3;<br /> }<br /> else {<br /> decoded += &quot;?&quot;;<br /> i++;<br /> }<br /> }<br /> else {<br /> decoded += ch;<br /> i++;<br /> }<br /> }<br /> var raw = decoded;<br /> var utf8 = &quot;&quot;;<br /> i = 0;<br /> var c = c1 = c2 = 0;<br /> while ( i &lt; raw.length ) {<br /> c = raw.charCodeAt(i);<br /> if (c &lt; 128) {<br /> utf8 += String.fromCharCode(c);<br /> i++;<br /> }<br /> else if((c &gt; 191) &amp;&amp; (c &lt; 224)) {<br /> c2 = raw.charCodeAt(i+1);<br /> utf8 += String.fromCharCode(((c &amp; 31) &lt;&lt; 6) | (c2 &amp; 63));<br /> i += 2;<br /> }<br /> else {<br /> c2 = raw.charCodeAt(i+1);<br /> c3 = raw.charCodeAt(i+2);<br /> utf8 += String.fromCharCode(((c &amp; 15) &lt;&lt; 12) | ((c2 &amp; 63) &lt;&lt; 6) | (c3 &amp; 63));<br /> i += 3;<br /> }<br /> }<br /> return utf8.replace(/_/g, &quot; &quot;);<br /> }<br /> <br /> /*<br /> * Replace interwiki links<br /> *<br /> * Default format is:<br /> * English [this is a link]<br /> * <br /> * This is converted to:<br /> * English (en) [this is bold]<br /> * Page title in other wiki [this is a link]<br /> */<br /> <br /> function interwikititle_replace() {<br /> // Find all &lt;li&gt; items<br /> for each (var li in document.getElementsByTagName(&quot;li&quot;)) {<br /> var className = li.className;<br /> // We&#039;re looking for class names starting with &quot;interwiki-&quot;<br /> if (className &amp;&amp; className.search(&quot;^interwiki-(.*)$&quot;) &gt; -1) {<br /> // Get language code<br /> var languagecode = RegExp.$1;<br /> <br /> // Save a few things<br /> var a = li.childNodes[0];<br /> var textnode = a.childNodes[0];<br /> var language = textnode.nodeValue<br /> <br /> // Allow wrapping of link<br /> a.style.wordWrap = &quot;break-word&quot;;<br /> a.style.whiteSpace = &quot;normal&quot;;<br /> <br /> // Regexp to get page title<br /> a.href.match(&quot;.*/wiki/(.*)$&quot;);<br /> var pagetitle = interwikititle_decode_wikiurl(RegExp.$1);<br /> <br /> // Change link text to page title<br /> textnode.nodeValue = pagetitle;<br /> <br /> // Add language name and code in &lt;strong&gt; tag<br /> var strong = document.createElement(&quot;strong&quot;);<br /> strong.appendChild(document.createTextNode(language + &quot; (&quot; + languagecode + &quot;)&quot;));<br /> li.insertBefore(strong, a);<br /> <br /> // Also add a line break<br /> li.insertBefore(document.createElement(&quot;br&quot;), a);<br /> }<br /> }<br /> }<br /> <br /> addOnloadHook (interwikititle_replace);</div> Dapete