Content deleted Content added
-3.2 |
-3.3 |
||
Line 1:
/// User:PerfektesChaos/js/lintHint/d.js
// Show LintErrors analysis live
/// 2018-
// ResourceLoader: compatible;
// dependencies: user, mw.API, mediawiki.storage, mediawiki.util
Line 17:
( function ( mw, $ ) {
"use strict";
var Version = -3.
Signature = "lintHint",
HINT = { cmodels: { "wikitext": true,
Line 55:
using: [ "mediawiki.api",
"mediawiki.storage",
"mediawiki.util"
"user.options" ],
$body: false,
$page: false,
Line 83 ⟶ 84:
$table: false,
$top: false },
CODMIRROR = { cm: false },
EDIT = { listen: false,
live: false,
Line 109 ⟶ 111:
sub: "/r.js" },
REPOS = { },
WIKED = { };
Line 346 ⟶ 349:
// fair()
// mw.hook()
// (
// (LINTER.first)
// (features)
Line 379 ⟶ 382:
case "ExpandTemplates":
PREGO.fire();
fair(
break;
case "LintErrors":
Line 437 ⟶ 440:
}
}
// mw.hook( "CodeMirror.enabled" ).add( CODMIRROR.fire );
break;
} // switch wgAction
Line 798 ⟶ 802:
// > HINT.launched
// > EDIT.live
//
// API.full()
// mw.hook()
// (BOX.flip)
// 2018-05-20 PerfektesChaos@de.wikipedia
if ( HINT.launch && ! HINT.launched && ! EDIT.live ) {
API.full();
Line 933 ⟶ 937:
// >< BOX.$other
// mw.message()
//
// BOX.future()
// (BOX.find)
Line 946 ⟶ 950:
s = mw.message( s ).text();
} else {
if ( HINT.later ) {
s = e.type;
Line 1,253 ⟶ 1,257:
// > BOX.fgcRun
// > GUIDER.live
// >< API.errors
// >< API.single
// >< EDIT.live
// < HINT.launch
//
// EDIT.fire()
// API.full()
// 2018-
if ( HINT.live ) {
if ( BOX.$box ) {
Line 1,289 ⟶ 1,288:
}
if ( EDIT.live ) {
} else {
HINT.launch = true;
Line 1,356 ⟶ 1,332:
}
}; // BOX.future()
CODMIRROR.fetch = function () {
// Retrieve CodeMirror contents
// Postcondition:
// Returns contents, if present
// Uses:
// > CODMIRROR.cm
// 2018-07-06 PerfektesChaos@de.wikipedia
var r;
if ( CODMIRROR.first() ) {
r = CODMIRROR.cm.doc.getValue();
}
return r;
}; // CODMIRROR.fetch()
CODMIRROR.first = function () {
// Uses:
// > window.CodeMirror
// >< CODMIRROR.cm
// mw.user.options.get()
// 2018-07-06 PerfektesChaos@de.wikipedia
var r, uo;
if ( ! CODMIRROR.cm &&
typeof window.CodeMirror === "function" &&
typeof window.CodeMirror.doc === "object" ) {
CODMIRROR.cm = window.CodeMirror;
}
if ( CODMIRROR.cm ) {
uo = mw.user.options.get( "usecodemirror" );
if ( typeof uo === "number"
&& uo > 0 ) {
r = CODMIRROR.cm;
}
}
return r;
}; // CODMIRROR.first()
/*
CODMIRROR.fire = function ( app ) {
}; // CODMIRROR.fire()
*/
EDIT.fetch = function () {
// Retrieve HTML textarea contents
// Postcondition:
// Returns textarea contents, if present
// Uses:
// > HINT.source
// > HINT.$page
// >< EDIT.selector
// >< EDIT.$source
// < EDIT.listen
// < HINT.$textarea
// 2018-07-06 PerfektesChaos@de.wikipedia
var r;
if ( ! EDIT.$source ) {
if ( ! EDIT.selector ) {
switch ( HINT.source ) {
case "wikitext":
case "proofread-page":
EDIT.selector = "#wpTextbox1";
break;
} // switch HINT.source
}
if ( EDIT.selector ) {
EDIT.$source = HINT.$page.find( EDIT.selector );
if ( ! EDIT.$source.length ) {
EDIT.live = false;
}
} else {
EDIT.live = false;
}
}
if ( EDIT.live && EDIT.$source && EDIT.$source.length ) {
HINT.$textarea = EDIT.$source;
r = EDIT.$source.val();
}
return r;
}; // EDIT.fetch()
Line 1,374 ⟶ 1,437:
}
}; // EDIT.fine()
EDIT.fire = function () {
// Anaysis of source text area requested
// Uses:
// > TMPLXPAND.live
// CODMIRROR.fetch()
// WIKED.fetch()
// EDIT.fetch()
// API.fire()
// BOX.$collapsed.hide()
// 2018-07-06 PerfektesChaos@de.wikipedia
var source;
if ( ! TMPLXPAND.live ) {
source = CODMIRROR.fetch();
if ( ! source ) {
WIKED.fetch();
}
}
if ( ! source ) {
source = EDIT.fetch();
}
if ( source ) {
EDIT.listen = false;
API.fire( source );
} else {
BOX.$collapsed.hide();
}
}; // EDIT.fire()
Line 1,676 ⟶ 1,769:
// Uses:
// >< API.Api
//
// mw.Api.loadMessagesIfMissing()
// (GUIDER.form)
Line 1,687 ⟶ 1,780:
API.Api = new mw.Api();
}
for ( i = 0; i < HINT.errors.length; i++ ) {
req.push( "linter-category-" + HINT.errors[ i ] );
Line 1,967 ⟶ 2,060:
// > PREGO.maxage
// mw.loader.getState()
// mw.loader.state()
// REPOS.fire()
// 2018-
var s = "ext.gadget." + PREGO.signature;
if ( ! mw.loader.getState( s )
mw.loader.state( s, "loading" );
REPOS.fire( PREGO.site,
PREGO.store + PREGO.signature + PREGO.sub,
Line 2,194 ⟶ 2,289:
// Initialize ExpandTemplates
// Uses:
// > HINT.using
// < TMPLXPAND.live
// < HINT.live
// < EDIT.live
// < EDIT.selector
// (TMPLXPAND.further)
// 2018-07-06 PerfektesChaos@de.wikipedia
TMPLXPAND.live = true;
HINT.live = true;
EDIT.live = true;
EDIT.selector = "#output";
mw.loader.using( HINT.using, TMPLXPAND.further );
}; // TMPLXPAND.first()
TMPLXPAND.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 );
}; // TMPLXPAND.first()
UPDATE.feed = function ( apply ) {
// Memorize unknown category
// Uses:
// ><
//
// 2018-05-20 PerfektesChaos@de.wikipedia
if ( typeof
}
if ( typeof
}
if ( $.inArray( apply, HINT.errors ) < 0 ) {
HINT.errors.push( apply );
}
}; //
// Consider memorized categories
// Precondition:
Line 2,222 ⟶ 2,349:
// > Signature
// >< HINT.errors
// <
//
// 2018-05-20 PerfektesChaos@de.wikipedia
var storage = mw.storage.get( Signature ),
Line 2,234 ⟶ 2,361:
if ( typeof parsed.translations === "object"
&& parsed.translations ) {
}
if ( typeof parsed.unknown === "object"
Line 2,255 ⟶ 2,382:
} // for i
if ( unknown.length ) {
if ( typeof
} else {
}
}
if ( unknown.length !== parsed.unknown.length ) {
}
}
Line 2,268 ⟶ 2,395:
} catch (e) {
}
if ( typeof
}
}
}; //
// Update unknown categories memory
// Precondition:
Line 2,282 ⟶ 2,409:
// Uses:
// > Signature
// >
// 2018-05-20 PerfektesChaos@de.wikipedia
var storage;
if ( typeof
storage = JSON.stringify(
}
if ( storage ) {
Line 2,293 ⟶ 2,420:
mw.storage.remove( Signature );
}
}; //
//
// Uses:
// >
//
// 2018-07-06
&& window.wikEd ) ) &&
typeof window.wikEd.disabled === "boolean" &&
typeof window.wikEd.highlightSyntax === "boolean" &&
typeof window.wikEd.turnedOn === "boolean" &&
WIKED.wikEd = window.wikEd;
if ( WIKED.wikEd &&
! WIKED.wikEd.disabled &&
WIKED.wikEd.useWikEd &&
WIKED.wikEd.turnedOn &&
WIKED.wikEd.highlightSyntax ) {
WIKED.wikEd.UpdateTextarea();
}
}; // WIKED.fetch()
/*
WIKED.fire = function () {
var script = document.createElement('script');
script.src = '//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript';
script.async = true;
document.getElementsByTagName('head')[0].appendChild(script);
}; //
*/
|