User:PerfektesChaos/js/lintHint/d.js: Difference between revisions

Content deleted Content added
-2.15
-2.8
Line 1:
/// User:PerfektesChaos/js/lintHint/d.js
// Show LintErrors analysis live
/// 2018-0205-0802 PerfektesChaos@de.wikipedia
// ResourceLoader: compatible;
// dependencies: user, mw.API
Line 17:
( function ( mw, $ ) {
"use strict";
var Version = -2.158,
Signature = "lintHint",
HINT = { cmodels: { "wikitext": true,
Line 48:
launch: false,
launched: false,
layer: falsenull,
lazy: false,
live: false,
Line 62:
errors: false,
scream: false,
serviceserver: "transformapi/wikitextrest_v1/to/lint" },
scanner: "transform/wikitext/to/lint",
swift: "page/lint" },
BOX = { bgc: "FFFF00",
bgcErr: "FFE4E1",
Line 93 ⟶ 95:
LINTER = { },
PREGO = { app: false,
signaturelive: "preferencesGadgetOptions" } false,
pars: [ [ "last", "boolean" ],
[ "later", "boolean" ],
[ "launch", "boolean" ],
[ "layer", "boolean" ],
[ "lazy", "boolean" ],
[ "spaces", "string" ] ],
signature: "preferencesGadgetOptions",
site: "w:en",
store: "User:PerfektesChaos/js/",
sub: "/r.js" },
REPOS = { },
TEACH = { };
 
Line 100 ⟶ 113:
HINT.texts = {
// 2017-10-06 PerfektesChaos@de.wikipedia
"desc": {"en": "Show LintErrors analysis live.",
"de": "Zeige LintErrors-Analyse live."},
"___domain": {"en": "en.wikipedia.org",
"de": "de.wikipedia.org"},
"howTo": {"en": "Fill balanced wikitext into first input area"
+ " and press adjacent submit button,"
+ " or enter page name into second input field.",
"de": + "Füge ausgeglichenen(might be followed by revision WikitextID).",
+"de": "Füge in das obere Eingabefeldausgeglichenen ein,Wikitext"
+ " oder einen Seitennamen in das untereobere Eingabefeld ein,"
+ " undoder einen betätigeSeitennamen diein jeweiligedas Schaltfläche.untere"},
+ " (ggf. gefolgt von einer Versionsnummer),"
"mark": {"en": "select problem in source text",
"de": + "Problem imund betätige die Quelltextjeweilige selektierenSchaltfläche."},
"noPagemark": {"en": "Wikitextselect problem pagein notsource foundtext",
"de": "Wikitext-SeiteProblem im nichtQuelltext gefundenselektieren"},
"othernoPage": {"en": "FutureWikitext problemspage detected.not found",
"de": "ZukünftigeWikitext-Seite Problemenicht detektiert.gefunden"},
"other": {"en": "Future problems detected.",
"de": "Zukünftige Probleme detektiert."},
"^suffix": {"en": "– linter error analysis support",
"de": "– Unterstützung"
+ " der Analyse von Linter-Fehlern"},
"^^last": {"en": "Analyze previous revisions, too.",
"de": "Analysiere auch frühere Seitenversionen."},
/*
"^^later" {"en": "",
"de": "Zeige auch zukünftige Fehlertypen,"
+ " zu denen noch keine"
+ " Linter-Kategorien existieren."},
*/
"^^launch":{"en": "Run analysis automatically in namespaces"
+ " on visit"
+ " rather than manually triggered by button.",
"de": "Löse die Analyse automatisch"
+ " beim Seitenbesuch in den Namensräumen aus,"
+ " statt sie manuell "
+ " über den angebotenen Knopf zu starten."},
"^^layer": {"en": "Convert all source edit links on"
+ " LintErrors special page"
+ " into ParserMigration tool edit.",
"de": "Wandle auf der LintErrors-Spezialseite"
+ " alle Verlinkungen zur Quelltextbearbeitung"
+ " in das Migrationswerkzeug um."},
"^^lazy": {"en": "Suppress small label if no error detected.",
"de": "Unterdrücke das kleine grüne Feld,"
+ " falls bei einer Seitendarstellung"
+ " kein Problem gefunden wurde."},
"^^spaces":{"en": "Space separated list of namespace numbers,"
+ " for automatized analysis"
+ " or - or\xA0*",
"de": "Namensraum-Nummern für automatische Analyse,"
+ " durch Leerzeichen getrennt,"
+ " oder - oder\xA0*"}
}; // HINT.texts
 
Line 165 ⟶ 214:
// > HINT.last
// > HINT.launched
// > HINT.using
// >< HINT.launch
// >< HINT.layer
Line 172 ⟶ 222:
// mw.loader.using()
// BOX.flat()
// (API.feedfull)
// (BOX.feed)
// 20172018-1105-1102 PerfektesChaos@de.wikipedia
var i, live;
if ( typeof apply === "object"
Line 219 ⟶ 269:
HINT.live = true;
if ( HINT.launch && ! HINT.launched ) {
mw.loader.using( HINT.using, API.feedfull );
} else {
mw.loader.using( HINT.using, BOX.feed );
Line 235 ⟶ 285:
// Uses:
// > Signature
// > PREGO.signature
// > LINTER.first
// > HINT.cmodels
Line 242 ⟶ 293:
// < HINT.signature
// < HINT.nsn
// < PREGO.live
// < HINT.source
// < HINT.idRev
Line 251 ⟶ 303:
// mw.loader.state()
// mw.config.get()
// PREGO.fire()
// TEACH.fetch()
// GUIDER.first()
Line 256 ⟶ 309:
// mw.loader.using()
// mw.hook()
// PREGO.feed()
// (features)
// 2018-05-02 (BOXPerfektesChaos@de.feed)wikipedia
var i, listen, live, re, s;
// 2018-02-08 PerfektesChaos@de.wikipedia
var listen, live, re, s;
HINT.signature = "ext.gadget." + Signature;
if ( mw.loader.getState( HINT.signature ) !== "ready" ) {
Line 273 ⟶ 324:
case "Blankpage":
s = mw.config.get( "wgTitle" );
ifi (= s.indexOf( "/" + Signature ) > 0 ) {;
if ( i > 1 TEACH.fetch(); {
GUIDERswitch ( s.firstsubstr( i + 1 ) ); {
case Signature:
TEACH.fetch();
GUIDER.first();
listen = true;
break;
case PREGO.signature:
PREGO.live = true;
PREGO.fire();
break;
} // switch subPage
}
listen = true;
break;
case "LintErrors":
Line 294 ⟶ 354:
if ( typeof HINT.cmodels[ s ] === "boolean" ) {
HINT.source = s;
} // fall through
// fall through
default:
HINT.idRev = mw.config.get( "wgRevisionId" );
Line 342 ⟶ 401:
}
if ( listen ) {
if ( HINT.nsn === 0 ) {
HINT.live = true;
}
mw.hook( Signature + ".config" ).add( features );
}
if ( live ) {
PREGO.feed();
fair();
TEACH.fetch();
if ( HINTPREGO.live fire() {;
mw.loader.using( HINT.using, BOX.feed );
}
}
HINT.pub = { doc: "[[" + HINT.doc + "]]",
Line 414 ⟶ 467:
mw.hook( "wikipage.content" ).add( BOX.fault );
}; // API.fault()
 
 
 
/*
API.fed = function ( arrived ) {
// Postprocess page content after ajax expandtemplates request
// Precondition:
// arrived -- JSON result of ajax expandtemplates query
// Uses:
// API.fire()
// 2017-08-01 PerfektesChaos@de.wikipedia
if ( typeof arrived === "object" &&
typeof arrived.expandtemplates === "object" &&
typeof arrived.expandtemplates.wikitext === "string" ) {
API.fire( arrived.expandtemplates.wikitext );
}
}; // API.fed()
 
 
Line 528 ⟶ 598:
}
}; // API.feeder()
*/
 
 
 
API.fed = function ( arrived ) {
// Postprocess page content after ajax expandtemplates request
// Precondition:
// arrived -- JSON result of ajax expandtemplates query
// Uses:
// API.fire()
// 2017-08-01 PerfektesChaos@de.wikipedia
if ( typeof arrived === "object" &&
typeof arrived.expandtemplates === "object" &&
typeof arrived.expandtemplates.wikitext === "string" ) {
API.fire( arrived.expandtemplates.wikitext );
}
}; // API.fed()
 
 
Line 580 ⟶ 635:
// mediawiki.api available
// Uses:
// >< API.site
// > API.server
// > API.scanner
// >< API.query
// API.first()
// (API.fine)
// (API.fault)
// 20172018-0805-0102 PerfektesChaos@de.wikipedia
var local = ( typeof ask === "string" );
/* , f; */
Line 597 ⟶ 655:
dataType: "json" // No "Intelligent Guess"
};
API.site = window.___location.protocol + "//" +
window.___location.hostname + "/";
if ( local ) {
// API.site = API.site + "v3/" + API.servicefirst();
API.site = API.site + "api/rest_v1/" + API.service;
API.query.type = "POST";
API.query.url = API.site + API.server + API.scanner;
// API.site + "v3/" + API.scanner;
}
}
Line 612 ⟶ 668:
.fail( API.fault );
}; // API.fire()
 
 
 
API.first = function () {
// Uses:
// >< API.site
// 2017-08-01 PerfektesChaos@de.wikipedia
if ( ! API.Api ) {
API.Api = new mw.Api();
}
if ( typeof API.site !== "string" ) {
API.site = window.___location.protocol + "//" +
window.___location.hostname + "/";
}
}; // API.first()
 
 
 
API.full = function ( access, actual ) {
// Analyse wikitext per page name
// Precondition:
// access -- string, with title of particular page, or current
// actual -- number, of revID, or not
// mediawiki.api available
// Uses:
// > API.server
// > API.Api
// >< API.single
// >< HINT.idRev
// >< API.page
// >< API.solver
// < HINT.launched
// API.first()
// (API.fine)
// (API.fault)
// 2018-05-02 PerfektesChaos@de.wikipedia
var idRev = actual,
subject = access;
HINT.launched = true;
if ( typeof subject === "string" ) {
subject = subject.trim();
} else {
if ( ! API.single ) {
API.single = mw.config.get( "wgTitle" );
}
subject = API.single;
if ( ! HINT.idRev ) {
HINT.idRev = mw.config.get( "wgRevisionId" );
}
idRev = HINT.idRev;
}
if ( typeof API.page !== "object" ) {
API.first();
/*
f = function ( jqXHR ) {
jqXHR.setRequestHeader( "Content-Type",
"application/json" );
};
*/
API.page = { //beforeSend: f,
dataType: "json" // No "Intelligent Guess"
};
API.solver = API.site + API.server + API.swift + "/";
}
subject = subject.replace( / /g, "_" );
API.page.url = API.solver + encodeURIComponent( subject );
if ( idRev ) {
API.page.url = API.page.url + "/" + idRev;
}
$.ajax( API.page ).done( API.fine )
.fail( API.fault );
}; // API.full()
 
 
 
BOX.facet = function ( $activate ) {
// Button for PREGO options arrived
// Precondition:
// $activate -- jQuery object of PREGO special page button
// Uses:
// > HINT.ltr
// >
// 2018-05-02 PerfektesChaos@de.wikipedia
if ( $activate ) {
$activate.css( { "float": ( HINT.ltr ? "right": "left" ) } );
BOX.$box.append( $activate );
}
}; // BOX.facet()
 
 
Line 626 ⟶ 770:
// > BOX.boc
// > BOX.fgc
// > GUIDER.live
// > PREGO.signature
// > Signature
// >< BOX.$box
// < HINT.$page
Line 632 ⟶ 779:
// BOX.flat()
// (BOX.flip)
// 2017-08-08 PerfektesChaos@de (BOX.wikipediafacet)
// 2018-05-05 PerfektesChaos@de.wikipedia
var $a, $e;
if ( HINT.live ) {
Line 676 ⟶ 824:
BOX.$box.append( $e );
BOX.focus( BOX.$box );
if ( ! GUIDER.live ) {
mw.hook( PREGO.signature + ".$button" ).fire( BOX.facet,
Signature );
}
}
} else {
Line 726 ⟶ 878:
// > HINT.launch
// > HINT.launched
// API> EDIT.feed()live
// API.full()
// mw.hook()
// (BOX.flip)
// 20172018-0805-0302 PerfektesChaos@de.wikipedia
if ( HINT.launch && ! HINT.launched && ! EDIT.live ) {
API.feedfull();
} else {
mw.hook( "wikipage.content" ).add( BOX.flip );
Line 889 ⟶ 1,042:
if ( typeof e.params === "object" ) {
par = e.params;
/*
if ( Version < 0 ) {
for ( s in par ) {
Line 899 ⟶ 1,053:
} // for s in par
}
*/
if ( typeof par.name === "string" ) {
$td.text( par.name );
Line 1,185 ⟶ 1,340:
// < HINT.launch
// < HINT.$textarea
// API.feedfull()
// 2018-0105-2102 PerfektesChaos@de.wikipedia
var source;
if ( HINT.live ) {
Line 1,235 ⟶ 1,390:
} else {
HINT.launch = true;
API.feedfull( API.single );
}
} else {
Line 1,319 ⟶ 1,474:
// > HINT.layer
// < LINTER.reEdit
// < LINTER.seek
// < LINTER.subst
// (LINTER.further)
// 20172018-1105-1102 PerfektesChaos@de.wikipedia
var $table = $area.find( ".TablePager" );
if ( $table.length ) {
Line 1,326 ⟶ 1,483:
$table.tablesorter();
}
if ( typeof HINT.layer === "boolean" ) {
if ( HINT.layer ) {
LINTER.reEdit = new RegExp( "([?&]action=)" +
"edit" +
"(&.+)?$" );
LINTER.seek = "action=edit";
LINTER.subst = "$1parsermigration-edit$2";
} else {
LINTER.reEdit = new RegExp( "([?&]action=)" +
"parsermigration-edit" +
"(&.+)?$" );
LINTER.seek = "action=parsermigration-edit";
LINTER.subst = "$1edit$2";
}
$table.find( "a" ).each( LINTER.further );
}
Line 1,360 ⟶ 1,527:
// Uses:
// > LINTER.reEdit
// 2017-11-11 PerfektesChaos@de > LINTER.wikipediaseek
// > LINTER.subst
// 2018-05-02 PerfektesChaos@de.wikipedia
var $a = $( a ),
s = $a.attr( "href" );
if ( s.indexOf( "action=edit"LINTER.seek ) > 0 ) {
$a.attr( "href", s.replace( LINTER.reEdit, LINTER.subst ) );
s.replace( LINTER.reEdit,
"$1parsermigration-edit$2" ) );
}
}; // LINTER.further()
 
 
 
GUIDER.facet = function ( $activate ) {
// Button for PREGO options arrived
// Precondition:
// $activate -- jQuery object of PREGO special page button
// Uses:
// > HINT.ltr
// > GUIDER.$desc
// 2018-05-02 PerfektesChaos@de.wikipedia
if ( $activate ) {
$activate.css( { "float": ( HINT.ltr ? "right": "left" ),
"margin-top": "1em" } );
GUIDER.$desc.before( $activate );
}
}; // GUIDER.facet()
 
 
 
GUIDER.figure = function () {
// Revision number input value has been changed
// Uses:
// > GUIDER.$rev
// >< GUIDER.reNaN
// 2018-05-02 PerfektesChaos@de.wikipedia
var s = GUIDER.$rev.val().trim();
if ( ! GUIDER.reNaN ) {
GUIDER.reNaN = new RegExp( "[^0-9]", "g" );
}
s = s.replace( GUIDER.reNaN, "" );
GUIDER.$rev.val( s );
}; // GUIDER.figure()
 
 
 
GUIDER.filled = function () {
// Page name input value has been changed
// Uses:
// > GUIDER.$input
// > GUIDER.$rev
// 2018-05-02 PerfektesChaos@de.wikipedia
var s = GUIDER.$input.val().trim();
GUIDER.$rev.attr( { disabled: ( s ? false : true ) } );
}; // GUIDER.filled()
 
 
Line 1,376 ⟶ 1,588:
// Uses:
// > GUIDER.$input
// > GUIDER.reTrim$rev
// < GUIDER.last
// < API.single
// GUIDER.fired()
// API.feedfull()
// 20172018-1005-0602 PerfektesChaos@de.wikipedia
var s = GUIDER.$input.val().trim();
GUIDER.$input.val( s );
GUIDER.fired();
GUIDER.last = true;
if ( ! GUIDER.reTrim.test( s ) ) {
API.single =full( s, GUIDER.$rev.val() );
API.feed( API.single );
}
}; // GUIDER.find()
Line 1,455 ⟶ 1,666:
// Submit button has been clicked
// Uses:
// >< GUIDER.flat()reTrim
// GUIDER.flat()
// 2017-08-04 PerfektesChaos@de.wikipedia
GUIDER.flat();
Line 1,472 ⟶ 1,684:
// < HINT.live
// < GUIDER.live
// PREGO.feedfire()
// fair()
// mw.loader.load()
// mw.hook()
// (GUIDER.furnish)
// 20172018-0805-0802 PerfektesChaos@de.wikipedia
var i;
PREGO.feedfire();
for ( i = 0; i < GUIDER.using.length; i++ ) {
HINT.using.push( GUIDER.using[ i ] );
Line 1,553 ⟶ 1,765:
// mw.hook()
// (GUIDER.fire)
// (GUIDER.flat)
// (GUIDER.find)
// (GUIDER.filled)
// (GUIDER.finish)
// 2017-082018-05-02 PerfektesChaos@de.wikipedia
var submit = mw.message( "go" ).text(),
$b = $( "<span>" ),
Line 1,575 ⟶ 1,789:
.css( { "float": ( HINT.ltr ? "right": "left" ) } );
GUIDER.$formText.append( $b );
$bdiv.css( ={ $("clear": "<span>both" } );
GUIDER.$formPage.append( $div );
$b.addClass( "mw-ui-button mw-ui-progressive" )
.click( GUIDER.find )
.css( { "color": "#FFFFFF" },
{ "float": ( HINT.ltr ? "right": "left" ) } )
.text( submit );
$div.append( $b );
$b = $( "<input>" );
$b.addClass( "mw-ui-button" )
Line 1,587 ⟶ 1,796:
.attr( { type: "reset" } )
.click( GUIDER.flat )
.click( GUIDER.filled )
.css( { "float": ( HINT.ltr ? "right": "left" ) } );
GUIDER.$divformPage.append( $b );
$b = .css$( { "float<span>": ( HINT.ltr ? "right": "left" ) } );
$b.addClass( "mw-ui-button mw-ui-progressive" )
GUIDER.$formPage.append( $div );
.click( GUIDER.find )
.css( { "color": "#FFFFFF" } )
.text( submit );
GUIDER.$formPage.append( $b );
mw.hook( PREGO.signature + ".ready" ).add( GUIDER.finish );
}; // GUIDER.form()
Line 1,634 ⟶ 1,848:
// > BOX.bgcOk
// > HINT.using
// > PREGO.signature
// < HINT.$page
// < GUIDER.$doc
Line 1,641 ⟶ 1,856:
// < GUIDER.$formPage
// < GUIDER.$input
// < GUIDER.$rev
// < HINT.$textarea
// face()
// PREGO.foreign()
// mw.loader.using()
// mw.hook()
// (GUIDER.filled)
// (GUIDER.foreign)
// 2017-10-06 PerfektesChaos@de (GUIDER.wikipediafacet)
// 2018-05-02 PerfektesChaos@de.wikipedia
var $v = $( "head" ),
$e = $v.find( "title" );
Line 1,693 ⟶ 1,912:
size: 50,
type: "text" } )
.css( { "float": ( HINT.ltr ? "left": "right" ),
"width": "auto",
"max-width": "auto" } );
.keyup( GUIDER.filled )
.mouseup( GUIDER.filled );
GUIDER.$formPage.append( GUIDER.$input );
GUIDER.$rev = $( "<input>" );
GUIDER.$rev.addClass( "mw-ui-input" )
.attr( { disabled: true,
maxlength: 12,
name: "revision",
size: 8,
type: "text" } )
.css( { "display": "inline-block",
"margin-left": "1.5em",
"margin-right": "1.5em",
"width": "auto",
"max-width": "auto" } )
.keyup( GUIDER.figure )
.mouseup( GUIDER.figure );
GUIDER.$formPage.append( GUIDER.$rev );
HINT.$page.append( GUIDER.$formText, GUIDER.$formPage );
GUIDER.$pagename = $( "<div>" );
GUIDER.$pagename.attr( { id: Signature + "-pagename" } )
.css( { "background-color": "#" + BOX.bgcOk,
"float": ( HINT.ltr ? "left": "right" ),
"margin-bottom": : "1emright" ),
"paddingmargin-bottom": "4px1em" } ),
"padding": "4px" } )
.hide();
HINT.$page.prepend( GUIDER.$pagename );
HINT.$textarea = GUIDER.$textarea;
mw.loader.using( HINT.using, GUIDER.foreign );
mw.hook( PREGO.signature + ".$button" ).fire( GUIDER.foreign );facet,
Signature );
}; // GUIDER.furnish()
 
 
 
PREGO.features = function ( applied ) {
// User options available
// Precondition:
// applied -- object, may be null, with values
// Uses:
// > PREGO.pars
// > HINT.nsn
// > HINT.using
// > PREGO.live
// >< HINT.live
// mw.loader.using()
// (BOX.feed)
// 2018-05-02 PerfektesChaos@de.wikipedia
var i, n, s, v, vals;
if ( typeof applied === "object"
&& applied ) {
n = PREGO.pars.length;
for ( i = 0; i < n; i++ ) {
v = PREGO.pars[ i ];
s = v[ 0 ];
if ( typeof applied[ s ] === v[ 1 ] ) {
HINT[ s ] = applied[ s ];
}
} // for i
}
if ( HINT.spaces ) {
HINT.spaces = HINT.spaces.trim();
}
if ( PREGO.live ) {
PREGO.form();
} else {
if ( HINT.spaces ) {
if ( HINT.spaces === "*" ) {
HINT.live = true;
} else if ( HINT.spaces !== "-" ) {
vals = HINT.spaces.split( " " );
s = HINT.nsn + "";
for ( i = 0; i < vals.length; i++ ) {
if ( s === vals[ i ] ) {
HINT.live = true;
break; // for i
}
} // for i
}
} else if ( HINT.nsn === 0 ) {
HINT.live = true;
}
if ( HINT.live ) {
mw.loader.using( HINT.using, BOX.feed );
}
}
}; // PREGO.features()
 
 
Line 1,717 ⟶ 2,010:
// Uses:
// > PREGO.signature
// > PREGO.site
// > PREGO.store
// > PREGO.sub
// mw.loader.getState()
// mwREPOS.loader.loadfire()
// 20172018-0805-0802 PerfektesChaos@de.wikipedia
var s = "ext.gadget." + PREGO.signature;
if ( mw.loader.getState( s ) !== "ready" ) {
mwREPOS.loader.loadfire( "https://en.wikipediaPREGO.org"site,
PREGO.store + PREGO.signature + "/w/indexPREGO.php?title="sub,
+ "User:PerfektesChaos/js/"false,
{ + PREGO.signature +action: "/r.jsraw",
ctype: + "&bcache=1&maxage=604812text/javascript",
bcache: + "&action=raw"1,
maxage: 604814 + "&ctype=text/javascript"} );
}
}; // PREGO.feed()
 
 
 
PREGO.fiat = function () {
// Namespaces text input field has been generated
// Uses:
// > PREGO.$spaces
// >< REPOS.reNum
// >< REPOS.rooms
// >< REPOS.follow
// 2018-05-02 PerfektesChaos@de.wikipedia
var s = PREGO.$spaces.val(),
i, k, got, rooms;
if ( s.indexOf( "-" ) >= 0 ) {
s = "-";
} else if ( s.indexOf( "*" ) >= 0 ) {
s = "*";
} else {
got = s.trim().split( " " );
s = "";
if ( got.length > 0 ) {
if ( typeof PREGO.rooms !== "object" ) {
PREGO.follow = function ( a, b ) {
return ( a < b ? -1 : 1 );
};
PREGO.reNum = new RegExp( "^[0-9]+$" );
PREGO.rooms = mw.config.get( "wgFormattedNamespaces" );
}
rooms = [ ];
for ( i = 0; i < got.length; i++ ) {
if ( PREGO.reNum.test( got[ i ] ) ) {
k = parseInt( got[ i ], 10 );
if ( ( k === 0 || PREGO.rooms[ k ] ) &&
$.inArray( k, rooms ) < 0 ) {
rooms.push( k );
}
}
} // for i
if ( rooms.length > 0 ) {
rooms.sort( PREGO.follow );
s = rooms.join( " " );
}
}
}
PREGO.$spaces.val( s );
}; // PREGO.fiat()
 
 
 
PREGO.field = function ( $applying ) {
// Namespaces text input field has been generated
// Uses:
// < PREGO.$spaces
// 2018-05-02 PerfektesChaos@de.wikipedia
PREGO.$spaces = $applying;
PREGO.$spaces.change( PREGO.fiat );
}; // PREGO.field()
 
 
 
PREGO.fire = function () {
// User options available
// Uses:
// > PREGO.signature
// > Signature
// PREGO.feed()
// mw.hook()
// (PREGO.features)
// 2018-05-02 PerfektesChaos@de.wikipedia
PREGO.feed();
mw.hook( PREGO.signature + ".fetch" ).fire( Signature,
PREGO.features );
}; // PREGO.fire()
 
 
 
PREGO.form = function () {
// Equip Special:Gadgets page with entry and form
// Uses:
// > HINT.doc
// > HINT.texts
// > HINT.launch
// > HINT.last
// > HINT.lazy
// > HINT.layer
// > HINT.spaces
// > Signature
// mw.hook()
// (PREGO.fiat)
// 2018-05-02 PerfektesChaos@de.wikipedia
var support = ".wikipedia.org/wiki/" + HINT.doc.substr( 3 ),
docs = { "en": "//en" + support,
"de": "//de" + support },
dialog, opts;
opts = [ { signature: "spaces",
type: "text",
show: HINT.texts[ "^^spaces" ],
val: ( HINT.spaces ? HINT.spaces
: "" ),
field: PREGO.field },
{ signature: "launch",
type: "checkbox",
show: HINT.texts[ "^^launch" ],
val: HINT.launch },
{ signature: "last",
type: "checkbox",
show: HINT.texts[ "^^last" ],
val: HINT.last },
{ signature: "lazy",
type: "checkbox",
show: HINT.texts[ "^^lazy" ],
val: HINT.lazy },
{ signature: "layer",
type: "checkbox",
show: HINT.texts[ "^^layer" ],
val: HINT.layer }
];
dialog = { script: Signature,
//show: ,
support: docs,
suffix: HINT.texts[ "^suffix" ],
opts: opts };
mw.hook( PREGO.signature + ".form" ).fire( dialog );
}; // PREGO.form()
 
 
 
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()