User:PerfektesChaos/js/userspaceLinks/d.js

/// userspaceLinks/d.js /// 2013-02-01 PerfektesChaos@de.wikipedia // Add specific tbox links if visiting a page related to particular user // ResourceLoader: compatible; //   dependencies: user, mediawiki.util //   namespaces:   -1, 2, 3 //   doc:          mw:User:PerfektesChaos/js/userspaceLinks /// Fingerprint: #0#0# /// @license GPL [//www.mediawiki.org/w/COPYING] (+GFDL, LGPL, CC-BY-SA) /// /*jshint curly:true, latedef:true, laxbreak:true, strict:true, trailing:true, undef:true, white:false         */ /*global document:false, jQuery: true, mediaWiki: false               */ /*jslint plusplus: true, regexp: true, unparam: true, vars: true, white: true, maxerr: 50                         */ /*globals document:false, jQuery: true, mediaWiki: false              */

( function ( mw, $ ) {  "use strict";   var URSLI;   if ( typeof mw.libs.userspaceLinks  || ! mw.libs.userspaceLinks ) {     mw.libs.userspaceLinks  =  { };   }   URSLI       =  mw.libs.userspaceLinks;   URSLI.doc   =  "mw:User:PerfektesChaos/js/userspaceLinks";   URSLI.type  =  "userspaceLinks";   URSLI.vsn   =  -1.0;

// Requires: JavaScript 1.3

URSLI.texts =  { // 2013-01-31 PerfektesChaos@de.wikipedia "subpage":     {"en": "Subpages", "de": "Unterseiten"}, "subpages":    {"en": "All subpages of this user below this page", "de": "Alle Benutzer-Unterseiten dieser Seite"} };  // .texts

URSLI.trans =  { // 2012-11-30 PerfektesChaos@de.wikipedia "de" :       "de", "de-at" :    "de", "de-ch" :    "de", "de-formal" : "de", "als" :      "de", "bar" :      "de", "dsb" :      "de", "frr" :      "de", "gsw" :      "de", "hsb" :      "de", "ksh" :      "de", "lb" :       "de", "nds" :      "de", "pdc" :      "de", "pdt" :      "de", "pfl" :      "de", "sli" :      "de", "stq" :      "de", "vmf" :      "de" };  // .trans

URSLI.feature =  function ( apply ) { // Wrap message text access for user or project language // Precondition: //   apply  -- text keyword // Postcondition: //   Return text closest to user language // Uses: //   this //   >  .trans //   >  .texts //   >< .slang // Remark: To be replaced //        if one day ResourceLoader3 gives access to      //         gadget@translatewiki // 2013-01-31 PerfektesChaos@de.wikipedia var e, r, s;     if ( ! this.slang ) { s          =  mw.config.get( "wgUserLanguage" ).toLowerCase; s          =  this.trans[ s ]; this.slang =  ( s ? s : "en" ); }     e  =  this.texts[ apply ]; if ( e ) { r =  e[ this.slang ]; if ( ! r ) { r =  e.en; if ( ! r ) { r =  "???" + apply + "???"; }        }      } else { r =  "***" + apply + "***"; }     return r;   };   // .feature

URSLI.fiat =  function  { // Equip page // Precondition: //   document has been loaded // Uses: //   >  .scope //   mw.config.get //   .feature //   mw.util.wikiUrlencode //   mw.util.addPortletLink // Remark: Used as event handler -- 'this' is not URSLI // 2013-01-31 PerfektesChaos@de.wikipedia var script   =  mw.config.get( "wgScript" ), subpages =  script + "?namespace=2&title=Special:Prefixindex/" + mw.util.wikiUrlencode( URSLI.scope ); mw.util.addPortletLink( "p-tb",                             subpages,                              URSLI.feature( "subpage" ),                              "g",                              URSLI.feature( "subpages" ),                              null ); };  // .fiat

URSLI.fire =  function  { // Start processing, if appropriate // Uses: //   this //    < .nsN //   mw.config.get //   mw.loader.using //   (.first) // 2013-01-31 PerfektesChaos@de.wikipedia var spec, launch =  false; URSLI.nsN =  mw.config.get( "wgNamespaceNumber" ); switch ( URSLI.nsN ) { case -1 :  // Special spec   =  mw.config.get( "wgCanonicalSpecialPageName" ); launch =  ( "|Contributions|Listfiles|".indexOf( spec )                         > 0 ); break; case 2 : case 3 : launch =  true; break; }  // switch wgNamespaceNumber if ( launch ) { mw.loader.using( [ "user",                           "mediawiki.util" ],                          this.first ); }  };   // .fire

URSLI.first =  function  { // Start processing // Precondition: //   Ressources are available // Uses: //   >  .nsN //    < .scope //   mw.config.get //   jQuery.ready //   (.fiat) // Remark: Used as event handler -- 'this' is not URSLI // 2013-01-31 PerfektesChaos@de.wikipedia var i,         launch  =  true; URSLI.scope =  mw.config.get( "wgTitle" ); if ( URSLI.nsN === -1 ) {  // Special: i      =  URSLI.scope.indexOf( "/" ); launch =  ( i > 1 );   // ensure one particular user if ( launch ) { URSLI.scope =  URSLI.scope.substr( i + 1 ); }     }      if ( launch ) { $( document ).ready( URSLI.fiat ); }  };   // .first

if ( ! URSLI.loaded ) { URSLI.loaded =  true; URSLI.fire; }  mw.loader.state( "ext.gadget.userspaceLinks", "ready" ); }( mediaWiki, jQuery ) );

// Emacs // Local Variables: // encoding: utf-8-dos // coding: utf-8-dos // fill-column: 80 // End:

/// EOF  userspaceLinks/d.js