User:PerfektesChaos/js/resultListSort/d.js

/// User:PerfektesChaos/js/resultListSort/d.js /// 2022-10-09 PerfektesChaos@de.wikipedia // Sort result lists of "Whatlinkshere", "Search" or other special pages. // ResourceLoader: compatible; //      dependencies: user, user.options, mediawiki.user, mediawiki.util //      namespaces:   -1 /// Documentation: mw:User:PerfektesChaos/js/resultListSort /// 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  =  -3.8,       RLS      =  "resultListSort",       Export   =  { signature: "ext.gadget." + RLS,                     support:   "User:PerfektesChaos/js/" + RLS,                     type:      RLS,                     vsn:       Version };   RLS         =  { config:  { params: { auto:    false,                                         casing:  false,                                         group:   false,                                         portlet: true } },                    pgGroup: { },                    type:    RLS,                    xBytes:  false,                    xChange: false };   Export.doc  =  "" + Export.support + "";

function features { // Set default constants // Uses: //   >  Export //    < .*      //    jQuery.extend // 2018-06-12 PerfektesChaos@de.wikipedia $.extend( RLS, Export ); 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", "Uncategorizedpages", "Uncategorizedtemplates", "Unusedcategories", "Unusedtemplates", "Wantedcategories", "Wantedfiles", "Wantedpages", "Wantedtemplates" ];  // 2018-06-12 RLS.modeDirect  =   0; // direct child RLS.modeLink2   =   1; // LinkSearch RLS.modeSRH     =   2; // .mw-search-result-heading RLS.modeContr   =  10; // Contributions page RLS.modeDate    =  11; // Contributions timestamp RLS.modeDiff    =  12; // Contributions size change RLS.modeMark    =  13; // Contributions marker RLS.modeSize    =  21; // Newpages size RLS.modeSumm    =  22; // summary // Contributions/Newpages/Recentchanges/Watchlist RLS.modeURL     =  23; // LinkSearch URL RLS.modeUser    =  24; // Newpages/Recentchanges/Watchlist user RLS.modeChange  =  25; // Search change time RLS.modeKBytes  =  26; // Search size RLS.modeGroup   =  30; // Recentchanges/Watchlist pagegroup page RLS.modeColumn  =  -1; // transform table into list RLS.unsorted   =  [ "Search", "LinkSearch", "Whatlinkshere" ]; RLS.gui        =  { greyed: false, skin:  false };

RLS.texts =  { // 2017-11-16 PerfektesChaos@de.wikipedia "byChange": {"en": "Sort by change time", "de": "Sortiere nach Änderungszeit"}, "byDiff":   {"en": "Sort by changed bytes", "de": "Sortiere nach geänderten Bytes"}, "byMark":   {"en": "Sort by mark", "de": "Sortiere nach Markierung"}, "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"}, "dmy":      {"en": "dmy", "da": "dmyt", "fr": "dmyt", "nl": "dmyt"}, "dmyt":     {"en": "dmyt"}, "dmyts":    {"en": "dmyts"}, "mdy":      {"en": "mdy2", "it": "mdy2"}, "ymd":      {"en": "ymd", "da": "ymd2", "fr": "ymd2", "nl": "ymd2"}, "ISO 8601": {"en": "ISO 8601"}, "OL":       {"en": "As list", "de": "Als Liste"}, "sizeSeq":  {"en": [1,2]}, "unitKB":   {"en": "KB", "fr": "Kio"}, "unitMB":   {"en": "MB"}, "Months":   {"en": "-", "da": "S", "de": "S", "it": "S", "nl": "S", "pl": "S"}, "^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 =  { "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   2016-11-11 PerfektesChaos@de.wikipedia }  // features

// 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)

function find( 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,         o  =  album, r =  false; switch ( typeof o ) { case "number" : case "string" : r =  ( o === RLS.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] === RLS.specialPage ); if ( r ) { break;  // for i                     } }  // for i               } else { r =  o[ RLS.specialPage ]; }           }            break; }  // switch typeof album return r;   }   // find

function fire { // 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 ); }  // fire

function firing { // Page is ready // Uses: //   mw.loader.using //   (fire) // 2016-11-11 PerfektesChaos@de.wikipedia mw.loader.using( [ "user",                        "user.options",                         "mediawiki.user",                         "mediawiki.util" ],                       fire ); }  // firing

function first { // AutoRun on load // Uses: //   >  Export //   >  Export.signature //   >  .type //   >  mw.libs //   >< RLS //   mw.loader.state //   .config.first //   mw.config.get //   .config.fire //   features //   mw.hook //   (.config.first) //   (firing) // 2018-08-24 PerfektesChaos@de.wikipedia var rls = { }; rls[ Export.signature ] = "ready"; mw.loader.state( rls ); if ( typeof mw.libs[ RLS.type ] ===  "object" ) { RLS.config.first( mw.libs[ RLS.type ] ); }     mw.libs[ RLS.type ]  =  Export; if ( mw.config.get( "wgNamespaceNumber" ) ===  -1 ) { RLS.specialPage = mw.config.get( "wgCanonicalSpecialPageName" ); RLS.config.fire; features; mw.hook( RLS.type + ".before" ).add( RLS.config.first ); mw.hook( "wikipage.content" ).add( firing ); } else { mw.hook( RLS.type + ".ready" ).fire( Export ); }  }   // first

function fullstop( activity ) { // Stop immediately event propagation // Precondition: //   activity  -- event // 2015-05-12 PerfektesChaos@de.wikipedia if ( typeof activity ===  "object"   &&   activity ) { if ( typeof activity.preventDefault ===  "function" ) { activity.preventDefault; }        if ( typeof activity.stopPropagation  ===  "function" ) { activity.stopPropagation; }     }   }   // fullstop

RLS.config.favorite =  function  { // Detect support page in user language // Uses: //   this //   >  .slang //   >  .support //   .favorite // 2016-10-21 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/" + RLS.support; };  // .config.favorite

RLS.config.fetch =  function  { // Retrieve preferences and overwrite presets // Uses: //   this //   >  .prego //   >  .type //    < .config.auto //    < .config.portlet //    < .config.casing //    < .config.group //   mw.libs.preferencesGadgetOptions.fetch // 2016-11-11 PerfektesChaos@de.wikipedia var cnf   =  RLS.config, scope =  " auto portlet casing group ", vals  =  RLS.prego.fetch( RLS.type ), n, s;     for ( s in vals ) { if ( scope.indexOf( " " + s + " " ) >  0 ) { cnf[ s ] =  vals[ s ]; if ( typeof cnf[ s ] ===  "string" ) { cnf[ s ] =  cnf[ s ].split( " " ); n        =  cnf[ s ].length; if ( n <= 1 ) { switch ( s ) { case "auto" : if ( n ) { if ( cnf[ s ] === "*" ) { cnf[ s ] =  true; }                       } else { cnf[ s ] =  false; }                       break; case "portlet" : if ( n ) { switch ( cnf[ s ][ 0 ] ) { case "" : cnf[ s ] =  true; break; case "0" : cnf[ s ] =  false; break; }                       } else { cnf[ 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: //   >  .config.auto //   >  .config.portlet // 2016-11-11 PerfektesChaos@de.wikipedia var r =  "", v =  RLS.config[ 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 //   > Version //    < .config.supply //   mw.loader.getState //   mw.loader.state //   mw.loader.load // 2016-11-11 PerfektesChaos@de.wikipedia var maxage, s, signature; this.supply =  "preferencesGadgetOptions"; signature   =  "ext.gadget." + this.supply; if ( ! mw.loader.getState( signature ) ) { mw.loader.state( signature, "loading" ); maxage =  3; if ( Version > 0 ) { s      =  "r"; maxage =  maxage + 604800; } else { s      =  "d"; maxage =  maxage + 1000; }        mw.loader.load( "https://en.wikipedia.org"                         + "/w/index.php?title="                         + "User:PerfektesChaos/js/" + this.supply                         + "/" + s + ".js"                         + "&action=raw&bcache=1&maxage=" + maxage                         + "&ctype=text/javascript",                         "text/javascript" ); }  };   // .config.fire

RLS.config.first =  function ( assign ) { // Check for user defined options // Uses: //   >  .config.params //    < .config.* // 2016-11-11 PerfektesChaos@de.wikipedia var p, s;     if ( typeof assign  ===  "object"  &&  assign ) { p =  RLS.config.params; for ( s in p ) { if ( typeof assign[ s ] !==  "undefined" ) { RLS.config[ s ] =  assign[ s ]; }        }   // for s in p      } };  // .config.first

RLS.config.form =  function  { // Equip Special:BlankPage page with entry and form // Uses: //   >  .type //   >  .config.casing //   >  .config.group //   >  .prego //   .favorite //   .config.fetch //   .finest //   .config.favorite //   .config.fiat //   mw.libs.preferencesGadgetOptions.form // 2016-11-11 PerfektesChaos@de.wikipedia var dialog; RLS.favorite; this.fetch; dialog = { script: RLS.type, show:   RLS.finest( "^show" ), support: this.favorite, suffix: RLS.finest( "^suffix" ), opts:   [ { signature: "auto", type:     "text", show:     RLS.finest( "^^auto" ), suffix:   RLS.finest( "^^auto+" ), val:      this.fiat( "auto" ) },                    { signature: "portlet", type:     "text", show:     RLS.finest( "^^portlet" ), suffix:   RLS.finest( "^^portlet+" ), val:      this.fiat( "portlet" ) },                    { signature: "casing", type:     "checkbox", show:     RLS.finest( "^^casing" ), val:      ( this.casing ? true : false ) },                    { signature: "group", type:     "checkbox", show:     RLS.finest( "^^group" ), val:      ( this.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 //   >  .type //   >  .vsn //   >< .controls //   .finest //   mw.util.addPortletLink //   (jQuery).click //   (.flip) // 2016-11-19 PerfektesChaos@de.wikipedia var s      =  ( action < 0  ?  access  :  "by" + access ), show   =  RLS.finest( s ), signal =  show + " * " + this.type + " " + this.vsn, slot   =  ( action < 0  ?  "ca-format-" + access                                   :  "ca-sort-by" + access ), dom    =  mw.util.addPortletLink( "p-cactions",                                             "#",                                             show,                                             slot,                                             signal,                                             null,                                             null ), $ctl =  $( dom ); $ctl.click( function ( event ) { fullstop( event );                                      RLS.flip( action );                                     } ); if ( ! this.controls ) { this.controls =  {}; }     if ( ! this.controls[ action ] ) { this.controls[ action ] =  { lazy:      false, $control: $ctl, 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 //   >  .modeChange //   >  .modeKBytes //   >  .modeDiff //   >  .modeMark //   >  .xChange //   >  .xBytes //   >  .reNS //   >  .space2num //   >  .config.group //   >  .config.casing //   >  .modeContr //   >< .reOldid //   .fetch //   jQuery.children // Requires: JavaScript 1.3  charCodeAt  fromCharCode // 2018-05-20 PerfektesChaos@de.wikipedia var k  =  0, m  =  0, n  =  0, s  =  this.fetch( $access ), g, i, p, x;     if ( s ) { switch ( RLS.mode ) { case this.modeURL : break; case this.modeChange : case this.modeDate : g =  this.xChange.re.exec( s ); if ( g ) { if ( this.xChange.order ) { p =  this.xChange.order; x =  new Array( 6 ); for ( i = 0; i < p.length;  i++ ) { x[ p[ i ] ] =  g[ i + 1 ]; }  // for i                     p  =  this.xChange.trslMonths; for ( i = 1; i < 12;  i++ ) { if ( x[ 1 ] ===  p[ i ] ) { if ( i < 10 ) { x[ 1 ] =  "0" + i;                           } else { x[ 1 ] =  i + ""; }                          break; }                    }   // for i                     if ( x[ 2 ].length  ===  1 ) { x[ 2 ] =  "0" + x[ 2 ]; }                 } else { g.shift; x =  g;                  } p =  x.join( "" ); s =  ""; for ( i = 0; i < p.length;  i++ ) { s =  s + String.fromCharCode( 105 - p.charCodeAt( i ) ); }  // for i               } // 189 KB (18.999 Wörter) - 2016-11-08T10:27:16 break; case this.modeKBytes : g =  this.xBytes.reKB.exec( s ); if ( g ) { s =  parseInt( g[ 1 ],  10 )   *   1000; } else { g =  this.xBytes.reMB.exec( s ); if ( g ) { if ( g[ 1 ] ) { s =  g[ 2 ] + "000"; s =  s.substr( 0, 3 ); s =  parseInt( g[ 1 ],  10 )   *   1000000 +                             parseInt( s, 10 )   *   1000; } else { s =  parseInt( g[ 2 ],  10 )   *   1000000; }                 } else { s =  parseInt( s, 10 ); }              }               break; case this.modeDiff : case this.modeMark : break; default: g =  this.reNS.exec( s ); if ( g ) { p =  g[ 1 ].toLowerCase; n =  this.space2num[ p ]; s =  s.substr( p.length + 1 );   // decodeURI if ( RLS.config.group ) { m =  n % 2; n =  ( n - m )  /  2; }              }               if ( RLS.config.casing ) { s =  s.toLowerCase; }              if ( RLS.mode === RLS.modeContr ) { if ( typeof this.reOldid !==  "object" )  { this.reOldid =  new RegExp( "[&?]oldid="                                                  + "([0-9]+)"                                                  + "(?:&.*)?$" ); }                 p  =  $access.children( "a" ).attr( "href" ); p =  this.reOldid.exec( p ); if (p) { k =  parseInt( p[ 1 ],  10 ); }              }         }   // switch RLS.mode } 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 ); }        }         if ( typeof this.userlang[ s ]  ===  "string" ) { this.slang =  this.userlang[ s ]; } else { this.slang =  s;         } }  };   // .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 //   >  .modeDate //   >  .modeDiff //   >  .modeGroup //   >  .modeLink2 //   >  .modeMark //   >  .modeSize //   >  .modeSRH //   >  .modeChange //   >  .modeKBytes //   >  .modeSumm //   >  .modeURL //   >  .modeUser //   >< .reNumber //   >< .reNewline //   >< .xBytes.reEnd //   jQuery.children //   jQuery.eq //   jQuery.text //   jQuery.attr // 2022-10-09 PerfektesChaos@de.wikipedia var j   =  0, r   =  false, sub =  "a", $s  =  false, s;     switch ( this.mode ) { case this.modeContr : case this.modeDirect : $s =  $access; break; case this.modeDate : r =  $access.children( ".mw-changeslist-date" ).text; break; case this.modeDiff : sub =  ".mw-plusminus-pos,.mw-plusminus-neg"; r   =  $access.children( sub ).text; if ( r ) { if ( typeof this.reNumber !==  "object" )  { this.reNumber =  new RegExp( "[^-0-9]",  "gi" ); }              r  =  r.replace( this.reNumber, "" ); r =  parseInt( r,  10 ); }           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.modeMark : if ( $access.children( ".newpage" ).length ) { r = 0; } else if ( $access.children( ".minoredit" ).length ) { r = 9; } else { r = 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.find( ".mw-search-result-heading" ); break; case this.modeChange : case this.modeKBytes : r =  $access.find( ".mw-search-result-data" ).text; 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 && $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 // 2016-11-11 PerfektesChaos@de.wikipedia var $content =  mw.util.$content.find( "#mw-content-text" ), $list    =  $( "" ), $li, $ul; $list.attr( { "id": RLS.type } ); $content.find( "h4" ).remove; $content.find( ".mw-changeslist-date" ).remove; $content.find( "ul.special" ).each( function {            $ul  =  $( this );            $ul.children.each( function  { $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 //   (jQuery).hide // Remark: May be used as event handler -- 'this' is not accessed // 2016-11-11 PerfektesChaos@de.wikipedia var control; if ( RLS.controls ) { for ( control in RLS.controls ) { control =  RLS.controls[ control ]; if ( control ) { control.$control.hide; }        }   // for key in .controls }  };   // .finalize

RLS.finest =  function ( ask ) { // Retrieve best localized string // Precondition: //   ask  -- string, with ID      // Postcondition: //   Returns best localized string, at least English // Uses: //   this //   >  .texts //   >  .slang // 2016-11-11 PerfektesChaos@de.wikipedia var t  =  this.texts[ ask ], r;     if ( typeof t[ this.slang ]  ===  "string" ) { r =  t[ this.slang ]; } else { r =  t.en; }     return  r;   };   // .finest

RLS.fire =  function  { // Start possible actions on current page // Precondition: //   Current page is special page // Uses: //   >  mw.libs.preferencesGadgetOptions //   >  .config.supply //   >  .flip //   >  .fresh //   >  .specialPage //   >  .unsorted //   >  .canonicals //   >  .config.params //   >< .config.auto //   >< .config.portlet //    < .prego //   mw.hook //   .config.form //   .config.fetch //   find //   .fresh //   .furnish // Remark: May be used as event handler -- 'this' is not RLS // 2016-11-11 PerfektesChaos@de.wikipedia var p, s;     if ( typeof mw.libs[ RLS.config.supply ]  ===  "object" ) { RLS.prego =  mw.libs[ RLS.config.supply ]; } else { RLS.prego =  false; }     Export.flip   =  RLS.flip; Export.fresh =  RLS.fresh; mw.hook( RLS.type + ".ready" ).fire( Export ); if ( RLS.specialPage === "Blankpage" ) { //                   "Gadgets" if ( RLS.prego ) { RLS.config.form; }     } else { if ( RLS.prego ) { RLS.config.fetch; }        p  =  RLS.config.params; for ( s in p ) { if ( typeof RLS.config[ s ] ===  "undefined" ) { RLS.config[ s ] =  p[ s ]; }        }   // for s in p         if ( find( RLS.config.auto, RLS.unsorted ) ) { RLS.fresh; }        if ( RLS.config.portlet === true ) { p =  true; } else { p =  find( RLS.config.portlet, RLS.canonicals ); }        if ( p ) { RLS.furnish; }     }   };   // .fire

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 //   >< .gui.greyed //   >< .gui.skin //   jQuery //   (jQuery).detach //   mw.config.get //   jQuery.find //   (jQuery).css //   (jQuery).text //   (jQuery).empty //   (jQuery).append //   .flat //   .fresh // 2016-11-11 PerfektesChaos@de.wikipedia var control, key; if ( this.controls ) { for ( key in this.controls ) { control =  this.controls[ key ]; if ( control &&  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 ( action < 0 ) { control.$control.detach; } else { if ( ! control.$a ) { if ( ! this.gui.greyed ) { this.gui.greyed =  { "color":       "#808080", "padding":    "0.5em", "white-space": "nowrap" }; if ( ! this.gui.skin ) { this.gui.skin =  mw.config.get( "skin" ); }                 if ( this.gui.skin ===  "vector" ) { this.gui.greyed[ "font-size" ] =  "0.8em"; }              }               control.$a        =  control.$control.find( "a" ); control.$greyed  =  $( " " ); control.$greyed.css( this.gui.greyed ) .text( control.text ); }           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 //   .fiat //   .fair //   (.first) // Remark: May be used as event handler -- 'this' is not accessed // 2018-06-12 PerfektesChaos@de.wikipedia var g, i, n, s, $l, $recent; // class="mw-spcontent" switch ( RLS.specialPage ) { case "Contributions" : case "PendingChanges" : RLS.mode =  ( alter ? alter : RLS.modeContr ); RLS.further; 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" : if ( alter ) { RLS.mode =  alter; RLS.further; } else { 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 ) { $recent =  RLS.recent[ i ]; if ( i === n ) { $recent.show; $l =  true; } else { $recent.hide; }           }   // 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 ); $recent =  $( "" ); $recent.attr( { "id": RLS.type + "_" + RLS.mode } ); RLS.recent[ RLS.mode + "" ] =  $recent; if ( RLS.$div ) { $l =  $recent; for ( i = 0; i < n;  i++ ) { $l.append( g[ i ][ 0 ].clone ); }  // for i               } else { $l.detach; $l =  $recent; for ( i = 0; i < n;  i++ ) { $l.append( g[ i ][ 0 ] ); }  // for i                  RLS.$div  =  $( " " ); RLS.$div.attr( { "id": RLS.type } ) .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 //   >  .modeDate //   >  .modeSumm //   >  .modeDiff //   >  .modeMark //   >  .modeURL //   >  .modeUser //   >  .modeSize //   >  .modeChange //   >  .modeKBytes //   .favorite //   .factory //   .pgGroup.find // 2018-06-12 PerfektesChaos@de.wikipedia this.favorite; if ( this.specialPage === "Prefixindex" ||           this.specialPage === "Allpages" ) { this.factory( "OL", this.modeColumn ); } else if ( this.specialPage !== "Unusedimages" ) { this.factory( "Name", this.modeDirect ); }     switch ( this.specialPage ) { case "Contributions" : this.factory( "Change", this.modeDate ); this.factory( "Summary", this.modeSumm ); this.factory( "Diff", this.modeDiff ); this.factory( "Mark", this.modeMark ); break; 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; case "Search" : this.factory( "Change", this.modeChange ); this.factory( "Size",  this.modeKBytes ); break; }  // switch .specialPage };  // .furnish

RLS.further =  function  { // Initialize advanced features // Uses: //   this //   >  .mode //   >  .modeChange //   >  .modeDate //   >  .modeKBytes //   >  .slang //   >< .xChange //   >< .xBytes //   mw.config.get //   .finest // 2018-06-12 PerfektesChaos@de.wikipedia var i, k, o, re, s, scheme, x;     switch ( this.mode ) { case this.modeChange : case this.modeDate : if ( ! this.xChange ) { this.xChange =  { }; scheme =  mw.user.options.get( "date" ); if ( ! scheme ||  scheme === "default" ) { scheme =  mw.config.get( "wgDefaultDateFormat" ); }              x  =  this.xChange; o =  { dmyt:  [ 2, 1, 0, 3, 4 ], dmyts: [ 2, 1, 0, 3, 4, 5 ], dmy:  [ 3, 4, 2, 1, 0 ], mdy:  [ 1, 2, 0, 3, 4 ], mdy2: [ 3, 4, 1, 2, 0 ], ymd:  [ 3, 4, 0, 1, 2 ], ymd2: [ 0, 1, 2, 3, 4 ], "ISO 8601":  false }; scheme  =  RLS.finest( scheme ); x.order =  o[ scheme ]; if ( x.order ) { s  =  "[0-6][0-9]"; re =  [ "2[012][0-9][0-9]", "\\S+\\W?", "[0-3]?[0-9]",                          s,                           s,                           s ]; s =  ""; for ( i = 0; i < x.order.length;  i++ ) { k =  x.order[ i ]; switch ( k ) { case 0: case 1: case 2: case 3: if ( s ) { s =  s + "\\s"; }                          break; case 4: case 5: s =  s + ":"; break; }  // switch i                     s  =  s + "(" + re[ k ] + ")"; switch ( k ) { case 0: switch ( scheme ) { case "dmyt": case "dmyts": case "mdy": s =  s + "(?:,|\\s\\W+)?"; break; }  // switch scheme break; case 2: s =  s + "\\W?"; switch ( scheme ) { case "ymd2": s =  s + "(?:\\s\\W+)?"; break; }  // switch scheme break; case 4: switch ( scheme ) { case "dmy": case "mdy2": case "ymd": s =  s + ",?"; break; }  // switch scheme }  // switch i                  }   // for i                  x.re  =  new RegExp( s + "$" ); s    =  "wgMonthNames"; if ( RLS.finest( "Months" ) === "S" ) { s =  s + "Short"; }                 x.trslMonths  =  mw.config.get( s ); } else { x.re =  new RegExp( "\\s(2[012][0-9][0-9])"                                       + "-([01]?[0-9])-([0-3]?[0-9])"                                       + "[ T](..):(..):(..)$" ); }           }            break; case this.modeKBytes : if ( ! this.xBytes ) { s =  "^((?:([0-9]+)[.,])?[0-9]+)\\s+"; this.xBytes =  { }; s =  "^([0-9]+)\\s+" + RLS.finest( "unitKB" ); this.xBytes.reKB =  new RegExp( s ); s =  "^(?:([0-9]+)[.,])?([0-9]+)\\s+" + RLS.finest( "unitMB" ); this.xBytes.reMB =  new RegExp( s ); }           break; }  // switch .mode };  // .further

if ( mw.loader.getState( Export.signature ) !==  "ready" ) { first; } }( window.mediaWiki, window.jQuery ) );

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

/// EOF  resultListSort/d.js