Content deleted Content added
-2.83 |
-5.8 |
||
(27 intermediate revisions by the same user not shown) | |||
Line 1:
/// User:PerfektesChaos/js/lintHint/d.js
/// 2024-07-04 PerfektesChaos@de.wikipedia
// Show LintErrors analysis live
// ResourceLoader: compatible;
// dependencies: user,
// mediawiki.API, mediawiki.storage, mediawiki.util
/// Fingerprint: #0#0#
/// License: CC-by-sa/4.0
/// <nowiki>
/* global window: false */
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 42 ⟶ 48:
"tidy-font-bug",
"tidy-whitespace-bug",
"unclosed-quotes-in-heading"
"wikilink-in-extlink" ],
idRev: 0,
indicators:".mw-indicators",
last: true,
later: false,
Line 52 ⟶ 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.
"mediawiki.util"
"user.options" ],
$body: false,
$
$
$textarea: false,
$widget: false },
API = { Api: false,
errors: false,
Line 83 ⟶ 100:
$table: false,
$top: false },
EDIT = { layer:
source:
$source: false },
GUIDER = { last: false,
live: false,
reTrim: false,
suitable: String.fromCharCode( 0x2714 ),
using: [ "jquery.textSelection",
"mediawiki.ui.button",
"mediawiki.ui.input" ],
$pagename: false },
INFO = { },
LINTER = { live: false },
PREGO = { app: false,
live: false,
maxage: 604813,
pars: [ [ "last", "boolean" ],
[ "later", "boolean" ],
[ "launch", "boolean" ],
[ "lazy", "boolean" ],
[ "silent", "string" ],
[ "spaces", "string" ] ],
signature: "preferencesGadgetOptions",
Line 107 ⟶ 135:
sub: "/r.js" },
REPOS = { },
UPDATE = { },
WIKED = { };
HINT.texts = {
//
"desc": {"en": "Show LintErrors analysis live.",
"de": "Zeige LintErrors-Analyse live.",
Line 169 ⟶ 199:
+ " piuttosto che avviandola manualmente "
+ " tramite bottone."},
/*
"^^layer": {"en": "Convert all source edit links on"
+ " LintErrors special page"
Line 180 ⟶ 211:
+ " nello"
+ " strumento di modifica ParserMigration."},
*/
"^^lazy": {"en": "Suppress small label if no error detected.",
"de": "Unterdrücke das kleine grüne Feld,"
Line 196 ⟶ 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 223 ⟶ 262:
// Uses:
// >< HINT.using
// mw.config.get()
// mw.loader.using()
// 2017-08-07 PerfektesChaos@de.wikipedia
if ( mw.config.get( "skin" ) !== "minerva" ) { // T49858
if ( action ) {
mw.loader.using( [ "jquery.tablesorter" ],
action );
} else {
Line 251 ⟶ 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 283 ⟶ 324:
HINT.launch = apply.launch;
}
/*
if ( typeof apply.layer === "boolean" ) {
HINT.layer = apply.layer;
}
*/
if ( typeof apply.lazy === "boolean" ) {
HINT.lazy = apply.lazy;
Line 308 ⟶ 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 321 ⟶ 383:
// > LINTER.first
// > HINT.cmodels
// > EDIT.sourceVE
// > EDIT.selTextbox
// > HINT.doc
// > Version
// >< HINT.using
// < HINT.signature
// < HINT.selector
// < HINT.nsn
// < PREGO.live
Line 332 ⟶ 397:
// < HINT.last
// < HINT.live
// < HINT.launch
// < EDIT.live
// < EDIT.layer
// < EDIT.selector
// < HINT.pub
// mw.loader.getState()
// mw.loader.state()
// mw.config.get()
// GUIDER.first()
// PREGO.fire()
// fair()
// mw.loader.using()
// mw.hook()
// (TMPLXPAND.first)
// (INFO.first)
// (LINTER.first)
// (features)
//
var i, later, listen, live, re, rls, s;
HINT.signature = "ext.gadget." + Signature;
if ( mw.loader.getState( HINT.signature ) !== "ready" ) {
rls[ HINT.signature ] = "ready";
mw.loader.state( rls );
HINT.selector = Signature.toLowerCase();
switch ( mw.config.get( "wgAction" ) ) {
case "view":
Line 362 ⟶ 435:
switch ( s.substr( i + 1 ) ) {
case Signature:
GUIDER.first();
listen = true;
Line 372 ⟶ 444:
} // switch subPage
}
break;
case "ExpandTemplates":
PREGO.fire();
EDIT.live = true;
EDIT.selector = "textarea#output";
fair( TMPLXPAND.first );
break;
case "Info":
$( INFO.first );
break;
case "LintErrors":
Line 407 ⟶ 488:
HINT.live = false;
}
} else if ( s.indexOf( "&lintid=" ) > 0 ) {
HINT.launch = true;
}
if ( s.indexOf( EDIT.sourceVE ) > 0 ) {
later = true;
EDIT.layer = true;
EDIT.live = true;
EDIT.selector = EDIT.selTextbox;
}
}
Line 416 ⟶ 505:
case "edit":
case "submit":
EDIT.live = true;
HINT.nsn = mw.config.get( "wgNamespaceNumber" );
Line 427 ⟶ 516:
}
}
// mw.hook( "CodeMirror.enabled" ).add( CODMIRROR.fire );
break;
case "info":
$( INFO.first );
break;
} // switch wgAction
Line 440 ⟶ 533:
}
if ( live ) {
fair();
PREGO.fire();
}
}
HINT.pub = { doc: "[[" + HINT.doc + "]]",
Line 480 ⟶ 576:
API.scream = textStatus;
break;
} // switch typeof textStatus
}
if ( errorThrown ) {
Line 511 ⟶ 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 576 ⟶ 681:
API.first = function () {
// Initialize API
// Uses:
// >< API.Api
// >< API.site
// 2017-08-01 PerfektesChaos@de.wikipedia
Line 598 ⟶ 705:
// Uses:
// > API.server
// >< API.single
// >< HINT.idRev
// >< API.page
// >< API.solver
// >< API.reSpace
// < HINT.launched
// API.first()
// (API.fine)
// (API.fault)
//
var idRev = actual,
subject = access
f */;
HINT.launched = true;
if ( typeof subject === "string" ) {
Line 629 ⟶ 737:
jqXHR.setRequestHeader( "Content-Type",
"application/json" );
}; */
API.page = { /* beforeSend: f, */
dataType: "json" // No "Intelligent Guess"
};
API.solver = API.site + API.server + API.swift + "/";
}
if ( typeof API.reSpace !== "object" ) {
API.reSpace = new RegExp( " +", "g" );
}
subject = subject.replace( API.reSpace, "_" );
}
API.page.url = API.solver + encodeURIComponent( subject );
if ( idRev ) {
Line 653 ⟶ 765:
// Uses:
// > HINT.ltr
// > BOX.$box
// 2018-
if ( $activate ) {
$activate.css( { "
"float": ( HINT.ltr ? "right": "left" ) } );
BOX.$box.append( $activate );
}
Line 669 ⟶ 782:
// Uses:
// > HINT.live
// > HINT.ltr
// > BOX.bgc
Line 676 ⟶ 788:
// > GUIDER.live
// > PREGO.signature
// > HINT.selector
// > Signature
// > Version
// >< BOX.$box
//
// face()
// BOX.focus()
// BOX.flat()
// BOX.firing()
// (BOX.flip)
// (BOX.facet)
//
var $a, $e;
if ( HINT.live ) {
if ( BOX.$box ) {
if ( BOX.$failure ) {
Line 710 ⟶ 825:
.css( { "float": ( HINT.ltr ? "left": "right" ) } );
BOX.$box.append( $e )
.
.attr( { id: HINT.selector,
role: "alert" } )
.css( { "background-color": "#" + BOX.bgc,
"border-color": "#" + BOX.boc,
Line 717 ⟶ 834:
"color": "#" + BOX.fgc,
"margin-bottom": "1em",
"padding": "0.5em"
"pointer-events": "all" } );
$e = $( "<button>" );
$e.click( BOX.flip )
.css( { "color": "#FF0000",
"
"
"float": ( HINT.ltr ? "right": "left" ),
"font-weight": "bolder",
"pointer-events": "all" } )
.css( "margin-" + ( HINT.ltr ? "right": "left" ),
"6px" )
Line 736 ⟶ 857:
BOX.flat();
}
BOX.firing( Version, false );
}; // BOX.factory()
Line 748 ⟶ 870:
// > BOX.$box
// > BOX.$table
// >< BOX.$failure
// < API.scream
// BOX.flat()
// BOX.factory()
//
// 2021-06-03 PerfektesChaos@de.wikipedia
BOX.flat();
BOX.factory( $area );
Line 770 ⟶ 892:
.show();
}
}; // BOX.fault()
Line 783 ⟶ 903:
// > HINT.launched
// > EDIT.live
// < API.errors
// UPDATE.fetch()
// API.full()
// mw.hook()
// (BOX.flip)
//
UPDATE.fetch();
if ( HINT.launch && ! HINT.launched && ! EDIT.live ) {
API.full();
} else {
API.errors = true;
mw.hook( "wikipage.content" ).add( BOX.flip );
}
Line 800 ⟶ 924:
// Precondition:
// $area -- mw-content-text
// mediawiki.api
// Uses:
// > BOX.$collapsed
// >
// > BOX.$box
// > HINT.$textarea
Line 810 ⟶ 934:
// > HINT.nsn
// > PREGO.signature
// > HINT.selector
// >< BOX.$table
// >< BOX.$tbody
// >< BOX.swift
// >< API.Api
// >< BOX.$pagename
// BOX.factory()
// mw.hook()
// BOX.filler()
// mw.Api.loadMessagesIfMissing()
// GUIDER.
// (BOX.flag)
// (BOX.filler)
// (API.fault)
//
var i, req, $th, $thead, $tr;
BOX.factory( $area );
if ( BOX.$collapsed && ! HINT.$widget ) {
BOX.$collapsed.hide();
}
if ( BOX.$box ) {
Line 871 ⟶ 993:
$thead.append( $tr );
BOX.$tbody = $( "<tbody>" );
BOX.$table.addClass( "wikitable
.attr( { id: HINT.selector + "-table" } )
.append( $thead, BOX.$tbody )
.css( { "clear": "both"
"overflow": "scroll" } );
if ( HINT.errors.length > 1 || HINT.nsn < 0 ) {
BOX.$table.addClass( "sortable" );
Line 889 ⟶ 1,013:
.fail( API.fault );
}
}
}; // BOX.fill()
Line 905 ⟶ 1,027:
// > mw.messages
// > HINT.later
// > HINT.selector
// > Signature
// > BOX.bgcErr
// > HINT.$textarea
Line 916 ⟶ 1,040:
// >< BOX.$other
// mw.message()
//
// 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 929 ⟶ 1,054:
s = mw.message( s ).text();
} else {
if ( HINT.later ) {
s = e.type;
Line 938 ⟶ 1,063:
if ( s ) {
$tr = $( "<tr>" );
$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 960 ⟶ 1,091:
if ( typeof par.name === "string" ) {
$td.text( par.name );
} else if ( typeof par.subtype === "string" ) {
$td.text( par.subtype );
} else if ( typeof par.root === "string" &&
typeof par.child === "string" ) {
Line 975 ⟶ 1,108:
typeof par.items.length === "number" ) {
for ( k = 0; k < par.items.length; k++ ) {
$e =
} else
$e = $( "<code>" );
$e.css( { "margin-right": "6px",
"white-space": "nowrap" } );
}
$e.text( s );
$td.append( $e );
} // for k
Line 992 ⟶ 1,130:
$td = $( "<td>" );
$td.click( BOX.find )
.css( { "background-color": "#FFFFFF" } )
.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 999 ⟶ 1,141:
}
$tr.append( $td );
loc = true;
}
BOX.$tbody.append( $tr );
Line 1,013 ⟶ 1,156:
}
BOX.$table.show();
if ( loc ) {
mw.hook( Signature + ".table-range" ).fire( BOX.$table );
}
} else {
BOX.$table.hide();
Line 1,043 ⟶ 1,189:
end: range[ 1 ] } );
}; // BOX.find()
BOX.fine = function () {
// Analysis without errors
// Uses:
// > BOX.$collapsed
// > API.errors
// > HINT.selector
// > BOX.bgcOk
// BOX.firing()
// 2021-06-03 PerfektesChaos@de.wikipedia
if ( BOX.$collapsed && ! API.errors ) {
BOX.firing( "+" );
BOX.$collapsed.addClass( HINT.selector + "-fine" )
.css( { "background-color": "#" + BOX.bgcOk } );
}
}; // BOX.fine()
BOX.firing = function ( about, active, attach ) {
// Manage pivot button
// Precondition:
// about -- tooltip text
// active -- true, if enabled after call
// attach -- cursor style, or not
// Uses:
// > BOX.$collapsed
// > BOX.bgcRun
// > BOX.fgcRun
// > BOX.fgc
// > HINT.selector
// (BOX.full)
// 2021-06-03 PerfektesChaos@de.wikipedia
var signal;
if ( BOX.$collapsed ) {
if ( active ) {
BOX.$collapsed.click( BOX.full )
.css( { "color": "#" + BOX.fgc } );
signal = "pointer";
} else {
BOX.$collapsed.css( { "background-color": "#" + BOX.bgcRun,
"color": "#" + BOX.fgcRun
} )
.off( "click", BOX.full );
signal = "default";
}
BOX.$collapsed.attr( { "aria-disabled": ! active,
"title": about } )
.css( { "cursor": attach || signal } )
.removeClass( [ HINT.selector + "-fine",
HINT.selector + "-progress" ] )
.show();
}
}; // BOX.firing()
BOX.first = function ( $area ) {
// Detect main section of page
// Precondition:
// $area -- mw-content-text, or nil
// Uses:
// > HINT.selMain
// > EDIT.selVEsrc
// >< HINT.$main
// >< EDIT.layer
// < HINT.$content
// < EDIT.live
// 2021-06-03 PerfektesChaos@de.wikipedia
var $main, $top;
if ( $area ) {
HINT.$content = $area;
}
if ( ! HINT.$main ) {
$top = $( HINT.selMain );
switch ( $top.length ) {
case 0:
if ( $area ) {
HINT.$main = HINT.$content;
}
break;
case 1:
$main = $top;
break;
default:
$main = $top.eq( 0 );
} // switch $top.length
if ( $main ) {
HINT.$main = $main.children().eq( 0 );
if ( EDIT.layer &&
! $main.find( EDIT.selVEsrc ).length ) {
EDIT.layer = false;
EDIT.live = false;
}
}
}
}; // BOX.first()
Line 1,071 ⟶ 1,316:
// alive -- leave BOX.$collapsed
// Uses:
// > BOX.$box
// > EDIT.live
// > API.errors
// > API.scream
Line 1,081 ⟶ 1,323:
// > API.single
// > HINT.launched
// >
// > BOX.fgc
// > HINT.ltr
//
//
//
// BOX.flip()
//
// 2021-06-03
if ( BOX.$box ) {
BOX.$box.hide();
}
if (
BOX.
} else {
BOX.fine();
}
if ( EDIT.live ) {
Line 1,108 ⟶ 1,345:
BOX.flip();
}
} else if ( ! API.errors &&
! API.scream && HINT.live }
}; // BOX.flat()
Line 1,151 ⟶ 1,360:
// $area -- mw-content-text, or nil
// Uses:
// > GUIDER.live
// > HINT.selector
// > HINT.ltr
// > BOX.bgc
// >
// > Version
// > TMPLXPAND.live
// > EDIT.$source
// > EDIT.live
// > API.errors
// > GUIDER.$pagename
// >< BOX.$collapsed
// BOX.first()
// face()
// BOX.
// BOX.focus()
// EDIT.fetch()
// EDIT.fine()
// (BOX.full)
//
face();
BOX.flat( $area, true );
if (
if ( BOX.$collapsed
} else {
BOX.$collapsed = $( "<
BOX.$collapsed.
.
.css( {
"padding-right": "2px",
"pointer-events": "all" } )
.text( Signature );
BOX.focus( BOX.$collapsed, true, true );
}
BOX.
BOX.$collapsed.css( { "background-color": "#" + BOX.bgc } );
}
if ( TMPLXPAND.live && ! EDIT.$source ) {
EDIT.fetch();
}
if ( EDIT.live && ! API.errors && ! TMPLXPAND.live ) {
EDIT.fine();
}
Line 1,202 ⟶ 1,417:
BOX.focus = function ( $apply, another, around ) {
// Insertion in page top region or toolbox
// Precondition:
// $apply -- jQuery object
// another -- try to add to indicators region
// around -- button style in page
// Uses:
// >
// > HINT.
// > HINT.$main
// >< HINT.$widget
// >< BOX.$top
//
var learn, light, s, $e;
if
HINT.$widget = $(
switch ( HINT.$widget.length )
case 1:
break;
default:
HINT.$widget = HINT.$widget.eq( 0 );
} // switch HINT.$widget.length
learn = true;
}
if ( HINT.$widget ) {
$apply.css( { "display": "inline-block",
"line-height": "1.2em",
"margin-left": "3px",
"margin-right": "3px",
"padding": "1px" } );
HINT.$widget.append( $apply );
light = true;
} else {
$apply.css( { "float": ( HINT.ltr ? "right"
: "left" ) } );
}
}
if ( ! light ) {
if ( ! BOX.$top ) {
BOX.$top = $( "<div>" );
BOX.$top.addClass( "noprint "
+ HINT.selector + "-top" )
.attr( { id: HINT.selector + "-top" } )
.css( { "clear": "both",
"width": "100%" } );
$e = $( "<div>" );
$e.css( { "clear": "both" } );
HINT.$main.before( BOX.$top, $e );
learn = true;
}
if ( around ) {
s = "#E0E0E0 #E0E0E0 #707070 #707070";
} else {
s = "transparent";
}
$apply.css( { "border-color": s,
"border-style": "solid",
"border-width": "2px",
"margin-bottom": "3px" } );
BOX.$top.prepend( $apply );
}
if ( learn &&
window.document.___location.hash ) {
window.document.___location = window.document.___location.href;
}
}; // BOX.focus()
Line 1,231 ⟶ 1,496:
// > HINT.live
// > BOX.$box
// > HINT.$widget
// > BOX.$collapsed
// >
// > GUIDER.live
// >
// >< API.errors
// >< API.single
// >< EDIT.live
// < HINT.launch
//
// EDIT.fire()
// API.full()
//
// 2021-06-03 PerfektesChaos@de.wikipedia
var idRev;
if ( HINT.live ) {
if ( BOX.$box ) {
if ( EDIT.live ) {
API.errors = false;
} else if ( HINT.$widget ) {
BOX.
}
if ( API.errors ) {
Line 1,260 ⟶ 1,524:
}
}
if ( ! GUIDER.live ) {
if ( ! API.single ) {
API.single = mw.config.get(
}
if (
}
}
if ( EDIT.live ) {
} else {
HINT.launch = true;
API.full( API.single, idRev );
BOX.firing( "?", false, "progress" );
}
} else if ( HINT.$widget ) {
BOX.
}
}; // BOX.full()
Line 1,309 ⟶ 1,554:
// Uses:
// > HINT.texts.other
// >
// > BOX.$box
// >< PREGO.app
// < BOX.$other
// PREGO.app.translation()
//
var $e;
if ( application ) {
Line 1,327 ⟶ 1,572:
.html( PREGO.app.translation( HINT.texts.other ) );
BOX.$other = $( "<div>" );
BOX.$other.
.attr( { id: HINT.selector + "-future" } )
.css( { "clear": "both",
"padding-bottom": "1em",
Line 1,335 ⟶ 1,581:
}
}; // 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 () {
// Check whether CodeMirror is activated
// Postcondition:
// Returns something, if present
// 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.fading = function () {
// Add link to toolbox portlet
// Precondition:
// mediawiki.util available
// Postcondition:
// Toolbox prepared and execution started
// Uses:
// > Signature
// > EDIT.layer
// > HINT.selector
// < HINT.$widget
// BOX.first()
// mw.util.addPortletLink()
// fair()
// PREGO.fire()
// 2021-11-04 PerfektesChaos@de.wikipedia
var dom;
BOX.first();
if ( EDIT.layer ) {
dom = mw.util.addPortletLink( "p-tb",
"#",
Signature,
HINT.selector + "-portlet",
Version );
HINT.$widget = $( dom );
if ( dom.nodeName.toLowerCase() !== "li" ) {
HINT.$widget = HINT.$widget.parent();
}
HINT.$widget.empty();
}
fair();
PREGO.fire();
}; // EDIT.fading()
EDIT.fetch = function () {
// Retrieve HTML textarea contents
// Postcondition:
// Returns textarea contents, if present
// Uses:
// > EDIT.selTextbox
// > HINT.source
// > HINT.$main
// > HINT.$content
// >< EDIT.selector
// >< EDIT.$source
// < EDIT.listen
// < HINT.$textarea
// 2021-12-23 PerfektesChaos@de.wikipedia
var r, $div;
if ( ! EDIT.$source ) {
if ( EDIT.layer ) {
EDIT.selector = EDIT.selTextbox;
} else if ( ! EDIT.selector ) {
switch ( HINT.source ) {
case "wikitext":
case "proofread-page":
EDIT.selector = "#wpTextbox1";
break;
} // switch HINT.source
}
if ( EDIT.selector ) {
if ( EDIT.layer ) {
$div = HINT.$main;
} else {
$div = HINT.$content;
}
EDIT.$source = $div.find( EDIT.selector );
if ( EDIT.$source.length ) {
if ( EDIT.$source.find( ":hidden" ).length ) {
EDIT.live = false;
}
} else {
EDIT.live = false;
}
} else {
EDIT.live = false;
}
}
if ( EDIT.live && EDIT.$source && EDIT.$source.length ) {
if ( EDIT.layer ) {
r = EDIT.$source.text();
} else {
HINT.$textarea = EDIT.$source;
r = EDIT.$source.val();
}
}
return r;
}; // EDIT.fetch()
Line 1,342 ⟶ 1,731:
// Uses:
// > EDIT.$source
// < EDIT.listen
// BOX.fine()
// (EDIT.focus)
//
if ( EDIT.$source ) {
EDIT.listen = true;
EDIT.$source.focusin( EDIT.focus );
}
BOX.fine();
}; // EDIT.fine()
EDIT.fire = function () {
// Anaysis of source text area requested
// Uses:
// > TMPLXPAND.live
// CODMIRROR.fetch()
// WIKED.fetch()
// EDIT.fetch()
// API.fire()
// 2021-06-03 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 );
}
}; // EDIT.fire()
Line 1,359 ⟶ 1,774:
// Source area has been touched
// Uses:
// > Version
// > BOX.bgc
// > BOX.$collapsed
// >< EDIT.listen
//
// 2021-06-03 PerfektesChaos@de.wikipedia
if ( EDIT.listen ) {
BOX.firing( Version, true );
BOX.$collapsed.css( { "background-color": "#" + BOX.bgc } );
EDIT.listen = false;
Line 1,412 ⟶ 1,830:
// < LINTER.subst
// (LINTER.further)
//
var $table = $area.find( ".mw-datatable, .TablePager" );
if ( $table.length ) {
if ( typeof $table.tablesorter === "function" ) {
$table.tablesorter();
}
/*
if ( typeof HINT.layer === "boolean" ) {
if ( HINT.layer ) {
Line 1,434 ⟶ 1,853:
$table.find( "a" ).each( LINTER.further );
}
*/
}
}; // LINTER.form()
Line 1,439 ⟶ 1,859:
/*
LINTER.further = function ( any, a ) {
// Divert LintErrors page link
Line 1,455 ⟶ 1,876:
}
}; // LINTER.further()
*/
Line 1,508 ⟶ 1,930:
// > GUIDER.$input
// > GUIDER.$rev
// > GUIDER.$startPage
// < GUIDER.last
// < API.single
// GUIDER.fired()
// API.full()
//
var s = GUIDER.$input.val().trim();
GUIDER.$input.val( s );
Line 1,521 ⟶ 1,944:
API.full( s, GUIDER.$rev.val() );
}
GUIDER.$startPage.css( { "cursor": "progress" } );
}; // GUIDER.find()
GUIDER.fine = function ( action ) {
// Precondition:
// action -- boolean, or Event object
// Pretty result of analysis
// Uses:
// > GUIDER.live
// > GUIDER.$pagename
// > GUIDER.$okay
// > GUIDER.$textarea
// > BOX.bgcOk
// > GUIDER.$input
// > GUIDER.$startText
// > GUIDER.$startPage
// (GUIDER.fine)
// 2021-06-03 PerfektesChaos@de.wikipedia
var lapsus, $e;
if ( GUIDER.live ) {
lapsus = ( action !== true );
if ( ( ! API.single || lapsus )
&& GUIDER.$pagename ) {
GUIDER.$pagename.hide();
}
if ( lapsus ) {
GUIDER.$okay.hide();
GUIDER.$textarea.css( { "background-color": "transparent" } )
.off( "focusin", GUIDER.fine );
GUIDER.$input.off( "focusin", GUIDER.fine );
} else {
if ( API.single ) {
$e = GUIDER.$pagename.children();
if ( ! $e.length ) {
$e = $( "<a>" );
$e.attr( { target: "_blank" } );
GUIDER.$pagename.append( $e );
}
$e.attr( { href: mw.util.getUrl( API.single ) } )
.text( API.single );
GUIDER.$pagename.show();
} else {
GUIDER.$okay.show();
GUIDER.$textarea.css( { "background-color":
"#" + BOX.bgcOk } )
.focusin( GUIDER.fine );
GUIDER.$input.focusin( GUIDER.fine );
}
}
GUIDER.$startText.css( { "cursor": "pointer" } );
GUIDER.$startPage.css( { "cursor": "pointer" } );
}
}; // GUIDER.fine()
Line 1,533 ⟶ 2,010:
// > HINT.texts.howTo
// > GUIDER.$desc
// > HINT.$
// > HINT.texts.___domain
// > Signature
Line 1,539 ⟶ 2,016:
// < PREGO.app
// PREGO.app.translation()
//
var $e = $( "<div>" );
PREGO.app = application;
Line 1,546 ⟶ 2,023:
"margin-top": "8em" } )
.html( PREGO.app.translation( HINT.texts.howTo ) );
HINT.$
$e = $( "<a>" );
$e.attr( { href: "https://"
Line 1,566 ⟶ 2,043:
// > GUIDER.$textarea
// > GUIDER.reTrim
// > GUIDER.$startText
// < GUIDER.last
// < API.single
Line 1,571 ⟶ 2,049:
// GUIDER.fired()
// API.fire()
//
var s = GUIDER.$textarea.val();
GUIDER.fired();
Line 1,580 ⟶ 2,058:
HINT.launched = true;
}
GUIDER.$startText.css( { "cursor": "progress" } );
}; // GUIDER.fire()
Line 1,629 ⟶ 2,108:
// Uses:
// > BOX.$box
//
// 2021-06-03
if ( BOX.$box ) {
BOX.$box.hide();
}
}; // GUIDER.flat()
Line 1,652 ⟶ 2,121:
// Request messages
// Precondition:
// mediawiki.api
// Uses:
// >< API.Api
// UPDATE.fetch()
// mw.Api.loadMessagesIfMissing()
// (GUIDER.form)
// (API.fault)
//
var req = [ "general-form-reset",
"go" ],
Line 1,665 ⟶ 2,135:
API.Api = new mw.Api();
}
UPDATE.fetch();
for ( i = 0; i < HINT.errors.length; i++ ) {
req.push( "linter-category-" + HINT.errors[ i ] );
Line 1,681 ⟶ 2,152:
// Uses:
// > GUIDER.$formText
// > GUIDER.suitable
// > GUIDER.$formPage
// > HINT.ltr
// > PREGO.signature
// < GUIDER.$startText
// < GUIDER.$okay
// < GUIDER.$startPage
// mw.hook()
// (GUIDER.fire)
Line 1,690 ⟶ 2,165:
// (GUIDER.filled)
// (GUIDER.finish)
//
var submit = mw.message( "go" ).text(),
$div = $( "<div>" ),
$x = $( "<span>" )
$b;
$x.css( { "color": "#FF0000",
"font-weight": "bolder" } )
.text( "X" );
GUIDER.$startText.addClass( "mw-ui-button mw-ui-progressive" )
.
GUIDER.$formText.append( GUIDER.$startText );
GUIDER.$okay = $( "<span>" );
GUIDER.$okay.css( { "background-color": "#" + BOX.bgcOk,
"margin-left": "1em",
"margin-right": "1em",
"padding": "0.2em 0.5em" } )
.hide()
.text( GUIDER.suitable );
GUIDER.$formText.append( GUIDER.$okay );
$b = $( "<input>" );
$b.addClass( "mw-ui-button" )
Line 1,708 ⟶ 2,192:
.attr( { type: "reset" } )
.click( GUIDER.flat )
.css( { "display": "block",
"float": ( HINT.ltr ? "right": "left" ) } ); GUIDER.$formText.append( $b );
$div.css( { "clear": "both" } );
Line 1,720 ⟶ 2,205:
.css( { "float": ( HINT.ltr ? "right": "left" ) } );
GUIDER.$formPage.append( $b );
GUIDER.$
GUIDER.$
.click( GUIDER.find )
.css( { "color": "#FFFFFF" } )
.text( submit );
GUIDER.$formPage.append( GUIDER.$
mw.hook( PREGO.signature + ".ready" ).add( GUIDER.finish );
}; // GUIDER.form()
Line 1,770 ⟶ 2,228:
// > HINT.using
// > PREGO.signature
// >
// < HINT.$content
// < GUIDER.$doc
// < GUIDER.$desc
Line 1,786 ⟶ 2,245:
// (GUIDER.foreign)
// (GUIDER.facet)
//
var $v = $( "head" ),
$e = $v.find( "title" );
Line 1,793 ⟶ 2,252:
$e.text( Signature );
$v.prepend( $e );
HINT.$
HINT.$
face();
$v = HINT.$body.find( "#firstHeading,#section_0" );
Line 1,815 ⟶ 2,274:
.text( String.fromCharCode( 160 ) );
$v.append( $v, GUIDER.$desc );
HINT.$
GUIDER.$formText = $( "<form>" );
GUIDER.$textarea = $( "<textarea>" );
GUIDER.$textarea.addClass( "mw-ui-input" )
.attr( { name: "wikitext" } )
.css( { "
"
"max-width": "100%"
"width": "100%" } );
GUIDER.$formText.append( GUIDER.$textarea );
GUIDER.$formPage = $( "<form>" );
Line 1,856 ⟶ 2,316:
.mouseup( GUIDER.figure );
GUIDER.$formPage.append( GUIDER.$rev );
HINT.$
GUIDER.$pagename = $( "<div>" );
GUIDER.$pagename.
HINT.selector + "-fine" ] )
.attr( { id: HINT.selector + "-pagename" } )
.css( { "background-color": "#" + BOX.bgcOk,
"float": ( HINT.ltr ? "left"
: "right" ),
"margin-bottom": "1em",
"padding": "4px"
"pointer-events": "all" } )
.hide();
HINT.$
HINT.$textarea = GUIDER.$textarea;
mw.loader.using( HINT.using, GUIDER.foreign );
Line 1,871 ⟶ 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 1,880 ⟶ 2,382:
// Uses:
// > PREGO.pars
// > PREGO.signature
// > Signature
// > HINT.nsn
// > HINT.using
// > PREGO.live
// > HINT.drop
// >< HINT.spaces
// >< HINT.live
// >< LINTER.live
// >< HINT.silent
// < HINT.quiet
// mw.hook()
// PREGO.form()
// LINTER.first()
// mw.loader.using()
// (BOX.feed)
//
var i, n, s, v, vals;
if ( typeof applied === "object"
Line 1,898 ⟶ 2,407:
s = v[ 0 ];
if ( typeof applied[ s ] === v[ 1 ] ) {
HINT[ s ]
}
} // for i
if ( typeof applied.layer === "boolean" ) {
delete applied.layer;
mw.hook( PREGO.signature + ".forward" ).fire( Signature,
applied );
}
}
if ( HINT.spaces ) {
Line 1,906 ⟶ 2,420:
}
if ( PREGO.live ) {
if ( ! HINT.drop ) {
HINT.silent = "*";
}
PREGO.form();
} else if ( LINTER.live ) {
Line 1,928 ⟶ 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 1,942 ⟶ 2,470:
// > PREGO.store
// > PREGO.sub
// > PREGO.maxage
// mw.loader.getState()
// mw.loader.state()
// REPOS.fire()
// 2018-
var
rls;
if ( ! mw.loader.getState( sign ) ) {
rls = { };
rls[ sign ] = "loading";
mw.loader.state( rls );
REPOS.fire( PREGO.site,
PREGO.store + PREGO.signature + PREGO.sub,
Line 1,953 ⟶ 2,487:
ctype: "text/javascript",
bcache: 1,
maxage:
}
}; // PREGO.feed()
Line 1,959 ⟶ 2,493:
PREGO.
// Namespaces text input field has been
// Uses:
// > PREGO.$spaces
// ><
// ><
// ><
// 2018-05-02 PerfektesChaos@de.wikipedia
var s = PREGO.$spaces.val(),
Line 2,001 ⟶ 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:
// $applying -- jQuery object of text input field
// 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()
PREGO.fire = function () {
// User options
// Uses:
// > PREGO.signature
Line 2,044 ⟶ 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,055 ⟶ 2,648:
val: ( HINT.spaces ? HINT.spaces
: "" ),
field: PREGO.
{ signature: "launch",
type: "checkbox",
Line 2,068 ⟶ 2,661:
show: HINT.texts[ "^^lazy" ],
val: HINT.lazy },
/*
,
{ signature: "layer",
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,
support: docs,
suffix: HINT.texts[ "^suffix" ],
Line 2,170 ⟶ 2,771:
// 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.further()
UPDATE.feed = function ( apply ) {
// Memorize unknown category
// Uses:
// ><
//
// 2018-
if ( typeof
}
if ( typeof UPDATE.o.unknown !== "object" ) {
UPDATE.o.unknown = [ ];
}
if ( $.inArray( apply, HINT.errors ) < 0 ) {
HINT.errors.push( apply );
UPDATE.o.unknown.push( apply );
}
};
// Consider memorized categories
// Precondition:
// mediawiki.storage available
// Uses:
// > Signature
// >< HINT.errors
// <
//
// 2018-
var
i, k, parsed, s, unknown;
if ( typeof storage === "string" ) {
try {
if ( typeof
if ( typeof parsed.translations
UPDATE.o = {
}
if ( typeof parsed. typeof
&&
for ( i = 0;
s = parsed.unknown[ i
if ( typeof s === "string" ) {
s = s.trim();
if ( s ) {
k = $.inArray( s, HINT.errors );
if ( k < 0 ) {
HINT.errors.push( s );
}
}
} //
if ( unknown.length )
if ( typeof
} else {
UPDATE.o = { unknown: unknown };
}
}
if ( unknown.length !== parsed.unknown.length ) {
UPDATE.flush();
}
}
}
} catch (e) {
}
if ( typeof UPDATE.o !== "object" ) {
UPDATE.flush();
}
}
}; //
// Update unknown categories memory
// Precondition:
// mediawiki.storage available
// Uses:
// > Signature
// >
// 2018-
var
if ( typeof
}
mw.storage.set( Signature, storage );
} else {
mw.storage.remove( Signature );
}
}; // UPDATE.flush()
WIKED.fetch = function () {
// Update text area from wikEd contents
// Uses:
// > window.wikEd
// >< WIKED.wikEd
// 2018-07-06 PerfektesChaos@de.wikipedia
if ( ! WIKED.wikEd &&
( typeof window.wikEd === "function" ||
( typeof window.wikEd === "object"
&& window.wikEd ) ) &&
typeof window.wikEd.disabled === "boolean" &&
typeof window.wikEd.highlightSyntax === "boolean" &&
typeof window.wikEd.turnedOn === "boolean" &&
typeof window.wikEd.useWikEd === "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);
}; // WIKED.fire()
*/
|