User:PerfektesChaos/js/templatedataHint/x.js

/// User:PerfektesChaos/js/templatedataHint/core/d.js /// 2020-01-10 PerfektesChaos@de.wikipedia // Enrich links to template pages with TemplateData now // ResourceLoader:  compatible //   dependencies: mediawiki.api, //                 mediawiki.storage, //                 mediawiki.util /// Fingerprint: #0#0# /// License: CC-by-sa/4.0 /// /* global window: false                                               */ /* jshint forin: false, bitwise:true, curly:true, eqeqeq:true, latedef:true, laxbreak:true, nocomma:true, strict:true, undef:true, unused:true          */

( function ( mw, $ ) {  "use strict";   var Version   = -0.5,       Signature = "templatedataHint",       Sub       = "core",       TDHC      = { },       API       = { Api:     false,                     errors:  false,                     max:     10,                     more:    3,                     scream:  false,                     $ajax:   false },       BABEL     = { dict:       false,                     dictionary: false,                     lower:      false,                     maxDays:    30,                     translate:  false },       DATAT     = { colors: { required:   "EAF3FF",                               suggested:  "FFFFFF",                               optional:   "EAECF0",                               optionalFG: "606060",                               deprecated: "FFCBCB" },                     css:    { "border-color":  "#B3B7FF",                               "border-style":  "solid", "border-with":  "2px", "margin-bottom": "0.2em", "margin-top":   "0.2em", "padding":      "0.25em" },

scroll: "20em", toggle: { hide: { src: "OOjs UI icon " + "collapse-progressive.svg", sub: "57" }, show: { src: "OOjs UI icon " + "expand-progressive.svg", sub: "a8" }, img: 18 }                  },       HOVER     = { }, ORDER    = { collate: false, util:   { signature: "sortCharUtility" } },      QUERY     = { }, REPOS, UL2DL    = { };

function fire ( about, acquired ) { // Generated list request arrived // Precondition: //   about     -- page information //   acquired  -- templates collection // Uses: //    < TDHC.result //    < TDHC.templates //   BABEL.fire //   ORDER.fetch //   API.fire //   (UL2DL.fire) //   (QUERY.fire) // 2020-12-27 PerfektesChaos@de.wikipedia if ( typeof about ===  "object"           &&     about    &&           typeof acquired  ===  "object"           &&     acquired ) { TDHC.result   = about; TDHC.templates = acquired; BABEL.fire; if ( about.list ) { ORDER.fetch; API.fire( false, UL2DL.fire ); } else { API.fire( true, QUERY.fire ); }     }   }   // fire

function fired ( apply ) { // Application requested execution, initialize now and inherit // Precondition: //   apply  -- application object // Uses: //   >  Signature //   >< TDHC //    < REPOS //   mw.hook //   mw.config.get //   BABEL.fire //   (fire) //   (HOVER.fire) //   (BABEL.flat) // 2020-12-27 PerfektesChaos@de.wikipedia var heritage = [ "doc", "pages", "re", "show", "space", "templates", "types", "uid", "$widget" ], cnf, i, s, sub; if ( typeof apply ===  "object"           &&     apply ) { mw.hook( Signature + ".init" ).remove( fired ); for ( i = 0; i < heritage.length;  i++ ) { sub = heritage[ i ]; s  = sub.substr( 0, 1 ); s  = ( s === "s"  ?  "string"  :  "object" ); if ( typeof apply[ sub ] ===  s                 &&     apply[ sub ] ) { TDHC[ sub ] = apply[ sub ]; }        }   // for i         if ( typeof apply.pub  ===  "object"              &&     apply.pub ) { heritage = apply.pub; if ( typeof heritage.type ===  "string" ) { TDHC.pub.typeParent = heritage.type; }           if ( typeof heritage.vsn  ===  "number" ) { TDHC.pub.vsnParent = heritage.vsn; }           if ( typeof heritage.doc  ===  "string" ) { TDHC.doc = heritage.doc; }        }         if ( typeof apply.REPOS  ===  "object"              &&     apply.REPOS ) { REPOS = apply.REPOS; }        if ( typeof apply.ltr  ===  "boolean" ) { TDHC.ltr = apply.ltr; } else { TDHC.ltr = true; }        cnf = mw.config.get( [ "wgUserLanguage",                                "wgUserName" ] ); TDHC.slang = cnf.wgUserLanguage.toLowerCase; TDHC.listen = cnf.wgUserName; TDHC.re.asc = new RegExp( "[^ -~]" ); TDHC.re.tag = new RegExp( "<[^<>]*>", "g" ); TDHC.re.tit = new RegExp( "^[^:]+:(.+)$" ); BABEL.fire; mw.hook( Signature + ".result" ).add( fire ); mw.hook( Signature + ".parsed" ).add( HOVER.fire ); mw.hook( Signature + ".clear" ).add( BABEL.flat ); }  }   // fired

function first { // Autorun on loading // Uses: //   >  Signature //   >  Sub //   >  Version //    < TDHC.signature //    < TDHC.pub //   mw.loader.getState //   mw.loader.state //   mw.hook //   (fired) // 2020-12-27 PerfektesChaos@de.wikipedia var signature = Signature + "/" + Sub, rls; TDHC.signature = "ext.gadget." + signature; if ( mw.loader.getState( TDHC.signature ) !==  "ready" ) { rls = { }; rls[ TDHC.signature ] = "ready"; mw.loader.state( rls ); TDHC.pub = { type: signature, vsn: Version }; mw.hook( signature + ".ready" ).fire( TDHC.pub ); mw.hook( Signature + ".init" ).add( fired ); }  }   // first

API.fault = function ( jqXHR, textStatus, errorThrown ) { // API failure // Precondition: //   Common failure call // Uses: //   >  Signature //   >< API.more //    < API.scream //    < API.errors // 2020-12-27 PerfektesChaos@de.wikipedia API.more = API.more - 1; if ( textStatus ) { switch ( typeof textStatus ) { case "object": if ( typeof textStatus.textStatus ===  "string" ) { API.scream = textStatus.textStatus; } else { API.scream = ""; }              if ( typeof textStatus.exception  ===  "string"                    &&     textStatus.exception ) { API.scream = API.scream + " ("                              + textStatus.exception + ")"; }              break; case "string": API.scream = textStatus; break; }  // switch typeof textStatus }     if ( errorThrown ) { if ( API.scream ) { API.scream = API.scream + " -- Error: "; }        API.scream = API.scream + errorThrown; }     if ( ! API.scream ) { API.scream = "???"; }     if ( typeof window.console  ===  "object"   &&           typeof window.console.log  ===  "function" ) { window.console.log( Signature + " * " + API.scream ); if ( typeof textStatus ===  "object"              &&     textStatus   &&              typeof window.console.dir  ===  "function" ) { window.console.dir( textStatus ); }     }      API.errors = false; };  // API.fault

API.find = function ( ask, another ) { // Receive page info by API // Precondition: //   ask      -- Array of page names //   another  -- continue, or not // Uses: //   >  API.query //   >  API.Api //   (API.found) //   (API.fault) // 2020-12-27 PerfektesChaos@de.wikipedia if ( another ) { API.query[ "continue" ] = another; }     API.query.titles = ask; API.Api.get( API.query ).done( API.found ) .fail( API.fault ); };  // API.find

API.fire = function ( add, after ) { // Start API retrieval // Precondition: //   add    -- true: TemplateData, else page info //   after  -- function to be executed after completion // Uses: //   >  TDHC.templates //   >  TDHC.slang //   >< API.Api //    < API.luxury //    < API.requests //    < API.n      //     < API.query //    < API.follow //   API.follower // 2020-12-27 PerfektesChaos@de.wikipedia var s, template; API.luxury  = add; API.requests = [ ]; for ( s in TDHC.templates ) { if ( API.luxury ) { template = TDHC.templates[ s ]; if ( ! template.shift ) { API.requests.push( s ); }        } else { API.requests.push( s ); }     }   // for s in TDHC.templates API.n = API.requests.length; if ( API.n ) { if ( ! API.Api ) { API.Api = new mw.Api; }        if ( add ) { API.query = { action: "templatedata", format: "json", lang:  TDHC.slang };        } else { API.query = { action:    "query", "continue": "", prop:      "info", redirects: "", inprop:    "displaytitle|watched" // |protection };        }         API.follow = after; API.follower; } else { API.requests = false; after; }  };   // API.fire

API.follower = function ( another ) { // Receive info by API // Precondition: //   another  -- continue, or not // Uses: //   >  API.max //   >< API.n      //    >< API.requests // 2020-12-27 PerfektesChaos@de.wikipedia var i, k, n, requests; if ( API.n > 0 ) { n = API.n - API.max; k = ( n < 0 ?  0  :  n ); requests = [ ]; for ( i = k; i < API.n;  i++ ) { requests.push( "template:" + API.requests[ i ] ); }  // for i         API.n = n;         API.find( requests, another ); } else { API.requests = false; API.follow; }  };   // API.follower

API.foreign = function ( array, after ) { // Update message set for current language // Precondition: //   array  -- array of message ID      //    after  -- function to be executed after completion // Uses: //   >< API.Api //   (API.fault) // 2020-12-27 PerfektesChaos@de.wikipedia if ( ! API.Api ) { API.Api = new mw.Api; }     API.Api.getMessages( array ).done( after ) .fail( API.fault ); };  // API.foreign

API.found = function ( arrived ) { // Answer arrived // Precondition: //   arrived  -- JSON result // Uses: //   >  TDHC.space //   >  TDHC.templates //   >  TDHC.listen //   >< API.n      //    >< API.requests //    < API.scream //   mw.util.getUrl //   API.follower // 2020-12-27 PerfektesChaos@de.wikipedia var i, id, ns, page, query, redir, s, template; if ( typeof arrived ===  "object"           &&     arrived ) { ns = TDHC.space.length + 1; if ( API.luxury ) { if ( typeof arrived.pages ===  "object" ) { for ( id in arrived.pages ) { page = arrived.pages[ id ]; s   = page.title.substr( ns ); if ( typeof TDHC.templates[ s ] ===  "object" ) { template      = TDHC.templates[ s ]; template.tData = page; }              }   // for id in arrived.pages }        } else { if ( typeof arrived.query ===  "object" ) { query = arrived.query; if ( typeof query.pages ===  "object" ) { for ( id in query.pages ) { page = query.pages[ id ]; s   = page.title.substr( ns ); if ( typeof TDHC.templates[ s ] ===  "object" ) { template = TDHC.templates[ s ]; } else { template = { shift: false }; TDHC.templates[ s ] = { }; }                    if ( typeof page.displaytitle  ===  "string" ) { template.show = page.displaytitle.substr( ns ); }                    if ( TDHC.listen  &&                          typeof page.watched  ===  "string" ) { template.listen = true; }                 }   // for id in query.pages if ( typeof query.redirects ===  "object" ) { for ( i = 0; i < query.redirects.length;  i++ ) { redir = query.redirects[ i ]; s    = redir.from.substr( ns ); if ( typeof TDHC.templates[ s ]                                                       ===  "object" ) { template      = TDHC.templates[ s ]; template.shift = redir.to.substr( ns ); template.href = mw.util.getUrl( page.title,                                                            { redirect:                                                              "no" } ); }                       s = redir.to.substr( ns ); if ( typeof TDHC.templates[ s ] !== "object" ) { redir              = { show:   s,                                                   shift:  false, listen: false }; TDHC.templates[ s ] = redir; API.requests.unshift( s ); API.n++; }                    }   // for i                  } }           }         }         API.follower; }     API.scream = false; };  // API.found

/* event.which  3 for right event.target    The DOM element that initiated the event.

BABEL.def = { // "aliases": "autovalue":         "-param-autovalue", "boolean":           "-param-type-boolean", "collapse":          "collapsible-collapse", "content":           "-param-type-content", "date":              "-param-type-date", "default":           "-param-default", "deprecated":        "-param-status-deprecated", "example":           "-param-example", "expand":            "collapsible-expand", // "label": "line":              "-param-type-line", "number":            "-param-type-number", "optional":          "-param-status-optional", // "params":            "-params", "required":          "-param-status-required", "status":            "-param-status", "string":            "-param-type-string", "suggested":         "-param-status-suggested", "type":              "-param-type", // "unknown": "unwatch":           "unwatch", "url":               "-param-type-url", "watch":             "watch", "wiki-file-name":    "-param-type-wiki-file-name", "wiki-page-name":    "-param-type-wiki-page-name", "wiki-template-name": "-param-type-wiki-template-name", "wiki-user-name":    "-param-type-wiki-user-name" };  // BABEL.translate

BABEL.fire = function { // Initialize messages storage // Uses: //   >  TDHC.slang //   >  BABEL.def //   >  BABEL.lower //   >< BABEL.translate //   >< BABEL.dict //   >< BABEL.lower //    < BABEL.slang // 2020-12-27 PerfektesChaos@de.wikipedia var date, less, load, repo, s, stored; if ( typeof mw.storage ===  "object"           &&     mw.storage   &&           typeof mw.storage.get  ===  "function"   &&           typeof mw.storage.remove  ===  "function"   &&           typeof mw.storage.set  ===  "function" ) { if ( ! BABEL.translate ) { BABEL.slang    = TDHC.slang.toLowerCase; BABEL.translate = { }; for ( s in BABEL.def ) { stored = BABEL.def[ s ]; if ( stored.substr( 0, 1 ) ===  "-" ) { stored = "templatedata-doc" + stored; }              BABEL.translate[ s ] = stored; }  // for s in BABEL.def }        if ( typeof BABEL.dict  !==  "object" ) { stored = mw.storage.get( Signature ); if ( stored ) { try { repo = JSON.parse( stored ); if ( typeof repo ===  "object"                       &&     repo ) { BABEL.dictionary = repo; if ( typeof repo.next ===  "number" ) { date = new Date; if ( repo.next < date.getTime ) { load = true; }                    }                     if ( typeof BABEL.dictionary[ BABEL.slang ]                                                        ===  "object" ) { BABEL.dict = BABEL.dictionary[ BABEL.slang ]; } else { load = true; }                 } else { less = true; }              } catch( ex ) { less = true; }           } else { load = true; }        }         if ( less || BABEL.lower ) { mw.storage.remove( Signature ); BABEL.lower = false; load       = true; }        if ( load ) { BABEL.fresh; }     }   };   // BABEL.fire

BABEL.flat = function { // Clear messages storage // Uses: //    < BABEL.lower //   BABEL.fire // 2020-12-27 PerfektesChaos@de.wikipedia BABEL.lower = true; BABEL.fire; };  // BABEL.flat

BABEL.fresh = function { // Update messages storage // Uses: //   >< BABEL.translate //   API.foreign // 2020-12-27 PerfektesChaos@de.wikipedia var q = [ ], s;     for ( s in BABEL.translate ) { q.push( BABEL.translate[ s ] ); }  // for s in BABEL.translate API.foreign( q, BABEL.freshed ); };  // BABEL.fresh

BABEL.freshed = function ( arrived ) { // Messages arrived // Precondition: //   arrived  -- JSON result // Uses: //   >  BABEL.maxDays //   >  BABEL.slang //   >  Signature //    < BABEL.dict //   mw.storage.set // 2020-12-27 PerfektesChaos@de.wikipedia var date = new Date, s;     if ( typeof BABEL.dictionary  !==  "object" ) { BABEL.dictionary = { }; }     BABEL.dictionary.next = date.getTime + BABEL.maxDays * 86400000; if ( typeof BABEL.dictionary[ BABEL.slang ] !==  "object" ) { BABEL.dictionary[ BABEL.slang ] = { }; }     BABEL.dict = BABEL.dictionary[ BABEL.slang ]; for ( s in arrived ) { if ( arrived[ s ] ) { BABEL.dict[ s ] = arrived[ s ]; }     }   // for s in arrived BABEL.dictionary[ BABEL.slang ] = BABEL.dict; mw.storage.set( Signature, JSON.stringify( BABEL.dictionary ) ); };  // BABEL.freshed

BABEL.from = function ( alien ) { // Translate a message // Precondition: //   alien  -- ID      // Postcondition: //   Returns string, which ever // Uses: //   >  BABEL.translate //   >  BABEL.dict //   BABEL.fetch // 2020-12-27 PerfektesChaos@de.wikipedia var r, s;     if ( BABEL.translate   &&           typeof BABEL.translate[ alien ]  ===  "string" ) { s = BABEL.translate[ alien ]; if ( s  &&              BABEL.dict   &&              typeof BABEL.dict[ s ]  ===  "string" ) { r = BABEL.dict[ s ]; }     }      return r || alien; };  // BABEL.from

DATAT.factory = function ( $area, apply ) { // Initialize TemplateData presentation // Precondition: //   $area  -- jQuery block element //   apply  -- template object // Postcondition: //   $area is equipped // Uses: //   >  Signature //   >  DATAT.css //   >  TDHC.ltr //   >  DATAT.toggle.show //   >  DATAT.toggle.img //   DATAT.find //   DATAT.$file //   BABEL.from //   (DATAT.flip) // 2020-12-27 PerfektesChaos@de.wikipedia var td   = apply.tData, $main = $( " " ), $span = $( " " ), story = DATAT.find( td, "description" ), flip; apply.box = { $box: $area }; story = ( story || "??????????" ); $span.text( story ); if ( typeof td.paramOrder ===  "object"           &&     td.paramOrder.length ) { apply.box.$widget = $( " " ); if ( TDHC.ltr ) { apply.box.$widget.css( { "float":      "right",                                     "margin-left": "1.5em" } ); } else { apply.box.$widget.css( { "float":       "left",                                     "margin-right": "1.5em" } ); }        flip = function  { DATAT.flip( apply, true ); }; apply.box.$details = false; apply.box.$expand = DATAT.$file( DATAT.toggle.show,                                           DATAT.toggle.img ); apply.box.$expand.attr( "title", BABEL.from( "expand" ) ) .click( flip ); apply.box.$widget.append( apply.box.$expand ); $main.append( apply.box.$widget ); }     $main.append( $span ); $area.addClass( Signature + "-box" ) .css( DATAT.css ) .append( $main ); };  // DATAT.factory

DATAT.feature = function ( $append, assign, assigned ) { // Create single parameter description // Precondition: //   $append   -- jQuery object to be appended //   assign    -- canonical parameter name //   assigned  -- param object // Uses: //   >  DATAT.colors //   DATAT.find //   BABEL.from // 2020-12-27 PerfektesChaos@de.wikipedia var $dt = $( "" ), $dl = $( "" ), css, i, s, status, $d, $dd; if ( typeof assigned.required ===  "boolean"           &&     assigned.required ) { status = "required"; } else if ( typeof assigned.suggested ===  "boolean"           &&     assigned.suggested ) { status = "suggested"; } else if ( typeof assigned.deprecated ===  "boolean"           &&     assigned.deprecated ) { status = "deprecated"; } else { status = "optional"; }     //  $dl   list-style: outside none none; css = { "background-color": "#" + DATAT.colors[ status ] }; if ( status === "optional" ) { css.color = "#" + DATAT.colors.optionalFG; }     $dt.css( css ) .css( { "font-family":  "monospace, monospace",                 "padding-left":  "0.2em",                 "padding-right": "0.2em" } ) .text( assign ); $append.append( $dt ); if ( typeof assigned.aliases ===  "object"           &&     assigned.aliases.length ) { for ( i = 0; i < assigned.aliases.length;  i++ ) { $dt = $( "" ); $dt.css( { "font-weight":  "normal",                       "padding-left":  "0.2em",                       "padding-right": "0.2em" } ) .css( css ) .text( assigned.aliases[ i ] ); $append.append( $dt ); }  // for i      } s = DATAT.find( assigned, "description" ); if ( s ) { $dd = $( "" ); $dd.css( css ) .text( s ); $append.append( $dd ); }     if ( typeof assigned.type  ===  "string"           &&     assigned.type ) { $dt = $( "" ); $dt.text( BABEL.from( "type" ) ); $dl.append( $dt ); $d = $( "" ); $d.text( BABEL.from( assigned.type ) ); $dl.append( $d ); }     $dt = $( "" ); $dt.text( BABEL.from( "status" ) ); $dl.append( $dt ); $d = $( "" ); $d.text( BABEL.from( status ) ); $dl.append( $d ); s = DATAT.find( assigned, "default" ); if ( s ) { $dt = $( "" ); $dt.text( BABEL.from( "default" ) ); $dl.append( $dt ); $d = $( "" ); $d.text( s ); $dl.append( $d ); }     s = DATAT.find( assigned, "example" ); if ( s ) { $dt = $( "" ); $dt.text( BABEL.from( "example" ) ); $dl.append( $dt ); $d = $( "" ); $d.text( s ); $dl.append( $d ); }     s = DATAT.find( assigned, "autovalue" ); if ( s ) { $dt = $( "" ); $dt.text( BABEL.from( "autovalue" ) ); $dl.append( $dt ); $d = $( "" ); $d.text( s ); $dl.append( $d ); }     $dd = $( "" ); $dd.css( css ) .append( $dl ); $append.append( $dd ); };  // DATAT.feature

DATAT.$features = function ( assigned ) { // Create details, if any // Precondition: //   assigned  -- templatedata object // Postcondition: //   Returns jQuery $element with collapsible box // Uses: //   >  DATAT.scroll //   DATAT.feature // 2020-12-27 PerfektesChaos@de.wikipedia var $div = $( " " ), $dl = $( "" ), $hr = $( " " ), $r  = $( " " ), i, s;     $div.css( { "max-height": DATAT.scroll,                  "overflow":   "auto" } ); for ( i = 0; i < assigned.paramOrder.length;  i++ ) { s = assigned.paramOrder[ i ]; DATAT.feature( $dl, s, assigned.params[ s ] ); }  // for i      $div.append( $dl ); $r.append( $hr ) .append( $div ); return $r; };  // DATAT.$features

DATAT.$file = function ( access, appear ) { // Create image // Precondition: //   access  -- media ID      //               .src   -- page title //              .sub   -- 2-char-code of subdir //              .site  -- default: commons //   appear  -- number, of pixels // Postcondition: //   Returns jQuery // Uses: //   >  TDHC.re.spc // 2020-12-27 PerfektesChaos@de.wikipedia var src = access.src.replace( TDHC.re.spc, "_" ),  // + encode $r = $( " " ); $r.attr( "src", "https://upload.wikimedia.org/wikipedia/commons"                     + "/thumb/"                      + access.sub.substr( 0, 1 ) + "/"                      + access.sub + "/"                      + src + "/"                      + appear + "px-" + src + ".png" ); return $r; };  // DATAT.$file

DATAT.find = function ( answer, at ) { // Detect appropriate translation // Precondition: //   answer  -- object, with components //   at      -- string, with ID of I18N (object or string) // Postcondition: //   Returns string, or not // Uses: //   >  TDHC.slang // 2020-12-27 PerfektesChaos@de.wikipedia var r, s;     switch ( typeof answer[ at ] ) { case "object": if ( ! answer[ at ] ) { r = false; } else if ( typeof answer[ at ][ TDHC.slang ] ===  "string"                        &&     answer[ at ][ TDHC.slang ] ) { r = answer[ at ][ TDHC.slang ]; } else if ( typeof answer[ at ].en ===  "string"                        &&     answer[ at ].en ) { r = answer[ at ].en; } else { for ( s in answer[ at ] ) { if ( typeof answer[ at ][ s ] ===  "string"                       &&     answer[ at ][ s ] ) { r = answer[ at ][ s ]; break;  // for s                  } }  // for s in arrived }           break; case "string": r = answer[ at ]; break; case "undefined": r = false; break; default: r = "????"; }  // switch typeof answer return r;  };   // DATAT.find

DATAT.flip = function ( assigned, action ) { // Toggle details expansion // Precondition: //   assigned  -- template object //   action    -- true: expand // Uses: //   >  DATAT.toggle.hide //   >  DATAT.toggle.img //   DATAT.$features //   DATAT.$file //   BABEL.from //   (DATAT.flip) // 2020-12-27 PerfektesChaos@de.wikipedia var box = assigned.box, flip = function { DATAT.flip( assigned, false ); }; if ( ! box.$details ) { box.$details = DATAT.$features( assigned.tData ); box.$box.append( box.$details ); box.$collapse = DATAT.$file( DATAT.toggle.hide,                                       DATAT.toggle.img ); box.$collapse.attr( "title", BABEL.from( "collapse" ) ) .click( flip ) .hide; box.$widget.append( box.$collapse ); }     if ( action ) { box.$expand.hide; box.$collapse.show; box.$details.show; } else { box.$expand.show; box.$collapse.hide; box.$details.hide; }  };   // DATAT.flip

HOVER.fire = function ( about, acquired ) { // Parsed request arrived // Precondition: //   about     -- page information //   acquired  -- templates collection // Uses: //    < TDHC. //    < TDHC.templates //   BABEL.fire // 2020-12-27 PerfektesChaos@de.wikipedia if ( typeof about ===  "object"           &&     about    &&           typeof acquired  ===  "object"           &&     acquired ) { console.log("HOVER.fire",about,acquired) TDHC.parsed   = about; TDHC.templates = acquired; BABEL.fire; }  };   // HOVER.fire

ORDER.fetch = function { // Retrieve collating weight table // Uses: //   >  ORDER.util.signature //    < ORDER.collate //   mw.storage.get //   JSON //   ORDER.fresh // 2020-12-27 PerfektesChaos@de.wikipedia var date, repo, stored; if ( typeof mw.storage ===  "object"           &&     mw.storage   &&           typeof mw.storage.get  ===  "function" ) { stored = mw.storage.get( ORDER.util.signature ); if ( stored ) { try { repo = JSON.parse( stored ); if ( typeof repo ===  "object"                    &&     repo ) { if ( typeof repo.s ===  "object"                       &&     repo.s ) { ORDER.collate = repo.s;                 } if ( typeof repo.next ===  "number" ) { date = new Date; if ( repo.next < date.getTime ) { ORDER.fresh; }                 }               }            } catch( ex ) { }        } else { ORDER.fresh; }     }      if ( ! ORDER.collate ) { ORDER.collate = { 0xDF:  "ss", 0xE0:	 "a", 0xE1:	 "a", 0xE2:	 "a", 0xE3:	 "a", 0xE4:	 "a", 0xE5:	 "a", 0xE6:	 "ae", 0xE7:	 "c", 0xE8:	 "e", 0xE9:	 "e", 0xEA:	 "e", 0xEB:	 "e", 0xEC:	 "i", 0xED:	 "i", 0xEE:	 "i", 0xEF:	 "i", 0xF0:	 "d", 0xF1:	 "n", 0xF2:	 "o", 0xF3:	 "o", 0xF4:	 "o", 0xF5:	 "o", 0xF6:	 "o", 0xF8:	 "o", 0xF9:	 "u", 0xFA:	 "u", 0xFB:	 "u", 0xFC:	 "u", 0xFD:	 "y", 0xFE:	 "th", 0xFF:	 "y", 0xA0:	 " ", 0x1680: " ", 0x2000: " ", 0x2001: " ", 0x2002: " ", 0x2003: " ", 0x2004: " ", 0x2005: " ", 0x2006: " ", 0x2007: " ", 0x2008: " ", 0x2009: " ", 0x200A: " ", 0x3000: " ", 0x303F: " ", 0x200B: "", 0x200C: "", 0x200D: "", 0x200E: "", 0x200F: "", 0xAD:  "", 0xAB:  "\"", 0xBB:   "\"", 0x2018: "'", 0x2019: "'", 0x201A: "'", 0x201B: "'", 0x2039: "'", 0x203A: "'", 0x201C: "\"", 0x201D: "\"", 0x201E: "\"", 0x201F: "\"", 0x2010: "-", 0x2011: "-", 0x2012: "-", 0x2013: "-", 0x2014: "-", 0x2015: "-", 0x202F: " ", 0x205F: " ", 0x2043: "-", 0x2044: "/", 0x2052: "-", 0x2212: "-", 0xB7:  ".", 0xA9:  "(c)", 0xAA:  "a", 0xAE:  "[TM]", 0xB2:  "2", 0xB3:  "3", 0xB9:  "1", 0xBA:  "o" };     }   };   // ORDER.fetch

ORDER.fire = function { // Create sort keys // Uses: //   >  TDHC.templates //   >  TDHC.re.asc //   ORDER.flat // 2020-12-27 PerfektesChaos@de.wikipedia var s, sort, template; for ( s in TDHC.templates ) { template = TDHC.templates[ s ]; if ( typeof template.show ===  "string" ) { sort = template.show; } else { sort = s;        } sort = sort.toLowerCase; if ( TDHC.re.asc.test( sort ) ) { sort = ORDER.flat( sort ); }        template.sort = sort; }  // for s in TDHC.templates };  // ORDER.fire

ORDER.flat = function ( alien ) { // Reduce sort key, best to ASCII // Precondition: //   alien  -- string with sort key // Postcondition: //   Returns string with sort key // Uses: //   >  ORDER.collate //   ORDER.fetch // 2020-12-27 PerfektesChaos@de.wikipedia var r = alien, i, k;     if ( ! ORDER.collate ) { ORDER.fetch; }     for ( i = alien.length - 1;  i >= 0;  i-- ) { k = r.charCodeAt( i ); if ( k > 126  &&              typeof ORDER.collate[ k ]  ===  "string" ) { r = ( i ?  r.substr( 0, i )  :  "" ) + ORDER.collate[ k ] + r.substr( i + 1 ); }     }   // for i-- return r;  };   // ORDER.flat

ORDER.follower = function ( a1, a2 ) { // Compare template objects // Precondition: //   a1  -- template object //   a2  -- template object // Postcondition: //   Returns   -1, if b < a      //               0, if a = b   -- does never happen //              1, if a < b      // Uses: //   >  TDHC.templates // 2020-12-27 PerfektesChaos@de.wikipedia return ( a1.sort > a2.sort  ?  1  :  -1 ); };  // ORDER.follower

ORDER.fresh = function { // Build or update sort key mapping // Uses: //   >  TDHC.REPOS // 2020-12-27 PerfektesChaos@de.wikipedia };  // ORDER.fresh

QUERY.fire = function { // Add TemplateData presentation to search results // Uses: //   >  TDHC.result.got //   >  TDHC.result.$container //   >  TDHC.uid.sign //   >  TDHC.templates //   >  TDHC.$widget //    < QUERY.got //    < QUERY.$container // 2020-12-27 PerfektesChaos@de.wikipedia var i, sign, template, $a, $li, $div; QUERY.got       = TDHC.result.got; QUERY.$container = TDHC.result.$container; for ( i = 0; i < QUERY.got.length;  i++ ) { $li = QUERY.got[ i ]; $a  = $li.find( "a" ).eq( 0 ); sign = $a.data( TDHC.uid.sign ); if ( sign ) { template = TDHC.templates[ sign ]; if ( template  &&                 typeof template.tData  ===  "object" ) { $div = $( " " ); DATAT.factory( $div, template ); $li.append( $div ); }        }      }   // for i      TDHC.$widget.remove; };  // QUERY.fire

UL2DL.fence = function { // Prepare category // Uses: //   >  TDHC.space //   >  UL2DL.$dl //   UL2DL.$flag // 2020-12-27 PerfektesChaos@de.wikipedia var $h2 = $( " " ); $h2.text( TDHC.space ); UL2DL.$container.after( UL2DL.$dl ); UL2DL.$container.after( UL2DL.$flag( true ) ); UL2DL.$container.after( $h2 ); };  // UL2DL.fence

UL2DL.filter = function { // Transfer <li> elements into <dt> (+ <dd>) // Uses: //   >  Signature //   >  TDHC.uid.sign //   >  TDHC.templates //   >  TDHC.re.spc //   >  TDHC.re.wsp //   >  TDHC.ltr //   ><  UL2DL.got //    <  UL2DL.result //   mw.util.getUrl //   BABEL.from // 2020-12-27 PerfektesChaos@de.wikipedia var sect = Signature + "@", i, s, sign, template, $a, $contents, $dd, $li, $span; UL2DL.result = [ ]; for ( i = 0; i < UL2DL.got.length;  i++ ) { $li = UL2DL.got[ i ]; $li.detach; $a      = $li.find( "a" ).eq( 0 ); sign    = $a.data( TDHC.uid.sign ); template = TDHC.templates[ sign ]; if ( template ) { if ( typeof template.href !==  "string" ) { template.href = $a.attr( "href" ); }           $a.remove; template.$dt = $( "<dt>" ); $a          = $( "<a>" ); $a.attr( { href: template.href,                      id:   sect + sign.replace( TDHC.re.spc, "_" )                     } ) .text( template.show ); if ( template.shift ) { $a.addClass( "mw-redirect" ); }           template.$dt.append( $a ); if ( TDHC.listen ) { s = ( template.listen ? "un" : "" )  +  "watch"; $a = $( "<a>" ); $a.attr( { href: mw.util.getUrl( "Template:" + template.show, { action: s } ),                         title: BABEL.from( s ) } ) .css( "padding-" +  ( TDHC.ltr ? "left" : "right" ),                      "3em" ); if ( template.listen ) { $a.text( String.fromCharCode( 0x2605 ) ); } else { $span = $( " " ); $span.css( { "font-weight": "normal" } ) .text( String.fromCharCode( 0x2606 ) ); $a.append( $span ); }              template.$dt.append( $a ); }           template.dd = [ ]; $contents = $li.contents; if ( ! TDHC.re.wsp.test( $contents.text ) ) { $dd = $( "<dd>" ); $dd.append( $contents.clone ); template.dd.push( $dd ); }           if ( typeof template.shift  ===  "string" ) { $dd  = $( "<dd>" ); $span = $( " " ); if ( TDHC.ltr ) { $span.css( { "padding-right": "1em" } ) .text( String.fromCharCode( 0x21A6 ) ); } else { $span.css( { "padding-left": "1em" } ) .text( String.fromCharCode( 0x21A4 ) ); }              $span.css( { "font-weight": "bolder" } ); $dd.append( $span ); $a = $( "<a>" ); $a.attr( { href:                           "#" + sect                            + template.shift.replace( TDHC.re.spc, "_" ),                          title: "redirect" } ) .text( template.shift ); // title $dd.append( $a ); template.dd.push( $dd ); }           UL2DL.result.push( template ); }        $li.remove; }  // for i      UL2DL.got = false; };  // UL2DL.filter

UL2DL.finish = function { // Sort templates and insert in <dl> // Uses: //   >  UL2DL.result //   >  UL2DL.$dl //   >  TDHC.$widget //   ORDER.fire //   UL2DL.$flag //   DATAT.factory //   (ORDER.follower) // 2020-12-27 PerfektesChaos@de.wikipedia var i, j, template, $dd; ORDER.fire; UL2DL.result.sort( ORDER.follower ); UL2DL.$flag( false ); for ( i = 0; i < UL2DL.result.length;  i++ ) { template = UL2DL.result[ i ]; if ( typeof template.dd !==  "object" ) { template.dd = [ ]; }        if ( typeof template.tData  ===  "object" ) { $dd = $( "<dd>" ); DATAT.factory( $dd, template ); template.dd.push( $dd ); }        UL2DL.$dl.append( template.$dt ); for ( j = 0; j < template.dd.length;  j++ ) { UL2DL.$dl.append( template.dd[ j ] ); }  // for j      }   // for i      TDHC.$widget.remove; };  // UL2DL.finish

UL2DL.fire = function { // Conversion of <ul> elements into <dl> // Uses: //   >  TDHC.result.scope //   >  TDHC.result.got //   >  TDHC.result.$container //    < UL2DL.got //    < UL2DL.$container //    < UL2DL.$dl //   UL2DL.fence //   UL2DL.filter //   UL2DL.fold //   API.fire //   (UL2DL.finish) // 2020-12-27 PerfektesChaos@de.wikipedia var later = ( TDHC.result.scope === "category"  ||                    TDHC.result.scope === "whatlinkshere" ); UL2DL.got       = TDHC.result.got; UL2DL.$container = TDHC.result.$container; UL2DL.$dl       = $( "<dl>" ); if ( later ) { UL2DL.fence; } else { UL2DL.$container.before( UL2DL.$dl ); }     UL2DL.filter; if ( later ) { UL2DL.fold; } else { if ( UL2DL.$container.children.length ) { UL2DL.$dl.after( $( " " ) ); } else { UL2DL.$container.remove; }     }      API.fire( true, UL2DL.finish ); };  // UL2DL.fire

UL2DL.$flag = function ( active ) { // Show ajax symbol or stop // Precondition: //   active  -- true: start, false: terminate // Postcondition: //   Returns $element, if active // Uses: //   >< UL2DL.$ajax // 2020-12-27 PerfektesChaos@de.wikipedia if ( active ) { UL2DL.$ajax = $( " " ); UL2DL.$ajax.addClass( "mw-ajax-loader" ) .css( { "margin-top": "1em"                        } ) .text( String.fromCharCode( 160 ) ); } else if ( UL2DL.$ajax ) { UL2DL.$ajax.remove; }     return UL2DL.$ajax; };  // UL2DL.$flag

UL2DL.fold = function { // Cleanup category // Uses: //   >  UL2DL.$container //   UL2DL.folded //   UL2DL.folder // 2020-12-27 PerfektesChaos@de.wikipedia UL2DL.$container.find( "ul" ).each( UL2DL.folded ); UL2DL.$container.find( ".mw-category-group" ).each( UL2DL.folder ); };  // UL2DL.fold

UL2DL.folded = function ( at, assigned ) { // Remove empty category <ul> // Precondition: //   at        -- number of <ul>, ignored //   assigned  -- DOM object of <ul> // 2020-12-27 PerfektesChaos@de.wikipedia var $ul = $( assigned ); if ( ! $ul.children.length ) { $ul.remove; }  };   // UL2DL.folded

UL2DL.folder = function ( at, assigned ) { // Remove empty category // Precondition: //   at        -- number of, ignored //   assigned  -- DOM object of       // 2020-12-27 PerfektesChaos@de.wikipedia var $div = $( assigned ); if ( $div.children.length < 2 ) { $div.remove; }  };   // UL2DL.folder

first; }( window.mediaWiki, window.jQuery ) );

/// User:PerfektesChaos/js/templatedataHint/d.js /// 2020-12-27 PerfektesChaos@de.wikipedia // Enrich links to template pages with templatedata // Part 1: Check wiki page for template links, equip with button etc. //  ResourceLoader:  compatible; //   dependencies: mediawiki.api, //                 mediawiki.storage, //                 mediawiki.ui.button, //                 mediawiki.util /// Fingerprint: #0#0# /// License: CC-by-sa/4.0 /// /* global window: false                                               */ /* jshint forin: false, bitwise:true, curly:true, eqeqeq:true, latedef:true, laxbreak:true, nocomma:true, strict:true, undef:true, unused:true          */

( function ( mw, $ ) {  "use strict";   var Version   = -0.4,       Signature = "templatedataHint",       Store     = "User:PerfektesChaos/js/" + Signature,       TDH       = { core:        { maxage: 86400,                                    site:   "w:en",                                    store:  Store },                     doc:         { site:   "w:en",                                    store:  Store },                     paged:       { "allpages":                                      { suite:  ".mw-allpages-nav",                                        search: ".mw-allpages-body"                                      },                                    "category":                                      { suite:  "#mw-pages",                                        search: "#mw-pages"                                      },                                    "info":                                      { suite:  "#mw-pageinfo-templates" + " td:first-child", search: "#mw-pageinfo-templates" + " td:nth-child(2)" + " ul" },                                   "prefixindex": { suite: ".mw-prefixindex-nav", search: ".mw-prefixindex-body" },                                   "private": { suite: "." + Signature + "-private", search: "." + Signature + "-private" },                                   "search": { suite: ".mw-search-results", search: ".mw-search-result-" + "heading" },                                   "used": { suite: ".templatesUsed", search: ".templatesUsed" + " ul" },                                   "whatlinkshere": { suite: "#mw-whatlinkshere-list", search: "#mw-whatlinkshere-list" },                                   "wikitext": { search: ".mw-parser-output" } },                    pages:       { "*":        { button: { large: true, lead: true },                                                 list:   true },                                   "info":     { button: { large: false, lead: false, low:  true },                                                 list:   true },

"private": { button: { large: false, lead: true },                                                 list:   true },                                   "search":   { button: { large: true, lead: true },                                                 list:   false },                                   "used":     { button: { large: false, lead: false, low:  false },                                                 list:   true },                                   "wikitext": { button: false, list:  false }                                 },                       parsed:    false, re:       false, result:   false, show:     " TemplateData", space:    false, templates: false, types:    false, wiki0ns0: [ "commons.wikimedia.org", "wikibooks.org", "wikidata.org", "wikinews.org", "wikipedia.org", "wikiquote.org", "wikisource.org", "wikiversity.org", "wiktionary.org" ]                    },       REPOS     = { }; TDH.REPOS = REPOS;

function face { // Page orientation // Precondition: //   DOM ready // Uses: //   >< TDH.$body //    < TDH.ltr // 2020-12-27 PerfektesChaos@de.wikipedia if ( ! TDH.$body ) { TDH.$body = $( "body" ); TDH.ltr  = ( $( "html" ).attr( "dir" )  !==  "rtl" ); }  }   // face

function favoured ( area ) { // Check namespace for probability // Precondition: //   area  -- namespace number // Postcondition: //   Returns true if templatedata could be expected // Uses: //   >  wiki0ns0 // 2020-12-27 PerfektesChaos@de.wikipedia var r = true, i, s, site; switch ( area ) { case 0: site = window.location.host; for ( i = 0; i < TDH.wiki0ns0.length;  i++ ) { s = TDH.wiki0ns0[ i ]; if ( site.substr( site.length - s.length ) ===  s ) { r = false; break;  // for i               } }  // for i            break; case 6: r = false; break; }  // switch area return r;  }   // favoured

function feed { // All preconditions met, run core script // Uses: //   >  Signature //   >  TDH //   mw.hook // 2020-12-27 PerfektesChaos@de.wikipedia mw.hook( Signature + ".init" ).fire( TDH ); }  // feeder

function feeder { // Retrieve core script // Uses: //   >  Signature //   >< TDH.core //   REPOS.fire //   mw.loader.using //   (feed) // 2020-12-27 PerfektesChaos@de.wikipedia if ( TDH.core ) { TDH.core.suite = ( Version > 1 ?  "r"  :  "d" ); if ( TDH.core.suite !== "r" ) { TDH.core.maxage = 100; }        REPOS.fire( TDH.core.site,                     TDH.core.store,                     "/" + TDH.core.suite + ".js",                     { maxage: TDH.core.maxage } ); TDH.core = false; mw.loader.using( [ "mediawiki.api",                           "mediawiki.storage",                            "mediawiki.util" ],                          feed ); }  }   // feeder

function fence ( access ) { // Modify info page table cell // Precondition: //   access  -- selector of       // 2020-12-27 PerfektesChaos@de.wikipedia var $td = $( access ), $div = $( " " ), $cnt = $td.contents; $cnt.detach; $div.append( $cnt ); $td.append( $div ); $div = $( " " ); $div.css( { clear: "both" } ); $td.append( $div ); }  // fence

function fetch { // Button has been pressed // Uses: //   >  TDH.$button //   >  Signature //   >  TDH.$widget //   >  TDH.result //   >  TDH.templates //   feeder //   mw.hook // 2020-12-27 PerfektesChaos@de.wikipedia var $ajax = $( " " ); TDH.$button.remove; $ajax.addClass( "mw-ajax-loader",                     Signature + "-ajax" ) .css( { "margin-bottom": "0.2em",                  "margin-left":   "1em",                   "margin-right":  "1em",                   "margin-top":    "0.2em" } ) .text( String.fromCharCode( 160 ) ); TDH.$widget.append( $ajax ); feeder; mw.hook( Signature + ".result" ).fire( TDH.result,                                            TDH.templates ); }  // fetch

function fiat ( at, assigned ) { // Matching link // Precondition: //   at        -- number of link to template, ignored //   assigned  -- DOM object of link to template // Uses: //   >  TDH.re.rel //   >  TDH.re.abs //   >  TDH.page //   >  TDH.re.usc //   >  TDH.uid.sign //   >  TDH.uid.hover //   >< TDH.templates //   >< TDH.got // 2020-12-27 PerfektesChaos@de.wikipedia var $a = $( assigned ), s = $a.attr( "href" ), got, template, $parent; if ( s.substr( 0, 1 ) === "/" ) { got = TDH.re.rel.exec( s ); } else { got = TDH.re.abs.exec( s ); }     if ( got ) { s = got[ 1 ]; try { s = decodeURIComponent( s ); } catch ( e ) { }        s = s.replace( TDH.re.usc, " " ); $a.data( TDH.uid.sign, s ); TDH.templates     = TDH.templates  ||  { }; TDH.templates[ s ] = { }; template          = TDH.templates[ s ]; template.show     = s;         template.shift     = false; template.listen   = false; if ( TDH.page.button ) { $parent = $a.parents( "li" ); TDH.page.got.push( $parent ); } else { $a.addClass( TDH.uid.hover ); }     }   }   // fiat

function fill ( apply ) { // Insert button // Precondition: //   apply  -- descriptive object //             .large  -- large or line-size? //             .lead   -- begin of block or float at end? //             .sel    -- selector ahead of which to insert. // Uses: //   >  TDH.ltr //   >  Signature //   >  Version //   >  TDH.show //    < TDH.$widget //    < TDH.$button //   mw.loader.load //   face //   (fetch) // 2020-12-27 PerfektesChaos@de.wikipedia var css  = { "background-color": "#3366CC", "border":          "1px solid #3366CC", "border-radius":   "2px", "color":           "#FFFFFF", "cursor":          "pointer", "display":         "inline-block", "font-weight":     "bold", "line-height":     "1.286", "padding":         "0.546875em 1em", "text-align":      "center", "vertical-align":  "middle", "white-space":     "nowrap" },         $rel = $( apply.sel ), low; mw.loader.load( "mediawiki.ui.button" ); // w:de:Template:MediaWiki-Button/styles.css TDH.$button = $( " " ); if ( apply.large ) { css[ "font-size" ] = "1.3em"; }     if ( ! apply.lead ) { face; if ( TDH.ltr ) { TDH.$button.addClass( "float-right" ); } else { TDH.$button.addClass( "float-left" ); }        low = apply.low; }     TDH.$button.addClass( [ "mw-ui-button",                              "mw-ui-progressive",                              Signature + "-button" ] ) .attr( { "role":  "button",                       "title":  Signature + " " + Version } ) .click( fetch ) .css( css ) .text( TDH.show ); TDH.$widget = $( " " ); TDH.$widget.append( TDH.$button ); if ( low ) { $rel.append( TDH.$widget ); } else { $rel.prepend( TDH.$widget ); }  }   // fill

function fire { // Document ready // Uses: //   >  TDH.space //   >  TDH.pages //   >  TDH.templates //   >< TDH.page //    < TDH.result //    < TDH.parsed //   mw.loader.load //   fence //   fill //   feeder //   mw.hook //   (fiat) // 2020-12-27 PerfektesChaos@de.wikipedia var seek = TDH.space.replace( TDH.re.spc, "_" ), i, scope, $got; seek = "/wiki/" + encodeURIComponent( seek ) + ":"; seek = "a[href*=\"" + seek + "\"]:not(a[href*=\"#\"])"; for ( i = 0; i < TDH.types.length;  i++ ) { scope = TDH.types[ i ]; switch ( scope ) { case "allpages": case "prefixindex": case "whatlinkshere": case "category": TDH.page = TDH.pages[ "*" ]; break; default: TDH.page = TDH.pages[ scope ]; }  // switch scope TDH.page.button.sel = TDH.paged[ scope ].suite; TDH.page.search    = TDH.paged[ scope ].search; TDH.page.$container = $( TDH.page.search ); $got               = TDH.page.$container.find( seek ); if ( $got.length ) { if ( TDH.page.button ) { TDH.page.got = [ ]; }           $got.each( fiat ); if ( TDH.templates ) { TDH.page.scope = scope; if ( TDH.page.button ) { if ( scope === "info" ) { fence( TDH.page.button.sel ); }                 TDH.result = TDH.page; fill( TDH.page.button ); } else { TDH.parsed     = TDH.page; TDH.parsed.$got = $got; feeder; mw.hook( Signature + ".parsed" ).fire( TDH.parsed,                                                        TDH.templates ); }           }         }      }   // for i      TDH.page = false; }  // fire

function firing ( alone ) { // Check request conditions // Precondition: //   alone  -- TDH if internal hook call // Uses: //   >  Signature //   >< TDH.types //    < TDH.re      //     < TDH.space //    < TDH.uid //   mw.config.get //   favoured //   mw.hook //   (fire) // 2020-12-27 PerfektesChaos@de.wikipedia var cnf, listen, s;     mw.hook( Signature + ".private" ).remove( firing ); if ( ! TDH.types ) { TDH.types = [ ]; cnf      = mw.config.get( [ "wgAction",                                      "wgPageContentModel",                                      "wgNamespaceNumber" ] ); listen   = ( alone !== TDH ); switch ( cnf.wgAction ) { case "view": if ( cnf.wgNamespaceNumber === -1 ) { s = mw.config.get( "wgCanonicalSpecialPageName" ); switch ( s ) { case "Allpages": case "Prefixindex": case "Search": case "Whatlinkshere": TDH.types.push( s.toLowerCase ); break; }  // switch wgCanonicalSpecialPageName } else if ( cnf.wgPageContentModel === "wikitext" ) { if ( favoured( cnf.wgNamespaceNumber ) ) { // TDH.types.push( "wikitext" ); }                 if ( listen ) { TDH.types.push( "private" ); }                 if ( cnf.wgNamespaceNumber === 14 ) { TDH.types.push( "category" ); }              }               break; case "edit": case "submit": if ( cnf.wgPageContentModel === "wikitext" ) { if ( favoured( cnf.wgNamespaceNumber ) ) { // TDH.types.push( "wikitext" ); }                 TDH.types.push( "used" ); if ( listen ) { TDH.types.push( "private" ); }              }               break; case "info": TDH.types.push( "info" ); break; }  // switch wgAction //console.log(TDH.types) if ( TDH.types.length ) { s        = Signature.toLowerCase + "-"; TDH.re   = { abs: new RegExp( "^(?:[htps]*:)?"                                           + "//[^:]+:(.+)$" ), rel: new RegExp( "^/[^:]+:(.+)$" ), spc: new RegExp( " ", "g" ), usc: new RegExp( "_", "g" ), wsp: new RegExp( "^\\s*$" ) };           TDH.space = mw.config.get( "wgFormattedNamespaces" )[ "10" ]; TDH.uid  = { hover: s + "hover", sign: s + "sign" };           $( fire ); }     }   }   // firing

function first { // Autorun on loading // Uses: //   >  Signature //   >  TDH.doc //   >  Version //    < TDH.signature //    < TDH.pub //   mw.loader.getState //   mw.loader.state //   mw.hook //   (firing) // 2020-12-27 PerfektesChaos@de.wikipedia var rls, s;     TDH.signature = "ext.gadget." + Signature; if ( mw.loader.getState( TDH.signature ) !==  "ready" ) { rls = { }; rls[ TDH.signature ] = "ready"; mw.loader.state( rls ); s = "" + TDH.doc.site + "/" + TDH.doc.store + ""; TDH.pub = { doc:      s,                     signature: TDH.signature, type:     Signature, vsn:      Version }; mw.hook( Signature + ".ready" ).fire( TDH.pub ); mw.hook( Signature + ".private" ).add( firing ); mw.hook( Signature + ".private" ).fire( TDH ); }  }   // first

REPOS.fire = function ( at, access, append, alter ) { // Load from external URL // Precondition: //   at      -- Wikimedia Foundation site code, or not //   access  -- string with basic page name //   append  -- string with subpage, or not //   alter   -- parameter object, or MIME string, or not // Uses: //   >< REPOS.requests //   REPOS.foundation //   mw.loader.load // 2018-03-21 PerfektesChaos@de.wikipedia var source, syntax; if ( typeof REPOS.requests !==  "object" ) { REPOS.requests = { }; }     if ( typeof REPOS.requests[ access ]  !==  "boolean" ) { REPOS.requests[ access ] = true; if ( append ) { source = access + append; } else { source = access; }        if ( at ) { source = REPOS.foundation( at, source, alter ); if ( typeof alter ===  "object"                 &&     alter   &&                 typeof alter.ctype  ===  "string" ) { syntax = alter.ctype; }        } else { syntax = alter; }        mw.loader.load( source, syntax ); }  };   // REPOS.fire

REPOS.foundation = function ( at, access, alter ) { // Create URL within Wikimedia Foundation // Precondition: //   at      -- site code, or not //   access  -- string with page name //   alter   -- parameter object, or not // Postcondition: //   Returns full URL // 2018-03-21 PerfektesChaos@de.wikipedia var s = access, r = encodeURI( s ); if ( typeof alter ===  "object"           &&     alter ) { r = "/w/index.php?title=" + r;        if ( access.substr( -3 ) === ".js" ) { alter.ctype = "text/javascript"; } else if ( access.substr( -4 ) === ".css" ) { alter.ctype = "text/css"; }        alter.action = "raw"; for ( s in alter ) { r = r + "&" + s + "=" + encodeURI( alter[ s ] ); }  // for s in alter } else { r = "/wiki/" + r;     } if ( typeof at ===  "string"           &&     at ) { switch ( at ) { case "meta": r = "meta.wikimedia.org" + r;              break; case "mw": r = "www.mediawiki.org" + r;              break; case "w:en": r = "en.wikipedia.org" + r;              break; default: r = window.location.host + r;        }   // switch at         r = "https://" + r;      } return r;  };   // REPOS.foundation

first; }( window.mediaWiki, window.jQuery ) );

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

/// EOF  templatedataHint/d.js