Content deleted Content added
-4.7 |
-5.8 |
||
(9 intermediate revisions by the same user not shown) | |||
Line 1:
/// User:PerfektesChaos/js/lintHint/d.js
///
// Show LintErrors analysis live
// ResourceLoader: compatible;
// dependencies: user,
// /// Fingerprint: #0#0#
/// License: CC-by-sa/4.0
Line 12 ⟶ 13:
laxbreak:true,
nocomma:true, strict:true, undef:true, unused:true */
Line 17 ⟶ 19:
( function ( mw, $ ) {
"use strict";
var Version = -
Signature = "lintHint",
HINT = { cmodels: { "wikitext": true,
Line 23 ⟶ 25:
"proofread-page": true },
doc: "en:User:PerfektesChaos/js/" + Signature,
drop: false,
errors: [ "bogus-image-options",
"deletable-table-tag",
Line 28 ⟶ 31:
"html5-misnesting",
"ignored-table-attr",
"inline-media-caption",
"large-tables",
"misc-tidy-replacement-issues",
"misnested-tag",
Line 36 ⟶ 41:
"multiline-html-table-in-list",
"multiple-unclosed-formatting-tags",
"night-mode-unaware-background-color",
"obsolete-tag",
"pwrap-bug-workaround",
Line 54 ⟶ 60:
live: false,
ltr: true,
quiet: [ "large-tables",
"night-mode-unaware-background-color"
],
selMain: "[role='main']",
silent: false,
source: false,
spaces: false,
using: [ "mediawiki.api",
"mediawiki.storage",
Line 107 ⟶ 118:
"mediawiki.ui.input" ],
$pagename: false },
INFO = { },
LINTER = { live: false },
PREGO = { app: false,
Line 116 ⟶ 128:
// [ "layer", "boolean" ],
[ "lazy", "boolean" ],
[ "silent", "string" ],
[ "spaces", "string" ] ],
signature: "preferencesGadgetOptions",
Line 215 ⟶ 228:
+ " dove effettuare l’analisi."
+ " Usare - per la lista vuota"
+ " e * per indicarli tutti."},
"^^silent":{"en": "Suppress these error types"
+ " (space separated list),"
+ " or - for all shown or * for auto default",
"de": "Unterdrücke diese Fehlertypen"
+ " (Leerzeichen-getrennte Liste),"
+ " oder - für alle zeigen"
+ " oder * für Vorgabe"}
}; // HINT.texts
Line 247 ⟶ 267:
if ( mw.config.get( "skin" ) !== "minerva" ) { // T49858
if ( action ) {
mw.loader.using( [ "jquery.tablesorter" ],
action );
} else {
Line 271 ⟶ 291:
// < HINT.later
// < HINT.lazy
// < HINT.drop
// mw.loader.using()
// BOX.flat()
// (API.full)
// (BOX.feed)
//
var i, live, s;
if ( typeof apply === "object"
&& apply ) {
Line 330 ⟶ 351:
} else if ( HINT.live && ! live ) {
BOX.flat();
}
if ( typeof apply.quiet === "object"
&& apply.quiet &&
typeof apply.quiet.length === "number" ) {
HINT.drop = [ ];
for ( i = 0; i < apply.quiet.length; i++ ) {
s = apply.quiet[ i ];
if ( typeof s === "string" ) {
s = s.trim();
if ( s ) {
HINT.drop.push( s );
}
}
} // for i
if ( HINT.drop.length > 0 ) {
HINT.silent = HINT.drop.join( " " );
} else {
HINT.silent = "-";
}
}
}
Line 371 ⟶ 411:
// mw.hook()
// (TMPLXPAND.first)
// (INFO.first)
// (LINTER.first)
// (features)
//
var i, later, listen, live, re, rls, s;
HINT.signature = "ext.gadget." + Signature;
Line 406 ⟶ 447:
case "ExpandTemplates":
PREGO.fire();
EDIT.live = true;
EDIT.selector = "textarea#output";
fair( TMPLXPAND.first );
break;
case "Info":
$( INFO.first );
break;
case "LintErrors":
Line 449 ⟶ 495:
EDIT.layer = true;
EDIT.live = true;
EDIT.selector =
}
}
Line 471 ⟶ 517:
}
// mw.hook( "CodeMirror.enabled" ).add( CODMIRROR.fire );
break;
case "info":
$( INFO.first );
break;
} // switch wgAction
Line 558 ⟶ 607:
// arrived -- JSON result of ajax lint query
// Uses:
// >
// < API.scream
// < API.errors
// (BOX.fill)
// (BOX.flat)
//
var
API.scream = false;
API.errors = false;
if ( typeof arrived === "object"
&& arrived &&
typeof arrived.length === "number"
&& arrived.length ) {
if ( $.inArray( e.type, HINT.quiet ) < 0 ) {
API.errors.push( e );
}
} // for i
} else {
API.errors = arrived;
}
}
s = ( API.
mw.hook( "wikipage.content" ).add( BOX[
}; // API.fine()
Line 707 ⟶ 765:
// Uses:
// > HINT.ltr
// > BOX.$box
// 2018-09-25 PerfektesChaos@de.wikipedia
if ( $activate ) {
Line 866 ⟶ 924:
// Precondition:
// $area -- mw-content-text
// mediawiki.api
// Uses:
// > BOX.$collapsed
Line 970 ⟶ 1,028:
// > HINT.later
// > HINT.selector
// > Signature
// > BOX.bgcErr
// > HINT.$textarea
Line 982 ⟶ 1,041:
// mw.message()
// UPDATE.feed()
// mw.hook()
// BOX.future()
// (BOX.find)
// (BOX.future)
//
var n = 0,
e, i, k, loc, par, s, $e, $e2, $e3, $td, $tr;
for ( i = 0; i < API.errors.length; i++ ) {
e = API.errors[ i ];
Line 1,005 ⟶ 1,065:
$tr.addClass( HINT.selector + "-" + e.type );
$td = $( "<td>" );
$
$
target: Signature + "SP",
title: "Special:LintErrors/" + e.type } )
.text( s );
$td.append( $e )
.css( { "background-color": "#" + BOX.bgcErr } );
$tr.append( $td );
$td = $( "<td>" );
Line 1,068 ⟶ 1,133:
.data( "range", e.dsr )
.data( "sort-value", i )
.attr( { "data-beg": "" + e.dsr[ 0 ],
"data-end": "" + e.dsr[ 1 ],
"data-type": e.type } )
.text( String.fromCharCode( 160, 8595, 160 ) );
if ( typeof BOX.swift === "string" ) {
Line 1,073 ⟶ 1,141:
}
$tr.append( $td );
loc = true;
}
BOX.$tbody.append( $tr );
Line 1,087 ⟶ 1,156:
}
BOX.$table.show();
if ( loc ) {
mw.hook( Signature + ".table-range" ).fire( BOX.$table );
}
} else {
BOX.$table.hide();
Line 1,252 ⟶ 1,324:
// > HINT.launched
// > HINT.selector
// > BOX.fgc
// > HINT.ltr
Line 1,295 ⟶ 1,366:
// > Signature
// > Version
// > TMPLXPAND.live
// > EDIT.$source
// > EDIT.live
// > API.errors
Line 1,303 ⟶ 1,376:
// BOX.firing()
// BOX.focus()
// EDIT.fetch()
// EDIT.fine()
// (BOX.full)
// 2021-
BOX.first( $area );
face();
Line 1,330 ⟶ 1,404:
BOX.$collapsed.css( { "background-color": "#" + BOX.bgc } );
}
if (
EDIT.fetch();
}
if ( EDIT.live && ! API.errors && ! TMPLXPAND.live ) {
EDIT.fine();
}
Line 1,572 ⟶ 1,649:
// fair()
// PREGO.fire()
// 2021-
var dom;
BOX.first();
if ( EDIT.layer ) {
dom = mw.util.addPortletLink( "p-tb",
HINT.$widget = $( dom );
if ( dom.nodeName.toLowerCase() !== "li" ) {
Line 1,606 ⟶ 1,683:
// < EDIT.listen
// < HINT.$textarea
// 2021-
var r, $div;
if ( ! EDIT.$source ) {
Line 1,626 ⟶ 1,703:
}
EDIT.$source = $div.find( EDIT.selector );
if (
if ( EDIT.$source.find( ":hidden" ).length ) {
EDIT.live = false;
}
} else {
EDIT.live = false;
}
Line 2,040 ⟶ 2,121:
// Request messages
// Precondition:
// mediawiki.api
// Uses:
// >< API.Api
Line 2,253 ⟶ 2,334:
Signature );
}; // GUIDER.furnish()
INFO.fiat = function () {
// Link headline on Special:info or &action=info if not yet linked
// Precondition:
// mediawiki.util available
// Uses:
// > INFO.$h
// mw.config.get()
// mw.util.getUrl()
// 2022-02-07 PerfektesChaos@de.wikipedia
var s = mw.config.get( "wgRelevantPageName" ),
$a = $( "<a>" );
$a.attr( { href: mw.util.getUrl( "Special:LintErrors",
{ pagename: s } ) } )
.text( INFO.$h.text() );
INFO.$h.empty()
.append( $a );
}; // INFO.fiat()
INFO.first = function () {
// Seek linter statistics headline on Special:info or &action=info
// Precondition:
// DOM ready
// Uses:
// < INFO.$h
// mw.loader.using()
// (INFO.fiat)
// 2022-02-07 PerfektesChaos@de.wikipedia
INFO.$h = $( "#mw-pageinfo-linter" );
if ( INFO.$h.length &&
! INFO.$h.find( "a" ).length ) {
mw.loader.using( [ "mediawiki.util" ],
INFO.fiat );
}
}; // INFO.first()
Line 2,267 ⟶ 2,387:
// > HINT.using
// > PREGO.live
// > HINT.drop
// >< HINT.spaces
// >< HINT.live
// >< LINTER.live
// >< HINT.silent
// < HINT.quiet
// mw.hook()
// PREGO.form()
Line 2,274 ⟶ 2,398:
// mw.loader.using()
// (BOX.feed)
//
var i, n, s, v, vals;
if ( typeof applied === "object"
Line 2,283 ⟶ 2,407:
s = v[ 0 ];
if ( typeof applied[ s ] === v[ 1 ] ) {
HINT[ s ]
}
} // for i
Line 2,296 ⟶ 2,420:
}
if ( PREGO.live ) {
if ( ! HINT.drop ) {
HINT.silent = "*";
}
PREGO.form();
} else if ( LINTER.live ) {
Line 2,318 ⟶ 2,445:
}
if ( HINT.live && HINT.nsn >= 0 ) {
switch ( HINT.silent ) {
case false:
case "*":
break;
case "-":
HINT.quiet = false;
break;
default:
HINT.quiet = HINT.silent.split( " " );
} // switch HINT.silent
mw.loader.using( HINT.using, BOX.feed );
}
Line 2,355 ⟶ 2,493:
PREGO.
// Namespaces text input field has been
// Uses:
// > PREGO.$spaces
Line 2,397 ⟶ 2,535:
}
PREGO.$spaces.val( s );
}; // PREGO.
PREGO.
// Quiet text input field has been used
// Uses:
// > PREGO.$silent
// >< PREGO.reID
// 2023-05-14 PerfektesChaos@de.wikipedia
var s = PREGO.$silent.val(),
got, i, quiet, single;
if ( s.indexOf( "*" ) >= 0 ) {
s = "*";
} else {
got = s.trim().split( " " );
if ( got.length > 0 ) {
quiet = [ ];
if ( typeof PREGO.reID !== "object" ) {
PREGO.reID = new RegExp( "^[a-z][a-z-]*[a-z]$" );
}
for ( i = 0; i < got.length; i++ ) {
single = got[ i ];
if ( PREGO.reID.test( single ) &&
$.inArray( single, quiet ) < 0 ) {
quiet.push( single );
} else if ( single === "-" ) {
quiet = [ ];
break; // for i
}
} // for i
if ( quiet.length > 0 ) {
s = quiet.join( " " );
} else {
s = "-";
}
} else {
s = "*";
}
}
PREGO.$silent.val( s );
}; // PREGO.fiat2()
PREGO.field1 = function ( $applying ) {
// Namespaces text input field has been generated
// Precondition:
Line 2,407 ⟶ 2,586:
// Uses:
// < PREGO.$spaces
//
// 2023-05-14 PerfektesChaos@de.wikipedia
PREGO.$spaces = $applying;
PREGO.$spaces.change( PREGO.
}; // PREGO.
PREGO.field2 = function ( $applying ) {
// Quiet text input field has been generated
// Precondition:
// $applying -- jQuery object of text input field
// Uses:
// < PREGO.$spaces
// (PREGO.fiat2)
// 2023-05-14 PerfektesChaos@de.wikipedia
PREGO.$silent = $applying;
PREGO.$silent.change( PREGO.fiat2 );
}; // PREGO.field2()
Line 2,442 ⟶ 2,636:
// > Signature
// mw.hook()
// (PREGO.
//
// 2023-05-14 PerfektesChaos@de.wikipedia
var support = ".wikipedia.org/wiki/" + HINT.doc.substr( 3 ),
docs = { "en": "//en" + support,
Line 2,453 ⟶ 2,648:
val: ( HINT.spaces ? HINT.spaces
: "" ),
field: PREGO.
{ signature: "launch",
type: "checkbox",
Line 2,465 ⟶ 2,660:
type: "checkbox",
show: HINT.texts[ "^^lazy" ],
val: HINT.lazy },
/*
,
Line 2,471 ⟶ 2,666:
type: "checkbox",
show: HINT.texts[ "^^layer" ],
val: HINT.layer },
*/
{ signature: "silent",
type: "text",
show: HINT.texts[ "^^silent" ],
val: ( HINT.silent ? HINT.silent
: "*" ),
field: PREGO.field2 }
];
dialog = { script: Signature,
Line 2,598 ⟶ 2,799:
// 2018-05-20 PerfektesChaos@de.wikipedia
mw.hook( "wikipage.content" ).add( BOX.flip );
}; // TMPLXPAND.
Line 2,739 ⟶ 2,940:
document.getElementsByTagName('head')[0].appendChild(script);
}; // WIKED.fire()
|