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

Content deleted Content added
-3.0
-3.1
Line 1:
/// User:PerfektesChaos/js/lintHint/d.js
// Show LintErrors analysis live
/// 2018-05-0920 PerfektesChaos@de.wikipedia
// ResourceLoader: compatible;
// dependencies: user, mw.API, mediawiki.storage, mediawiki.util
/// Fingerprint: #0#0#
/// @license GPL [//www.mediawiki.org/w/COPYING] (+GFDL, LGPL, CC-BY-SA)
Line 17:
( function ( mw, $ ) {
"use strict";
var Version = -3.01,
Signature = "lintHint",
HINT = { cmodels: { "wikitext": true,
Line 55:
using: [ "mediawiki.api",
"mediawiki.api.messages",
"mediawiki.storage",
"mediawiki.util" ],
$body: false,
Line 85 ⟶ 86:
EDIT = { listen: false,
live: false,
source: false,
$source: false },
GUIDER = { last: false,
Line 96 ⟶ 98:
PREGO = { app: false,
live: false,
maxage: 604813,
pars: [ [ "last", "boolean" ],
[ "later", "boolean" ],
Line 107 ⟶ 110:
sub: "/r.js" },
REPOS = { },
TEACH = { };,
WIKITEXT = { live: false };
 
 
Line 223 ⟶ 227:
// Uses:
// >< HINT.using
// mw.config.get()
// mw.loader.using()
// 2017-08-07 PerfektesChaos@de.wikipedia
Line 332 ⟶ 337:
// < HINT.last
// < HINT.live
// < HINT.launch
// < EDIT.live
// < HINT.pub
Line 337 ⟶ 343:
// mw.loader.state()
// mw.config.get()
// GUIDER.first()
// PREGO.fire()
// TEACH.fetch()
// GUIDER.first()
// fair()
// mw.loader.using()
// mw.hook()
// (WIKITEXT.first)
// (LINTER.first)
// (features)
// 2018-05-0720 PerfektesChaos@de.wikipedia
var i, listen, live, re, s;
HINT.signature = "ext.gadget." + Signature;
Line 362 ⟶ 368:
switch ( s.substr( i + 1 ) ) {
case Signature:
TEACH.fetch();
GUIDER.first();
listen = true;
Line 372 ⟶ 377:
} // switch subPage
}
break;
case "ExpandTemplates":
PREGO.fire();
fair( WIKITEXT.first );
break;
case "LintErrors":
Line 407 ⟶ 416:
HINT.live = false;
}
} else if ( s.indexOf( "&lintid=" ) > 0 ) {
HINT.launch = true;
}
}
Line 441 ⟶ 452:
if ( live ) {
fair();
TEACH.fetch();
PREGO.fire();
}
Line 789 ⟶ 799:
// > HINT.launched
// > EDIT.live
// TEACH.fetch()
// API.full()
// mw.hook()
// (BOX.flip)
// 2018-05-0220 PerfektesChaos@de.wikipedia
TEACH.fetch();
if ( HINT.launch && ! HINT.launched && ! EDIT.live ) {
API.full();
Line 926 ⟶ 938:
// (BOX.find)
// (BOX.future)
// 2018-0205-0717 PerfektesChaos@de.wikipedia
var n = 0,
e, i, k, par, s, $e, $e2, $e3, $td, $tr;
Line 998 ⟶ 1,010:
$td = $( "<td>" );
$td.click( BOX.find )
.css( { "background-color": "#FFFFFF" } )
.data( "range", e.dsr )
.data( "sort-value", i )
Line 1,243 ⟶ 1,256:
// > HINT.source
// > HINT.$page
// > WIKITEXT.live
// >< API.errors
// >< API.single
// >< EDIT.live
// >< EDIT.source
// >< EDIT.$source
// < EDIT.listen
Line 1,251 ⟶ 1,266:
// < HINT.$textarea
// API.full()
// 2018-05-0720 PerfektesChaos@de.wikipedia
var source;
if ( HINT.live ) {
if ( BOX.$box ) {
Line 1,277 ⟶ 1,291:
if ( EDIT.live ) {
if ( ! EDIT.$source ) {
switchif ( HINT! EDIT.source ) {
caseswitch "wikitext":( HINT.source ) {
case "proofread-pagewikitext":
source =case "#wpTextbox1proofread-page";:
break EDIT.source = "#wpTextbox1";
} // switch HINT.source break;
if ( source )} { // switch HINT.source
EDIT.$source = HINT.$page.find( source );}
if ( ! EDIT.$source.length ) {
EDIT.$source = HINT.$page.find( EDIT.source );
if ( ! ( EDIT.$source.length || WIKITEXT.live ) ) {
BOX.$collapsed.hide();
EDIT.live = false;
Line 1,293 ⟶ 1,309:
}
}
if ( EDIT.live && EDIT.$source && EDIT.$source.length ) {
EDIT.listen = false;
API.fire( EDIT.$source.val() );
Line 1,661 ⟶ 1,677:
// Uses:
// >< API.Api
// TEACH.fetch()
// mw.Api.loadMessagesIfMissing()
// (GUIDER.form)
// (API.fault)
// 20172018-0805-0420 PerfektesChaos@de.wikipedia
var req = [ "general-form-reset",
"go" ],
Line 1,671 ⟶ 1,688:
API.Api = new mw.Api();
}
TEACH.fetch();
for ( i = 0; i < HINT.errors.length; i++ ) {
req.push( "linter-category-" + HINT.errors[ i ] );
Line 1,948 ⟶ 1,966:
// > PREGO.store
// > PREGO.sub
// > PREGO.maxage
// mw.loader.getState()
// REPOS.fire()
// 2018-05-0220 PerfektesChaos@de.wikipedia
var s = "ext.gadget." + PREGO.signature;
if ( mw.loader.getState( s ) !== "ready" ) {
Line 1,959 ⟶ 1,978:
ctype: "text/javascript",
bcache: 1,
maxage: 604813PREGO.maxage } );
}
}; // PREGO.feed()
Line 2,023 ⟶ 2,042:
 
PREGO.fire = function () {
// User options availablerequest
// Uses:
// > PREGO.signature
Line 2,181 ⟶ 2,200:
// >< TEACH.o
// TEACH.flush()
// 2018-0205-0820 PerfektesChaos@de.wikipedia
if ( typeof TEACH.o !== "object" ) {
TEACH.o = [{ ]};
}
if ( typeof TEACH.o.unknown !== "object" ) {
TEACH.o.unknown = [ ];
}
if ( $.inArray( apply, HINT.errors ) < 0 ) {
HINT.errors.push( apply );
TEACH.o.unknown.push( apply );
}
TEACH.o.push( apply );
TEACH.flush();
}; // TEACH.feed()
Line 2,193 ⟶ 2,218:
TEACH.fetch = function () {
// Consider memorized categories
// Precondition:
// mediawiki.storage available
// Uses:
// > Signature
Line 2,198 ⟶ 2,225:
// < TEACH.o
// TEACH.flush()
// 2018-0205-0820 PerfektesChaos@de.wikipedia
var got,storage i,= k,mw.storage.get( leave,Signature parsed), s, webLs;
i, k, parsed, s, unknown;
if ( typeof window.localStorage === "object" ) {
if ( typeof storage === "string" ) {
webLs = window.localStorage;
try {
if ( webLs && typeof webLs.getItem === "function" ) {
tryparsed {= JSON.parse( storage );
if ( typeof gotparsed = webLs.getItem(=== Signature );"object"
if ( got&& parsed ) {
if ( typeof parsed.translations = JSON.parse(=== got );"object"
if ( typeof&& parsed === "object"parsed.translations ) {
TEACH.o = { && translations: parsed.translations &&};
}
if ( typeof parsed.lengthunknown === "numberobject"
&& parsed.lengthunknown ) { &&
typeof TEACHparsed.ounknown.length === parsed; "number"
&& for ( i = 0; i < TEACHparsed.ounknown.length; i++ ) {
sunknown = TEACH.o[ i ];
for ( i = 0; ifi (< typeofparsed.unknown.length; s i++ === ) "string"{
s = parsed.unknown[ i && s ) {];
if ( typeof s === "string" ) {
s = s.trim();
if ( s ) {
k = $.inArray( s, HINT.errors );
if ( k < 0 ) {
HINT.errors.push( s );
} else { unknown.push( s );
s = false;
}
} else {
s = false;
}
if ( ! s ) {}
} // TEACH.o.splice(for i, 1 );
if ( unknown.length ) leave = true;{
if ( typeof }TEACH.o === "object" ) {
} //TEACH.o.unknown for= iunknown;
} else {
TEACH.o = { unknown: unknown };
}
}
if ( unknown.length !== parsed.unknown.length ) {
TEACH.flush();
}
}
if ( typeof TEACH.o !== "object" ) {
TEACH.o = [ ];
}
if ( got && ( leave || ! TEACH.o.length ) ) {
TEACH.flush();
}
} catch (e) {
}
} catch (e) {
}
if ( typeof TEACH.o !== "object" ) {
TEACH.flush();
}
}
Line 2,248 ⟶ 2,279:
TEACH.flush = function () {
// Update unknown categories memory
// Precondition:
// mediawiki.storage available
// Uses:
// > Signature
// > TEACH.o
// 2018-0205-0820 PerfektesChaos@de.wikipedia
var webLsstorage;
if ( typeof windowTEACH.localStorageo === "object" ) {
webLsstorage = windowJSON.localStoragestringify( TEACH.o );
if ( webLs &&}
if ( storage ) {
typeof webLs.removeItem === "function" &&
mw.storage.set( Signature, storage );
typeof webLs.setItem === "function" ) {
} tryelse {
if ( TEACHmw.ostorage.lengthremove( Signature ) {;
webLs.setItem( Signature,
JSON.stringify( TEACH.o ) );
} else {
webLs.removeItem( Signature );
}
} catch (e) {
}
}
}
}; // TEACH.flush()
 
 
 
WIKITEXT.first = function () {
// Initialize ExpandTemplates
// Uses:
// > HINT.using
// < WIKITEXT.live
// < HINT.live
// < EDIT.live
// < EDIT.source
// (WIKITEXT.further)
// 2018-05-20 PerfektesChaos@de.wikipedia
WIKITEXT.live = true;
HINT.live = true;
EDIT.live = true;
EDIT.source = "#output";
mw.loader.using( HINT.using, WIKITEXT.further );
}; // WIKITEXT.first()
 
 
 
WIKITEXT.further = function () {
// Prepare ExpandTemplates
// Precondition:
// Resources available
// Uses:
// mw.hook()
// (BOX.flip)
// 2018-05-20 PerfektesChaos@de.wikipedia
mw.hook( "wikipage.content" ).add( BOX.flip );
}; // WIKITEXT.first()