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

Content deleted Content added
-2.81
-2.82
Line 1:
/// User:PerfektesChaos/js/lintHint/d.js
// Show LintErrors analysis live
/// 2018-05-0708 PerfektesChaos@de.wikipedia
// ResourceLoader: compatible;
// dependencies: user, mw.API
Line 17:
( function ( mw, $ ) {
"use strict";
var Version = -2.8182,
Signature = "lintHint",
HINT = { cmodels: { "wikitext": true,
Line 112:
 
HINT.texts = {
// 20172018-1005-0608 PerfektesChaos@de.wikipedia
"desc": {"en": "Show LintErrors analysis live.",
"de": "Zeige LintErrors-Analyse live."},
"it": "Mostra analisi degli errori di Lint"
+ " in diretta."},
"___domain": {"en": "en.wikipedia.org",
"de": "de.wikipedia.org"},
Line 125 ⟶ 127:
+ " oder einen Seitennamen in das untere"
+ " (ggf. gefolgt von einer Versionsnummer),"
+ " und betätige die jeweilige Schaltfläche."},
"it": "Inserisci il wikitesto"
+ " nella prima area di input e premi"
+ " il tasto di invio adiacente,"
+ " oppure scrivi il titolo della pagina"
+ " nel secondo campo"
+ " (potrebbe essere seguito"
+ " dall’ID della revisione)."},
"mark": {"en": "select problem in source text",
"de": "Problem im Quelltext selektieren"},
"it": "Seleziona un problema nel testo sorgente"},
"noPage": {"en": "Wikitext page not found",
"de": "Wikitext-Seite nicht gefunden"},
"it": "Pagina di wikitesto non trovata"},
"other": {"en": "Future problems detected.",
"de": "Zukünftige Probleme detektiert."},
"it": "Futuri problemi individuati."},
"^suffix": {"en": "– linter error analysis support",
"de": "– Unterstützung"
+ " der Analyse von Linter-Fehlern"},
"it": "8211; Supporto"
+ " per l’analisi degli errori di Lint"},
"^^last": {"en": "Analyze previous revisions, too.",
"de": "Analysiere auch frühere Seitenversionen."},
"it": "Analizza anche le revisioni precedenti."},
/*
"^^later" {"en": "",
Line 148 ⟶ 163:
"de": "Löse die Analyse automatisch"
+ " beim Seitenbesuch in den Namensräumen aus,"
+ " statt sie manuell "
+ " über den angebotenen Knopf zu starten."},
"it": "Esegui automaticamente l’analisi"
+ " nei namespace all’accesso, "
+ " piuttosto che avviandola manualmente "
+ " tramite bottone."},
"^^layer": {"en": "Convert all source edit links on"
+ " LintErrors special page"
Line 155 ⟶ 174:
"de": "Wandle auf der LintErrors-Spezialseite"
+ " alle Verlinkungen zur Quelltextbearbeitung"
+ " in das Migrationswerkzeug um."},
"it": "Converti tutti i link di modifica sorgente"
+ " presenti"
+ " sulla pagina speciale Errori di Lint"
+ " nello"
+ " strumento di modifica ParserMigration."},
"^^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."},
"it": "Nascondi l’etichetta"
+ " in assenza di errori rilevati."},
"^^spaces":{"en": "Space separated list of namespace numbers,"
+ " for automatized analysis"
+ " or - for none or\xA0 * for all",
"de": "Namensraum-Nummern für automatische Analyse,"
+ " durch Leerzeichen getrennt,"
+ " oder - für keine oder\xA0 * für alle"},
"it": "Lista di namespace,"
+ " in formato numerico separati da spazi,"
+ " dove effettuare l’analisi."
+ " Usare - per la lista vuota"
+ " e * per indicarli tutti."}
}; // HINT.texts
 
Line 224 ⟶ 255:
// (API.full)
// (BOX.feed)
// 2018-05-0207 PerfektesChaos@de.wikipedia
var i, live;
if ( typeof apply === "object"
Line 232 ⟶ 263:
typeof apply.rooms.length === "number" ) {
live = false;
if ( HINT.nsn >= 0 ) {
for ( i = 0; i < apply.rooms.length; i++ ) {
if ( apply.rooms[ i ] === HINT.nsn ) {
live = true;
break; // for i
}
} // for i
}
} else if ( typeof apply.rooms === "string"
&& apply.rooms === "*" ) {
live = true( HINT.nsn >= 0 );
} else {
live = false;
Line 470 ⟶ 503:
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()
 
 
 
API.feed = function ( access ) {
// Intermediate retrieval of wikitext
// Precondition:
// access -- string, with title of particular page, or not
// mediawiki.api available
// Uses:
// > HINT.nsn
// >< API.Api
// >< HINT.idRev
// < API.single
// < HINT.launched
// mw.config.get()
// (API.feeder)
// (API.fault)
// 2017-08-03 PerfektesChaos@de.wikipedia
var w = { action: "query",
prop: "revisions" };
if ( typeof access === "string" ) {
API.single = access;
}
if ( HINT.nsn < 0 ) {
w.rvprop = "content|contentmodel";
} else {
w.rvprop = "content";
if ( ! HINT.idRev ) {
HINT.idRev = mw.config.get( "wgRevisionId" );
}
HINT.launched = true;
}
if ( HINT.idRev ) {
w.revids = HINT.idRev;
} else if ( API.single ) {
w.titles = API.single;
} else {
w = false;
}
if ( w ) {
if ( ! API.Api ) {
API.Api = new mw.Api();
}
API.Api.get( w ).done( API.feeder )
.fail( API.fault );
}
}; // API.feed()
 
 
 
API.feeder = function ( arrived ) {
// Intermediate expansion of wikitext
// Precondition:
// arrived -- JSON result of ajax content query
// mediawiki.api available
// Uses:
// > HINT.cmodels
// > API.single
// > API.Api
// > HINT.idRev
// > PREGO.app
// > HINT.texts.noPage
// API.fire()
// API.fault()
// (API.fed)
// (API.fault)
// 2018-02-07 PerfektesChaos@de.wikipedia
var id, q, s, w;
if ( typeof arrived === "object" &&
typeof arrived.query === "object" &&
typeof arrived.query.pages === "object" ) {
q = arrived.query.pages;
for ( id in q ) {
q = q[ id ];
if ( q && q.revisions ) {
q = q.revisions[ 0 ];
if ( typeof q.contentmodel !== "string" ||
typeof HINT.cmodels[ q.contentmodel ] === "boolean"
) {
s = q[ "*" ];
if ( /\{\{/.test( s ) ) {
w = { action: "expandtemplates",
prop: "wikitext|volatile",
text: s };
if ( API.single ) {
w.title = API.single;
}
if ( HINT.idRev ) {
w.revid = HINT.idRev;
}
if ( w ) {
API.Api.post( w ).done( API.fed )
.fail( API.fault );
}
} else {
API.fire( s );
}
}
}
break; // for id
} // for id in q
}
if ( ! s ) {
if ( PREGO.app ) {
s = PREGO.app.translation( HINT.texts.noPage );
} else {
s = HINT.texts.noPage.en;
}
if ( API.single ) {
s = s + " * " + API.single;
}
API.fault( null, "Missing", s );
}
}; // API.feeder()
*/
 
 
Line 1,608 ⟶ 1,509:
// > GUIDER.$rev
// < GUIDER.last
// < API.single
// GUIDER.fired()
// API.full()
// 2018-05-0207 PerfektesChaos@de.wikipedia
var s = GUIDER.$input.val().trim();
GUIDER.$input.val( s );
Line 1,616 ⟶ 1,518:
GUIDER.last = true;
if ( s ) {
API.single = s;
API.full( s, GUIDER.$rev.val() );
}
Line 1,942 ⟶ 1,845:
maxlength: 12,
name: "revision",
placeholder: "IDoldid",
size: 8,
type: "text" } )
Line 2,024 ⟶ 1,927:
HINT.live = true;
}
if ( HINT.live && HINT.nsn >= 0 ) {
mw.loader.using( HINT.using, BOX.feed );
}