Jump to content

User:Edoderoo/vector.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//------------------------------------------------------------------------------------
// Script plaatst interwiki's naar grotere Wikipedia's indien aanwezig bovenaan
// (Duits, Engels, Frans, Italiaans, Portugees, Spaans, Fins, Noors, Pools en Zweeds)
// Tevens enkele aan het Nederlands verwante talen
// (Afrikaans, Fries, Limburgs, Nedersaksisch, West-Vlaams en Zeeuws)
//
// Based on script found on [[:nn:MediaWiki/monobook.js]]
// Maintainers: [[:no:User:Jeblad]], fix voor nl: [[nl:User:Zanaq]]
//
// Indien andere talen gewenst het script kopiëren en de talen achter prefs= aanpassen
// Voeg de code importScript('Gebruiker:Troefkaart/interwiki.js'); toe aan monobook.js
// Vervang Troefkaart door eigen naam bij kopiëren gehele code
//
// Door bv li.interwiki-de, li.interwiki-en { font-weight: bold; } in het monobook.css 
// te plaatsen worden interwiki's naar aangegeven talen vet gemaakt.
// Werkt ook zonder dit script
//------------------------------------------------------------------------------------ 
 
  addOnloadHook( function () {
 
      //if (!prefs) return;
      prefs=["nl", "de", "en", "fr", "it", "pl", "pt", "sv", "es"]
 
      var iwlinks = [];
      for (i=0;i<prefs.length;i++) {
          iwlinks["interwiki-" + prefs[i]] = 1;
      }
      var container = document.getElementById("p-lang");
 
      if (!container) return;
 
      var keeps = Array();
      var ul = container.getElementsByTagName("ul");
      if (!ul) return;
      if (ul.length != 1) return;
      ul = ul[0];
      var childs = container.getElementsByTagName("li");
      for (i=0;i<childs.length;i++) {
          // the following test fails if there are several classes for the actual child
	  if ( iwlinks[ childs[i].getAttribute( 'class' ) ] ) {
	      keeps.push(childs[i]);
          }
      }
      var n = childs.length;
      for (i=childs.length-1;i>=0;i--) {
	  if ( !iwlinks[ childs[i].getAttribute( 'class' ) ] ) {
	      keeps[--n] = childs[i];
          }
          else {
              childs[i].setAttribute( 'class', childs[i].getAttribute( 'class' ) + ' iw-focus' );
          }
      }
 
      var child;
      while (child = ul.firstChild) {
          ul.removeChild(child);
      }
      for (i=0;i<keeps.length;i++) {
          ul.appendChild(keeps[i]);
      }
  });

importScript(':nl:Gebruiker:Michielderoo/interwiki-translate-nl.js');
importScript(':nl:Gebruiker:Edoderoo/interwiki.js');