User:PerfektesChaos/js/resultListSort/d.js

/// User:PerfektesChaos/js/resultListSort/d.js /// 2015-09-27 PerfektesChaos@de.wikipedia // Sort result lists of "Whatlinkshere", "Search" or other special pages. // ResourceLoader: compatible; //      dependencies: user, user.options, mediawiki.user, mediawiki.util /// Fingerprint: #0#0# /// @license GPL [//www.mediawiki.org/w/COPYING] (+GFDL, LGPL, CC-BY-SA) /// /* global window:false                                                */ /* jshint forin:false, curly:true, eqeqeq:true, futurehostile:true, latedef:true, laxbreak:true, nocomma:true, strict:true, undef:true, unused:true          */

( function ( mw, $ ) {  "use strict";   var VERSION  =  -2,       RLS      =  "resultListSort";   if ( typeof mw.libs[ RLS ]  !==  "object"   ||   ! mw.libs[ RLS ] ) {     mw.libs[ RLS ]  =  { };   }   mw.libs[ RLS ].type  =  RLS;   RLS                  =  mw.libs[ RLS ];   if ( ! RLS.loaded ) {     // 2015-09-27      RLS.vsn         =  VERSION;      RLS.support     =  "User:PerfektesChaos/js/" + RLS.type;      RLS.doc         =  "" + RLS.support + "";      RLS.canonicals  =  [ // General Purpose                           "Contributions",                           "LinkSearch",                           "Newpages",                           "Recentchanges",                           "Search",                           "Watchlist",                           "Whatlinkshere",                           // transform table into list                           "Allpages",                           "Prefixindex",                           // Maintenance                           // "Notifications",                           "BrokenRedirects",                           "Deadendpages",                           "DoubleRedirects",                           "Fewestrevisions", "Lonelypages", "Longpages", "PagesWithProp", "PendingChanges", "Protectedpages", "Protectedtitles", "Shortpages", "Uncategorizedcategories", "Uncategorizedimages", "Uncategorizedpages", "Uncategorizedtemplates", "Unusedcategories", "Unusedimages", "Unusedtemplates", "Wantedcategories", "Wantedfiles", "Wantedpages", "Wantedtemplates" ];  // 2013-10-07 RLS.script     =  "javascript"; RLS.modeDirect =   0;  // direct child RLS.modeContr  =   1;  // Contributions RLS.modeLink2  =   2;  // LinkSearch RLS.modeSRH    =   3;  // .mw-search-result-heading RLS.modeSize   =  21;  // Newpages size RLS.modeSumm   =  22;  // Newpages/Recentchanges/Watchlist summary RLS.modeURL    =  23;  // LinkSearch URL RLS.modeUser   =  24;  // Newpages/Recentchanges/Watchlist user RLS.modeGroup  =  30;  // Recentchanges/Watchlist pagegroup page RLS.modeColumn =  -1;  // transform table into list RLS.unsorted   =  [ "Search", "LinkSearch", "Whatlinkshere" ]; RLS.pgGroup    =  { }; RLS.config     =  { };

RLS.texts =  { // 2014-01-04 PerfektesChaos@de.wikipedia "byName":   {"en": "Sort results", "de": "Sortiere Ergebnisseiten"}, "bySize":   {"en": "Sort by size", "de": "Sortiere nach Größe"}, "bySummary": {"en": "Sort by summary", "de": "Sortiere nach BK"}, "byURL":    {"en": "URL Sort", "de": "Sortiere nach URL"}, "byUser":   {"en": "Sort by user", "de": "Sortiere nach Benutzer"}, "OL":       {"en": "As list", "de": "Als Liste"}, "^show":    {"en": "Result-List-Sort", "de": "Result-List-Sort"}, "^suffix":  {"en": "&#8211; Sort result lists" + " on special pages", "de": "&#8211; Ergebnislisten auf Spezialseiten" + " sortieren"}, "^^auto":   {"en": "Perform sorting automatically" + " on selected special pages.", "de": "Automatische Sortierung" + " für bestimmte Spezialseiten"}, "^^auto+":  {"en": " " + "Space sparated list" + " of canonical special page names " + "Empty list:" + " Manual triggering only " + " &#8211;"                             + " sort every unsorted page ", "de": " " + "Leerzeichen-getrennte Liste" + " von kanonischen Namen " + "Leere Liste:" + " Gesonderte Aktivierung " + " &#8211;"                             + " alle unsortierten Seiten" + " sortieren "}, "^^portlet": {"en": "Create portlet link.", "de": "Portlet-Link einfügen"}, "^^portlet+":{"en": " " + "Space sparated list" + " of canonical specialpage names " + "Empty list:" + " all supported pages " + " &#8211;"                             + " Do not create portlet link. ", "de": " " + "Leerzeichen-getrennte Liste" + " von kanonischen Namen " + "Leere Liste: Immer Portlet-Link " + " &#8211;"                             + " keine Portlet-Links "}, "^^casing": {"en": "Perform case-insensitive sorting.", "de": "Groß- und Kleinschreibung" + " bei Sortierung ignorieren"}, "^^group":  {"en": "Keep page together with talk page.", "de": "Seite mit Diskussionsseite zusammenhalten"} };  // .texts

RLS.userlang =  { "de" :  "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" };  // .userlang   2012-12-19 PerfektesChaos@de.wikipedia }

// User options: // .auto // .casing // .group // .portlet

/*   * 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 2 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html */

// Requires: JavaScript 1.4             ("in") //          ECMA        262-3 § 11.8.5  (string comparison operators) //          MediaWiki   1.20            (mw .libs .hook, jQuery core)

RLS.config.favorite =  function  { // Detect support page in user language // Uses: //   this //   >  .slang //   .favorite // 2013-10-06 PerfektesChaos@de.wikipedia var r;     RLS.favorite; switch ( RLS.slang ) { case "de" : r =  "de.wikipedia.org"; break; default: r =  "www.mediawiki.org"; }  // switch .slang return "//" + r + "/wiki/"; };  // .config.favorite

RLS.config.fetch =  function  { // Retrieve preferences and overwrite presets // Uses: //   this //   >  .prego //   >  .type //    < .auto //    < .portlet //    < .casing //    < .group //   mw.libs.preferencesGadgetOptions.fetch // 2013-10-14 PerfektesChaos@de.wikipedia var n, s,         scope  =  " auto portlet casing group ", vals  =  RLS.prego.fetch( RLS.type ); for ( s in vals ) { if ( scope.indexOf( " " + s + " " ) >  0 ) { RLS[ s ] =  vals[ s ]; if ( typeof RLS[ s ] ===  "string" ) { RLS[ s ] =  RLS[ s ].split( " " ); n        =  RLS[ s ].length; if ( n <= 1 ) { switch ( s ) { case "auto" : if ( n ) { if ( RLS[ s ] === "*" ) { RLS[ s ] =  true; }                       } else { RLS[ s ] =  false; }                       break; case "portlet" : if ( n ) { switch ( RLS[ s ][ 0 ] ) { case "" : RLS[ s ] =  true; break; case "0" : RLS[ s ] =  false; break; }                       } else { RLS[ s ] =  true; }                       break; }  // switch s               } }        }      }   // for s in vals };  // .config.fetch

RLS.config.fiat =  function ( access ) { // Convert object component user configuration into string // Precondition: //   access  -- option ID      // Uses: //   >  .auto //   >  .portlet // 2013-10-06 PerfektesChaos@de.wikipedia var r = "", v =  RLS[ access ]; switch ( access ) { case "auto" : switch ( v ) { case undefined : case false : case null : break; case true : r = "*"; break; default: if ( typeof v ===  "object" ) { r =  v.join( " " ); }                 break; }  // switch v            break; case "portlet" : switch ( v ) { case false : case null : r = "0"; break; case undefined : case true : break; default: if ( typeof v ===  "object" ) { r =  v.join( " " ); }                 break; }  // switch v            break; }  // switch s      return  r;   };   // .config.fiat

RLS.config.fire =  function  { // Prepare ResourceLoader availability // Uses: //   this //    < .config.supply //   mw.loader.getState //   mw.loader.state //   mw.loader.load // 2015-09-27 PerfektesChaos@de.wikipedia var signature; this.supply =  "preferencesGadgetOptions"; signature   =  "ext.gadget." + this.supply; if ( ! mw.loader.getState( signature ) ) { mw.loader.state( signature, "loading" ); mw.loader.load( "https://en.wikipedia.org"                        + "/w/index.php?title="                         + "User:PerfektesChaos/js/" + this.supply                         + "/r.js"                         + "&action=raw&bcache=1&maxage=604803"                         + "&ctype=text/javascript",                         "text/javascript" ); }  };   // .config.fire

RLS.config.form =  function  { // Equip Special:Gadgets page with entry and form // Uses: //   >  .type //   >  .slang //   >  .texts //   >  .auto //   >  .portlet //   >  .casing //   >  .group //   >  .prego //   .favorite //   .config.fetch //   .config.favorite //   .config.fiat //   mw.libs.preferencesGadgetOptions.form // 2013-10-08 PerfektesChaos@de.wikipedia var dialog; RLS.favorite; this.fetch; dialog = { script: RLS.type, show:   RLS.texts[ "^show" ][ RLS.slang ], support: this.favorite, suffix: RLS.texts[ "^suffix" ][ RLS.slang ], opts:   [ { signature: "auto", type:     "text", show:     RLS.texts[ "^^auto" ][ RLS.slang ], suffix:   RLS.texts[ "^^auto+" ][ RLS.slang ], val:      this.fiat( "auto" ) },                    { signature: "portlet", type:     "text", show:     RLS.texts[ "^^portlet" ][ RLS.slang ], suffix:   RLS.texts[ "^^portlet+" ][ RLS.slang ], val:      this.fiat( "portlet" ) },                    { signature: "casing", type:     "checkbox", show:     RLS.texts[ "^^casing" ][ RLS.slang ], val:      ( RLS.casing ? true : false ) },                    { signature: "group", type:     "checkbox", show:     RLS.texts[ "^^group" ][ RLS.slang ], val:      ( RLS.group ? true : false ) }                  ] };      RLS.prego.form( dialog ); };  // .config.form

RLS.pgGroup.find =  function  { // Is this page in 'enhanced' page group mode? // Precondition: //   current page is Recentchanges/Watchlist // Postcondition: //   Returns true iff 'enhanced' page group mode // Uses: //   this //   >  mw.util.$content //    < .pgGroup.less //    < .pgGroup.$part //   mw.util.getParamValue //   jQuery.find //   mw.user.options.get // 2013-02-11 PerfektesChaos@de.wikipedia var $grab, set   =  mw.util.getParamValue( "enhanced" ); if ( set ) { this.less =  ( set === "1" ); } else { this.$part =  mw.util.$content.find( "#mw-content-text" ); $grab      =  this.$part.find( ".mw-enhanced-rc" ); if ( $grab.length ) { this.less =  true; } else if ( mw.user.options.get( "usenewrc" ) ) { this.less =  true; } else { this.less =  false; }     }      return this.less; };  // .pgGroup.find

RLS.pgGroup.first =  function  { // If this page in 'enhanced' page group mode, put into  // Precondition: //   Recentchanges/Watchlist in 'enhanced' page group mode // Uses: //   this //   >  mw.util.$content //   >< .pgGroup.$part //    < .pgGroup.less //    < .$list //   jQuery.find //   jQuery.eq //   jQuery.detach //   jQuery.append // 2013-02-11 PerfektesChaos@de.wikipedia var i, n, $grab, $i, $li; if ( ! this.$part ) { this.$part =  mw.util.$content.find( "#mw-content-text" ); }     $grab  =  this.$part.find( "div table.mw-enhanced-rc" ); n     =  $grab.length; if ( n ) { RLS.$list =  $( " " ); for ( i = 0; i < n;  i++ ) { $i =  $grab.eq( i ); $i.detach; $li =  $( " " ); $li.append( $i ); RLS.$list.append( $li ); }  // for i         this.$part.append( RLS.$list ); }  };   // .pgGroup.first

RLS.factory =  function ( access, action ) { // Insert portlet link // Precondition: //   access  -- text distinguisher ("by") //   action  -- mode code // Uses: //   this //   >  .script //   >  .type //   >  .slang //   >  .texts //   >  .vsn //   >< .controls //   mw.util.addPortletLink //   (.flip) // 2012-12-12 PerfektesChaos@de.wikipedia var dom; var s      =  ( action < 0  ?  access  :  "by" + access ); var script =  this.script + ":mw.libs." + this.type + ".flip(" + action + ");" + "void(0);"; var show   =  this.texts[ s ][ this.slang ]; var signal =  show + " * " + this.type + " " + this.vsn; var slot   =  ( action < 0  ?  "ca-format-" + access                                   :  "ca-sort-by" + access ); if ( ! show ) { show =  this.texts[ s ].en; }     dom  =  mw.util.addPortletLink( "p-cactions",                                      script,                                      show,                                      slot,                                      signal,                                      null,                                      null ); if ( ! this.controls ) { this.controls =  {}; }     if ( ! this.controls[ action ] ) { this.controls[ action ] =  { lazy: false, dom: dom, text: show }; } else { this.controls[ action ].lazy =  false; }  };   // .factory

RLS.fair =  function ( $access ) { // Make sortable element from jQuery list item // Precondition: //   $access  -- jQuery list item // Postcondition: //   Returns   [ $access, ns, title, talkmod, oldid ] // Uses: //   this //   >  .mode //   >  .modeURL //   >  .reNS //   >  .space2num //   >  .group //   >  .casing //   >  .modeContr //   .fetch //   jQuery.children // 2012-07-29 PerfektesChaos@de.wikipedia var g;     var k   =  0; var m  =  0; var n  =  0; var p;     var s   =  this.fetch( $access ); if ( s ) { if ( RLS.mode !== RLS.modeURL ) { g =  this.reNS.exec( s ); if ( g ) { p =  g[ 1 ].toLowerCase; n =  this.space2num[ p ]; s =  s.substr( p.length + 1 );   // decodeURI if ( RLS.group ) { m =  n % 2; n =  ( n - m )  /  2; }           }            if ( RLS.casing ) { s =  s.toLowerCase; }           if ( RLS.mode === RLS.modeContr ) { p =  $access.children( "a" ).attr( "href" ); p =  /[&?]oldid=([0-9]+)(?:&.*)?$/.exec( p ); if (p) { k =  parseInt( p[1], 10 ); }           }         }      } else { s =  ""; }     return  [ $access, n, s, m, k ]; };  // .fair

RLS.favorite =  function  { // Guess user language // Uses: //   this //   >  .userlang //   >< .slang //   mw.config.get // 2012-12-19 PerfektesChaos@de.wikipedia var s;     if ( ! this.slang ) { s =  mw.config.get( "wgUserLanguage" ).toLowerCase; if ( s.length > 4 ) {  // Remove RFC 1766 subtag from code if ( s.charCodeAt( 2 ) ===  45 ) {   // '-' s =  s.substr( 0, 2 ); }        }         s           =  this.userlang[ s ]; this.slang =  ( s ? s : "en" ); }  };   // .favorite

RLS.fetch =  function ( $access ) { // Retrieve distinguisher from jQuery list item // Precondition: //   $access  -- jQuery list item // Postcondition: //   Returns namespace:title string // Uses: //   this //   >  .mode //   >  .modeContr //   >  .modeDirect //   >  .modeGroup //   >  .modeLink2 //   >  .modeSize //   >  .modeSRH //   >  .modeSumm //   >  .modeURL //   >  .modeUser //   jQuery.children //   jQuery.eq //   jQuery.text //   jQuery.attr // 2013-02-11 PerfektesChaos@de.wikipedia var j   =  0; var r   =  false; var sub =  "a"; var $s  =  false; switch ( this.mode ) { case this.modeContr : case this.modeDirect : $s =  $access; break; case this.modeGroup : $s  =  $access.children.children.children.eq( 0 ) .children; $s  =  $s.eq( ( $s.length === 2  ? 1 :  2 ) );            $s   =  $s.children.children.eq( 0 ); sub =  false; break; case this.modeLink2 : $s =  $access; j  =  1; break; case this.modeSize : r =  $access.children( ".mw-newpages-length" ).text; if ( r ) { r =  r.replace( /\[?([.0-9]+)[^0-9].*/, "$1" ); r =  "            ".substr( 0, 13 - r.length )  +  r; /*                    123456789012 r =  r.replace( /\./g, "" );   parseint(,10);          */ }           break; case this.modeSRH : $s =  $access.children( ".mw-search-result-heading" ); break; case this.modeSumm : r =  $access.children( ".comment" ).text; break; case this.modeURL : r =  $access.children( "a" ).attr( "href" ); break; case this.modeUser : $s  =  $access.children( ".mw-userlink" ); sub =  false; break; }  // switch .mode if ( $s ) { if ( $s.length ) { if ( sub ) { $s =  $s.children( sub ); if ( j ) { $s =  $s.eq( j ); }           }            r  =  $s.attr( "title" ); }     }      return  r;   };   // .fetch

RLS.fiat =  function  { // Ensure namespace RegExp and list objects // Postcondition: //   configuration has been set // Uses: //   this //   >< .reNS //   >< .space2num //   mw.config.get // Requires: JavaScript 1.3  charCodeAt // 2012-10-29 PerfektesChaos@de.wikipedia var k, o, re, s;     if ( ! this.reNS ) { o              =  mw.config.get( "wgNamespaceIds" ); re             =  ""; this.space2num =  { }; for ( s in o ) { k =  o[ s ]; if ( k ) {  // not main s                   =  s.replace( /_/, " " ); this.space2num[ s ] =  k;               re                   =  re  +  ( re ? "|" : "" )  +  s;            } }  // for s in .space2num this.reNS =  new RegExp( "^(" + re + "):",  "i" ); }  };   // .fiat

RLS.filter =  function  { // Reduce date-grouped multi-list page to singe list // Precondition: // Uses: //   this //   >  .type //   jQuery.find //   jQuery // 2013-12-12 PerfektesChaos@de.wikipedia var $content =  mw.util.$content.find( "#mw-content-text" ); var $list    =  $( "" ); $content.find( "h4" ).remove; $content.find( ".mw-changeslist-date" ).remove; $content.find( "ul.special" ).each( function {            var $ul  =  $( this );            $ul.children.each( function  { var $li =  $( this ); $li.detach; $list.append( $li ); return true; } );           $ul.remove;            return true;                                                       } ); $content.append( $list ); };  // .filter

RLS.finalize =  function  { // Terminate interactive sorting: Remove sort controls // Uses: //   >< .controls // Remark: May be used as event handler -- 'this' is not accessed // 2012-11-12 PerfektesChaos@de.wikipedia var control; if ( RLS.controls ) { for ( control in RLS.controls ) { control =  RLS.controls[ control ]; if ( control ) { control =  control.dom; if ( control ) { control.setAttribute( "style", "display:none" ); }           }         }   // for key in .controls }  };   // .finalize

RLS.find =  function ( album, allow ) { // Is element matching? // Precondition: //   album  -- collection or single item //   allow  -- default for album===true // Postcondition: //   Returns false iff not matching // Uses: //   this //   >  .specialPage // 2012-07-27 PerfektesChaos@de.wikipedia var i;     var o  =  album; var r =  false; switch ( typeof o ) { case "number" : case "string" : r =  ( o === this.specialPage ); break; case "boolean" : if ( ! o ) { break; }           o  =  allow;   // fall through case "object" : // if ( o ) { if ( typeof o.length ===  "number" ) {   // Array for ( i = 0; i < o.length;  i++ ) { r =  ( o[i] === this.specialPage ); if ( r ) { break;  // for i                     } }  // for i               } else { r =  o[ this.specialPage ]; }           }            break; }  // switch typeof album return r;   };   // .find

RLS.fire =  function  { // Start possible actions on current page // Precondition: //   Current page is special page // Uses: //   >  .config.supply //   >  .specialPage //   >  .canonicals //   >< .auto //   >< .portlet //   >< .unsorted //    < .prego //   mw.user.isAnon //   .config.form //   .config.fetch //   .find //   .fresh //   .furnish // Remark: May be used as event handler -- 'this' is not RLS // 2015-09-27 PerfektesChaos@de.wikipedia if ( typeof mw.libs[ RLS.config.supply ] ===  "object" ) { RLS.prego =  mw.libs[ RLS.config.supply ]; } else { RLS.prego =  false; }     mw.loader.state( "ext.gadget.resultListSort", "ready" ); if ( RLS.specialPage === "Gadgets" ) { if ( RLS.prego ) { RLS.config.form; }     } else { if ( RLS.prego ) { RLS.config.fetch; }        if ( typeof RLS.auto  ===  "undefined" ) { RLS.auto =  false; }        if ( typeof RLS.casing  ===  "undefined" ) { RLS.casing =  false; }        if ( typeof RLS.portlet  ===  "undefined" ) { RLS.portlet =  true; }        if ( typeof RLS.unsorted  ===  "undefined" ) { RLS.unsorted =  false; }        if ( RLS.find( RLS.auto, RLS.unsorted ) ) { RLS.fresh; }        if ( RLS.find( ( RLS.portlet === true ? RLS.canonicals                                               : RLS.portlet ), RLS.canonicals ) ) { RLS.furnish; }     }   };   // .fire

RLS.firing =  function  { // Intermediate loading process step // Precondition: //   MW ressources are available // Uses: //   >  .config.supply //   mw.hook //   (.fire) // Remark: Used as event handler -- 'this' is not RLS // 2015-09-27 PerfektesChaos@de.wikipedia mw.hook( RLS.config.supply + ".ready" ).add( RLS.fire ); };  // .firing

RLS.first =  function ( arg1, arg2 ) { // Compare two list elements //   element:  [ *, ns, title, talkmod, oldid, ... ]     // Precondition: //   arg1  -- first element //   arg2  -- second element // Postcondition: //   Returns number  -1 :  arg2 -> arg1 //                    0 :  arg1 == arg2 //                    1 :  arg1 -> arg2 // 2012-07-23 PerfektesChaos@de.wikipedia var r =  arg1[ 1 ]  -  arg2[ 1 ]; if ( ! r ) { if ( arg1[ 2 ] ===  arg2[ 2 ] ) { if ( arg1[ 3] ===  arg2[ 3 ] ) { r =  arg1[ 4 ]  -  arg2[ 4 ]; } else { r =  arg1[ 3 ]  -  arg2[ 3 ]; }        } else if ( arg1[ 2 ]  <  arg2[ 2 ] ) { r =  -1; } else { r =  1; }     }      return  r;   };   // .first

RLS.flat =  function  { // Transform 3-column table into list // Uses: //   >  mw.util.$content //   jQuery.find //   jQuery.children //   jQuery // 2012-10-29 PerfektesChaos@de.wikipedia var i, k, n, $div, $item, $li, $ol, $rows, $table, $tr; switch ( this.specialPage ) { case "Allpages" : k =  ".mw-allpages-table-chunk"; break; case "Prefixindex" : k =  "#mw-prefixindex-list-table"; break; }  // switch this.specialPage $div   =  mw.util.$content.find( "#mw-content-text" ); $table =  $div.find( k ); $rows  =  $table.find( "tbody" ).children( "tr" ); n =  $rows.length; if ( n ) { $ol =  $( " " ); for ( i = 0; i < n;  i++ ) { $tr =  $rows.eq( i ).children; for ( k = 0; k < $tr.length;  k++ ) { $li   =  $( " " ); $item =  $tr.eq( k ).children; $item.detach; $li.append( $item ); $ol.append( $li ); }  // for k         }   // for i         $div.append( $ol ); $table.remove; }  };   // .flat

RLS.flip =  function ( action ) { // Perform interactive user action // Precondition: //   action  -- distinguisher // Uses: //   this //   >  .controls //   jQuery //   jQuery.find //   mw.config.get //   .flat //   .fresh // 2012-10-29 PerfektesChaos@de.wikipedia var control, key; if ( this.controls ) { for ( key in this.controls ) { control =  this.controls[ key ]; if ( control ) { if ( control.lazy ) { control.lazy =  false; control.$greyed.detach; control.$control.append( control.$a ); break; }           }         }   // for key in .controls } else { this.controls =  { }; }     control  =  this.controls[ action ]; if ( control ) { control.lazy =  true; if ( ! control.$control ) { control.$control =  $( control.dom ); }        if ( action < 0 ) { control.$control.detach; } else { if ( ! control.$a ) { control.$a       =  control.$control.find( "a" ); control.$greyed  =  $( ""                                       +  control.text                                       +  " " ); }           if ( mw.config.get( "skin" ) ===  "vector" ) { control.$greyed.css( "font-size", "0.8em" ); }           control.$control.empty; control.$control.append( control.$greyed ); }     }      if ( action < 0 ) { this.flat; } else { this.fresh( action ); }  };   // .flip

RLS.fresh =  function ( alter ) { // Launch sorting process on current page // Precondition: //   alter  -- optional distinguisher // Uses: //   >  .specialPage //   >  .modeContr //   >  .modeLink2 //   >  .modeDirect //   >  .type //   >  .pgGroup.less //   >  .modeGroup //   >  .modeSRH //   >  .canonicals //   >  mw.util.$content //   >< .lean //   >< .$list //   >< .$div //    < .mode //   .pgGroup.first //   .filter //   .find //   jQuery.find //   jQuery.children //   .fiat //   .fair //   (.first) // Remark: May be used as event handler -- 'this' is not accessed // 2013-12-12 PerfektesChaos@de.wikipedia var g, i, n, s, $l; // class="mw-spcontent" switch ( RLS.specialPage ) { case "Contributions" : case "PendingChanges" : RLS.mode =  RLS.modeContr; s        =  "#mw-content-text ul"; break; case "LinkSearch" : RLS.mode =  ( alter ? alter : RLS.modeLink2 ); s        =  "ol.special"; break; case "Newpages" : RLS.mode =  ( alter ? alter : RLS.modeDirect ); s        =  "#mw-content-text ul"; break; case "PagesWithProp" : RLS.mode =  ( alter ? alter : RLS.modeDirect ); s        =  "ol.special"; break; case "Recentchanges" : case "Watchlist" : RLS.mode =  ( alter ? alter : RLS.modeDirect ); if ( ! RLS.lean ) { RLS.pgGroup.first; RLS.filter; RLS.lean =  true; }           if ( RLS.pgGroup.less ) { RLS.mode =  RLS.modeGroup; } else { s =  "#" + RLS.type; }           break; case "Recentchangeslinked" : RLS.mode =  RLS.modeDirect; s        =  ".special"; break; case "Search" : RLS.mode =  RLS.modeSRH; s        =  ".mw-search-results"; break; case "Whatlinkshere" : RLS.mode =  RLS.modeDirect; s        =  "#mw-whatlinkshere-list"; break; default : if ( RLS.find( RLS.specialPage, RLS.canonicals ) ) { s =  "ol.special"; } else { s =  false; }     }   // switch .specialPage if ( RLS.$list === undefined &&  s ) { $l =  mw.util.$content.find( s ); if ( $l.length ) { RLS.$list =  $l; }     }      if ( RLS.$list ) { $l =  false; if ( RLS.recent ) { // recycling n =  RLS.mode + ""; for ( i in RLS.recent ) { if ( i === n ) { $l =  RLS.recent[ i ]; s  =  "block"; } else { s =  "none"; }              RLS.recent[ i ].attr( "style", "display:" + s ); }  // for i in RLS.recent } else { RLS.recent =  { }; }        if ( ! $l ) { $l =  RLS.$list.children( "li" ); n  =  $l.length; if ( n > 1 ) { g =  new Array( n ); RLS.fiat; for ( i = 0; i < n;  i++ ) { g[ i ] =  RLS.fair( $l.eq( i ) ); }  // for i               g.sort( RLS.first ); RLS.recent[ RLS.mode ] =  $( "" ); if ( RLS.$div ) { $l =  RLS.recent[ RLS.mode ]; for ( i = 0; i < n;  i++ ) { $l.append( g[ i ][ 0 ].clone ); }  // for i               } else { $l.detach; $l =  RLS.recent[ RLS.mode ]; for ( i = 0; i < n;  i++ ) { $l.append( g[ i ][ 0 ] ); }  // for i                  RLS.$div  =  $( "" ); RLS.$div.insertBefore( RLS.$list ); RLS.$list.remove; }              RLS.$div.append( $l ); RLS.$list =  $l; } else { RLS.$list =  false; }        }      }   };   // .fresh

RLS.furnish =  function  { // Equip current page with portlet links // Uses: //   this //   >  .specialPage //   >  .modeColumn //   >  .modeDirect //   >  .modeURL //   >  .modeUser //   >  .modeSize //   >  .modeSumm //   .favorite //   .factory //   .pgGroup.find // 2013-02-11 PerfektesChaos@de.wikipedia this.favorite; if ( this.specialPage === "Prefixindex" ||           this.specialPage === "Allpages" ) { this.factory( "OL", this.modeColumn ); } else { this.factory( "Name", this.modeDirect ); }     switch ( this.specialPage ) { case "LinkSearch" : this.factory( "URL", this.modeURL ); break; case "Newpages" : this.factory( "User", this.modeUser ); this.factory( "Size", this.modeSize ); this.factory( "Summary", this.modeSumm ); break; case "Recentchanges" : case "Watchlist" : if ( ! this.pgGroup.find ) { this.factory( "User", this.modeUser ); this.factory( "Summary", this.modeSumm ); }           break; }  // switch .specialPage };  // .furnish

if ( ! RLS.loaded ) { RLS.loaded =  true; if ( mw.config.get( "wgNamespaceNumber" ) ===  -1 ) { RLS.config.fire; mw.hook( "wikipage.content" ).add( function {               RLS.specialPage  =                           mw.config.get( "wgCanonicalSpecialPageName" );               mw.loader.using( [ "user", "user.options", "mediawiki.user", "mediawiki.util" ], RLS.firing );                                         } );   // .ready }  } }( window.mediaWiki, window.jQuery ) );

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

/// EOF  resultListSort/d.js