User:Jonesey95/js/lintHint/r.js

/// User:PerfektesChaos/js/lintHint/r.js /// 2019-04-27 PerfektesChaos@de.wikipedia /// Fingerprint:#0#71B8CDDF# /// License: CC-by-sa/4.0 /// (function(mw,$){ "use strict"; var Version=4.1,Signature="lintHint",HINT={cmodels:{"wikitext":true, "proofread-index":true, "proofread-page":true},doc:"en:User:PerfektesChaos/js/"+Signature,errors:["bogus-image-options","deletable-table-tag","fostered","html5-misnesting","ignored-table-attr","misc-tidy-replacement-issues","misnested-tag","missing-end-tag","missing-start-tag","mixed-content","multi-colon-escape","multiline-html-table-in-list","multiple-unclosed-formatting-tags","pwrap-bug-workaround","self-closed-tag","stripped-tag","tidy-font-bug","tidy-whitespace-bug","unclosed-quotes-in-heading","wikilink-in-extlink"],idRev:0,last:true,later:false,launch:false,launched:false,layer:null,lazy:false,live:false,ltr:true,source:false, using:["mediawiki.api","mediawiki.storage","mediawiki.util","user.options"],$body:false,$page:false,$textarea:false},API={Api:false,errors:false,scream:false,server:"api/rest_v1/",scanner:"transform/wikitext/to/lint",swift:"page/lint"},BOX={bgc:"FFFF00",bgcErr:"FFE4E1",bgcOk:"ADFF2F",bgcRun:"C0C0C0",boc:"808080",fgc:"000000",fgcRun:"A0A0A0",swift:false,$box:false,$collapsed:false,$failure:false,$null:false,$other:false,$pagename:false,$swift:false,$tbody:false,$table:false,$top:false},CODMIRROR={cm:false},EDIT={listen:false,live:false,source:false,$source:false},GUIDER={last:false,live:false,reTrim:false,using:["jquery.textSelection","mediawiki.ui.button","mediawiki.ui.input"],$pagename:false},LINTER={live:false},PREGO={app:false,live:false,maxage:604813,pars:"last","boolean"],["later","boolean"],["launch","boolean"],["lazy","boolean"],["spaces","string",signature:"preferencesGadgetOptions",site:"w:en",store:"User:PerfektesChaos/js/",sub:"/r.js"},REPOS={},TMPLXPAND={live:false},UPDATE={},WIKED={}; HINT.texts={ "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"}, "howTo":{"en":"Fill balanced wikitext into first input area and press adjacent submit button, or enter page name into second input field (might be followed by revision ID).", "de":"Füge ausgeglichenen Wikitext in das obere Eingabefeld ein, 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":"&#8211; linter error analysis support", "de":"&#8211; 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."}, "^^launch":{"en":"Run analysis automatically in namespaces on visit rather than manually triggered by button.", "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."}, "^^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 * for all", "de":"Namensraum-Nummern für automatische Analyse, durch Leerzeichen getrennt, oder - für keine oder * 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."} }; function face{ if(!HINT.$body){ HINT.$body=$("body"); HINT.ltr=($("html").attr("dir")!=="rtl");}} function fair(action){ if(mw.config.get("skin")!=="minerva"){ if(action){ mw.loader.using("jquery.tablesorter",action); }else{ HINT.using.push("jquery.tablesorter");}}} function features(apply){ var i,live; if(typeof apply==="object"&&apply){ if(typeof apply.rooms==="object"&&apply.rooms&&typeof apply.rooms.length==="number"){ live=false; if(HINT.nsn>=0){ for(i=0;i=0); }else{ live=false;} if(typeof apply.later==="boolean"){ HINT.later=apply.later;} if(typeof apply.launch==="boolean"){ HINT.launch=apply.launch;} if(typeof apply.lazy==="boolean"){ HINT.lazy=apply.lazy; if(HINT.lazy){ BOX.flat;}} if(live&&!HINT.last){ live=false; if(typeof apply.oldid==="boolean"&&apply.oldid){ live=true;}} if(live&&!HINT.live){ HINT.live=true; if(HINT.launch&&!HINT.launched){ mw.loader.using(HINT.using,API.full); }else{ mw.loader.using(HINT.using,BOX.feed);} }else if(HINT.live&&!live){ BOX.flat;}}} function first{ var i,listen,live,re,rls,s; HINT.signature="ext.gadget."+Signature; if(mw.loader.getState(HINT.signature)!=="ready"){ rls={}; rls[HINT.signature]="ready"; mw.loader.state(rls); switch(mw.config.get("wgAction")){ case "view": HINT.nsn=mw.config.get("wgNamespaceNumber"); switch(HINT.nsn){ case-1: s=mw.config.get("wgCanonicalSpecialPageName"); switch(s){ case "Blankpage": s=mw.config.get("wgTitle"); i=s.indexOf("/"); if(i>1){ switch(s.substr(i+1)){ case Signature: GUIDER.first; listen=true; break; case PREGO.signature: PREGO.live=true; PREGO.fire; break;}} break; case "ExpandTemplates": PREGO.fire; fair(TMPLXPAND.first); break; case "LintErrors": LINTER.live=true; PREGO.fire; fair(LINTER.first); break;} break; case 102: case 104: case 106: case 108: case 110: case 112: s=mw.config.get("wgPageContentModel"); if(typeof HINT.cmodels[s]==="boolean"){ HINT.source=s;} default: HINT.idRev=mw.config.get("wgRevisionId"); s=window.location.search; if(HINT.idRev<=0){ live=false; }else if(s){ re="\\b(diff|history|printable)="; re=new RegExp(re); live=!re.test(s); if(live){ if(s.indexOf("&oldid=")>0){ if(mw.config.get("wgCurRevisionId")!==HINT.idRev){ HINT.last=false; HINT.live=false;} }else if(s.indexOf("&lintid=")>0){ HINT.launch=true;}} }else{ live=true;}} break; case "edit": case "submit": case "parsermigration-edit": EDIT.live=true; HINT.nsn=mw.config.get("wgNamespaceNumber"); HINT.using.push("jquery.textSelection"); live=true; if(HINT.nsn>=100){ s=mw.config.get("wgPageContentModel"); if(s==="proofread-page"){ HINT.source=s;}} break;} if(live){ if(!HINT.source){ HINT.source=mw.config.get("wgPageContentModel"); live=(HINT.source==="wikitext");} listen=live;} if(listen){ mw.hook(Signature+".config").add(features);} if(live){ fair; PREGO.fire;} HINT.pub={doc:""+HINT.doc+"",type:Signature,vsn:Version}; mw.hook(Signature+".ready").fire(HINT.pub);}} API.fault=function(jqXHR,textStatus,errorThrown){ if(textStatus){ switch(typeof textStatus){ case "object": if(typeof textStatus.textStatus==="string"){ API.scream=textStatus.textStatus; }else{ API.scream="";} if(typeof textStatus.exception==="string"&&textStatus.exception){ API.scream=API.scream+" ("+textStatus.exception+")";} break; case "string": API.scream=textStatus; break;}} if(errorThrown){ if(API.scream){ API.scream=API.scream+" -- Error: ";} API.scream=API.scream+errorThrown;} if(!API.scream){ API.scream="???";} if(typeof window.console==="object"&&typeof window.console.log==="function"){ window.console.log(Signature+" * "+API.scream); if(typeof textStatus==="object"&&textStatus&&typeof window.console.dir==="function"){ window.console.dir(textStatus);}} API.errors=false; mw.hook("wikipage.content").add(BOX.fault); }; API.fine=function(arrived){ var start; if(typeof arrived==="object"&&arrived&&typeof arrived.length==="number"&&arrived.length){ API.errors=arrived; start="fill"; }else{ API.errors=false; start="flat";} API.scream=false; mw.hook("wikipage.content").add(BOX[start]); }; API.fire=function(ask){ var local=(typeof ask==="string"); if(typeof API.query!=="object"){ API.query={ dataType:"json" }; if(local){ API.first; API.query.type="POST"; API.query.url=API.site+API.server+API.scanner;}} if(local){ API.query.data={wikitext:ask};} $.ajax(API.query).done(API.fine).fail(API.fault); }; API.first=function{ if(!API.Api){ API.Api=new mw.Api;} if(typeof API.site!=="string"){ API.site=window.location.protocol+"//"+window.location.hostname+"/";} }; API.full=function(access,actual){ var idRev=actual,subject=access; HINT.launched=true; if(typeof subject==="string"){ subject=subject.trim; }else{ if(!API.single){ API.single=mw.config.get("wgPageName");} subject=API.single; if(!HINT.idRev){ HINT.idRev=mw.config.get("wgRevisionId");} idRev=HINT.idRev;} if(typeof API.page!=="object"){ API.first; API.page={ dataType:"json" }; API.solver=API.site+API.server+API.swift+"/";} if(subject.indexOf(" ")>0){ if(typeof API.reSpace!=="object"){ API.reSpace=new RegExp(" +","g");} subject=subject.replace(API.reSpace,"_");} API.page.url=API.solver+encodeURIComponent(subject); if(idRev){ API.page.url=API.page.url+"/"+idRev;} $.ajax(API.page).done(API.fine).fail(API.fault); }; BOX.facet=function($activate){ if($activate){ $activate.css({"display":"block", "float":(HINT.ltr?"right":"left")}); BOX.$box.append($activate);} }; BOX.factory=function($area){ var $a,$e; if(HINT.live){ HINT.$page=$area; if(BOX.$box){ if(BOX.$failure){ BOX.$failure.hide;} BOX.$box.show; }else{ face; BOX.$box=$(" "); $e=$(" "); if(HINT.nsn<0){ $a=$(" "); }else{ $a=$(""); $a.attr({href:"/wiki/Special:Blankpage/"+Signature,target:Signature});} $a.css({"font-weight":"bold", "font-size":"larger"}).text(Signature+"@PerfektesChaos"); $e.append($a).css({"float":(HINT.ltr?"left":"right")}); BOX.$box.append($e).attr({id:Signature}).css({"background-color":"#"+BOX.bgc, "border-color":"#"+BOX.boc, "border-style":"solid", "border-width":"1px", "color":"#"+BOX.fgc, "margin-bottom":"1em", "padding":"0.5em"}); $e=$(" "); $e.click(BOX.flip).css({"color":"#FF0000", "display":"block", "float":(HINT.ltr?"right":"left"), "font-weight":"bolder"}).css("margin-"+(HINT.ltr?"right":"left"), "6px").text("X"); BOX.$box.append($e); BOX.focus(BOX.$box); if(!GUIDER.live){ mw.hook(PREGO.signature+".$button").fire(BOX.facet,Signature);}} }else{ BOX.flat;} }; BOX.fault=function($area){ BOX.flat; BOX.factory($area); if(API.scream&&BOX.$box){ if(BOX.$table){ BOX.$table.hide;} if(!BOX.$failure){ BOX.$failure=$(" "); BOX.$failure.css({"clear":"both", "color":"#FF0000", "font-weight":"bold"}); BOX.$box.append(BOX.$failure);} BOX.$failure.text(API.scream).show;} if(GUIDER.$pagename){ GUIDER.$pagename.hide;} }; BOX.feed=function{ UPDATE.fetch; if(HINT.launch&&!HINT.launched&&!EDIT.live){ API.full; }else{ mw.hook("wikipage.content").add(BOX.flip);} }; BOX.fill=function($area){ var i,req,$th,$thead,$tr; BOX.factory($area); if(BOX.$collapsed){ BOX.$collapsed.hide;} if(BOX.$null){ BOX.$null.hide;} if(BOX.$box){ if(BOX.$table){ if(HINT.$textarea){ if(GUIDER.last){ BOX.$swift.hide; }else{ BOX.$swift.show;}} BOX.$tbody.empty; BOX.filler; }else{ BOX.$table=$(" "); $thead=$(" "); if(HINT.nsn<0){ BOX.$pagename=$(" "); BOX.$pagename.css({"font-weight":"normal", "white-space":"nowrap"}); BOX.$table.append(BOX.$pagename);} $tr=$(" "); $th=$(" "); $th.text("lint"); $tr.append($th); $th=$(" "); $th.text("+"); $tr.append($th); if(HINT.$textarea){ BOX.$swift=$(" "); BOX.$swift.data("sort-type","number").text("⇓"); mw.hook(PREGO.signature+".ready").add(BOX.flag); if(GUIDER.last){ BOX.$swift.hide;} $tr.append(BOX.$swift);} $thead.append($tr); BOX.$tbody=$(" "); BOX.$table.addClass("wikitable").attr({id:Signature+"-table"}) .append($thead,BOX.$tbody).css({"clear":"both"}); if(HINT.errors.length>1||HINT.nsn<0){ BOX.$table.addClass("sortable");} BOX.$box.append(BOX.$table); req=[]; for(i=0;i<HINT.errors.length;i++){ req.push("linter-category-"+HINT.errors[i]);} if(!API.Api){ API.Api=new mw.Api;} API.Api.loadMessagesIfMissing(req).done(BOX.filler).fail(API.fault);} if(BOX.$pagename){ GUIDER.from(BOX.$pagename);}} }; BOX.filler=function{ var n=0,e,i,k,par,s,$e,$e2,$e3,$td,$tr; for(i=0;i<API.errors.length;i++){ e=API.errors[i]; s="linter-category-"+e.type; if(mw.messages.exists(s)){ s=mw.message(s).text; }else{ UPDATE.feed(e.type); if(HINT.later){ s=e.type; }else{ s=false;}} if(s){ $tr=$(" "); $td=$(" "); $td.css({"background-color":"#"+BOX.bgcErr}); $td.text(s); $tr.append($td); $td=$(" "); $td.css({"background-color":"#FFFFFF"}); if(typeof e.params==="object"){ par=e.params; 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"){ $e=$(" "); $e.text(par.root); $e2=$(" "); $e2.css({"padding-left":"1em", "padding-right":"1em"}).html("&gt;"); $e3=$(" "); $e3.text(par.child); $td.append($e,$e2,$e3).css({"white-space":"nowrap"}); }else if(typeof par.items==="object"&&typeof par.items.length==="number"){ for(k=0;k<par.items.length;k++){ $e=$(" "); $e.css({"margin-right":"6px", "white-space":"nowrap"}).text(par.items[k]); $td.append($e);}}} $tr.append($td); if(HINT.$textarea&&!GUIDER.last&&typeof e.dsr==="object"&&e.dsr&&typeof e.dsr[0]==="number"&&typeof e.dsr[1]==="number"){ $td=$(" "); $td.click(BOX.find).css({"background-color":"#FFFFFF"}).data("range",e.dsr) .data("sort-value",i).text(" ↓ "); if(typeof BOX.swift==="string"){ $td.attr({title:BOX.swift});} $tr.append($td);} BOX.$tbody.append($tr); n++;}} if(n){ if(BOX.$other){ BOX.$other.hide;} if(n>1&&typeof BOX.$table.tablesorter==="function"){ BOX.$table.tablesorter;} BOX.$table.show; }else{ BOX.$table.hide; if(BOX.$other){ BOX.$other.show; }else{ if(PREGO.app){ BOX.future; }else{ mw.hook(PREGO.signature+".ready").add(BOX.future);}}} }; BOX.find=function(event){ var $item=$(event.target),range=$item.data("range"); HINT.$textarea.focus.textSelection("setSelection",{start:range[0],end:range[1]}); }; BOX.flag=function(application){ if(application){ PREGO.app=application;} BOX.swift=PREGO.app.translation(HINT.texts.mark); BOX.$swift.attr({title:BOX.swift}); }; BOX.flat=function($area,alive){ if($area&&!HINT.$page){ HINT.$page=$area;} if(BOX.$box){ BOX.$box.hide;} if(BOX.$collapsed&&!alive&&!EDIT.live){ BOX.$collapsed.hide;} if(EDIT.live){ if(!alive){ BOX.flip;} }else if(!API.errors&&!API.scream&&HINT.live){ if(API.single&&GUIDER.$pagename){ if(BOX.$null){ BOX.$null.hide;} GUIDER.from(GUIDER.$pagename); }else if(BOX.$null){ if(HINT.lazy){ BOX.$null.hide; }else{ BOX.$null.show;} }else if(!HINT.lazy&&HINT.launched&&HINT.$page){ face; BOX.$null=$(" "); BOX.$null.attr({id:Signature+"-null"}).css({"background-color":"#"+BOX.bgcOk, "clear":"both", "color":"#"+BOX.fgc, "float":(HINT.ltr?"right":"left"), "font-size":"smaller", "padding":"3px"}).text(Signature); if(!GUIDER.live){ BOX.$null.attr({title:Signature+"@PerfektesChaos "+Version});} BOX.focus(BOX.$null);} }else if(BOX.$null){ BOX.$null.hide;} }; BOX.flip=function($area){ if($area&&!HINT.$page){ HINT.$page=$area;} face; BOX.flat($area,true); if(BOX.$collapsed){ BOX.$collapsed.attr({disabled:false}).show; }else{ BOX.$collapsed=$(" "); BOX.$collapsed.attr({id:Signature+"-collapsed"}).click(BOX.full).css({/*"clear":(HINT.ltr?"right": "left"),*/ "display":"block", "float":(HINT.ltr?"right": "left"), "margin-bottom":"3px", "padding":"2px"}).text(Signature); if(!GUIDER.live){ BOX.$collapsed.attr({title:Version});} BOX.focus(BOX.$collapsed);} BOX.$collapsed.css({"background-color":"#"+BOX.bgc, "color":"#"+BOX.fgc}); if(EDIT.live&&!API.errors){ EDIT.fine;} if(GUIDER.$pagename){ GUIDER.$pagename.hide;} }; BOX.focus=function($apply){ var learn=(!BOX.$top),$e; if(learn){ BOX.$top=$(" "); BOX.$top.addClass("noprint").attr({id:Signature+"-top"}) .css({"clear":"both", "width":"100%"}); $e=$(" "); $e.css({"clear":"both"}); HINT.$page.prepend(BOX.$top,$e);} $apply.addClass("noprint"); BOX.$top.prepend($apply); if(learn&&window.document.location.hash){ window.document.location=window.document.location.href;} }; BOX.full=function{ var idRev; if(HINT.live){ if(BOX.$box){ if(EDIT.live){ API.errors=false; }else{ BOX.$collapsed.hide;} if(API.errors){ BOX.$box.show; }else{ BOX.$box.hide;}} if(!API.errors){ BOX.$collapsed.attr({disabled:true}).css({"background-color":"#"+BOX.bgcRun, "color":"#"+BOX.fgcRun});} if(!GUIDER.live){ if(!API.single){ API.single=mw.config.get("wgPageName");} if(HINT.idRev&&HINT.idRev>0){ idRev=HINT.idRev;}} if(EDIT.live){ EDIT.fire; }else{ HINT.launch=true; API.full(API.single,idRev);} }else{ BOX.$collapsed.hide;} }; BOX.future=function(application){ var $e; if(application){ PREGO.app=application;} if(PREGO.app){ $e=$(" "); $e.css({"border-color":"#"+BOX.boc, "border-style":"solid", "border-width":"1px", "padding":"0.4em"}).html(PREGO.app.translation(HINT.texts.other)); BOX.$other=$(" "); BOX.$other.attr({id:Signature+"-future"}).css({"clear":"both", "padding-bottom":"1em", "padding-top":"1em"}).append($e); BOX.$box.append(BOX.$other);} }; CODMIRROR.fetch=function{ var r; if(CODMIRROR.first){ r=CODMIRROR.cm.doc.getValue;} return r; }; CODMIRROR.first=function{ 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; }; EDIT.fetch=function{ var r; if(!EDIT.$source){ if(!EDIT.selector){ switch(HINT.source){ case "wikitext": case "proofread-page": EDIT.selector="#wpTextbox1"; break;}} 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.fine=function{ if(EDIT.$source){ EDIT.listen=true; EDIT.$source.focusin(EDIT.focus); BOX.$collapsed.css({"background-color":"#"+BOX.bgcOk});} }; EDIT.fire=function{ 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.focus=function{ if(EDIT.listen){ BOX.$collapsed.css({"background-color":"#"+BOX.bgc}); EDIT.listen=false;} }; LINTER.fire=function{ LINTER.live=true; mw.hook("wikipage.content").add(LINTER.form); }; LINTER.first=function{ if(mw.config.get("wgTitle").indexOf("/")>0&&!LINTER.live){ fair(LINTER.fire);} }; LINTER.form=function($area){ var $table=$area.find(".mw-datatable, .TablePager"); if($table.length){ if(typeof $table.tablesorter==="function"){ $table.tablesorter;}} }; GUIDER.facet=function($activate){ if($activate){ $activate.css({"float":(HINT.ltr?"right":"left"), "margin-top":"1em"}); GUIDER.$desc.before($activate);} }; GUIDER.figure=function{ var s=GUIDER.$rev.val.trim; if(!GUIDER.reNaN){ GUIDER.reNaN=new RegExp("[^0-9]","g");} s=s.replace(GUIDER.reNaN,""); GUIDER.$rev.val(s); }; GUIDER.filled=function{ var s=GUIDER.$input.val.trim; GUIDER.$rev.attr({disabled:(s?false:true)}); }; GUIDER.find=function{ var s=GUIDER.$input.val.trim; GUIDER.$input.val(s); GUIDER.fired; GUIDER.last=true; if(s){ API.single=s; API.full(s,GUIDER.$rev.val);} }; GUIDER.finish=function(application){ var $e=$(" "); PREGO.app=application; GUIDER.$desc.html(PREGO.app.translation(HINT.texts.desc)); $e.css({"clear":"both", "margin-top":"8em"}).html(PREGO.app.translation(HINT.texts.howTo)); HINT.$page.append($e); $e=$(""); $e.attr({href:"https://"+PREGO.app.translation(HINT.texts.domain)+"/wiki/User:PerfektesChaos/js/"+Signature,target:Signature}).text(GUIDER.$doc.text); GUIDER.$doc.text("").append($e); }; GUIDER.fire=function{ var s=GUIDER.$textarea.val; GUIDER.fired; GUIDER.last=false; if(!GUIDER.reTrim.test(s)){ API.single=false; API.fire(s); HINT.launched=true;} }; GUIDER.fired=function{ GUIDER.flat; if(!GUIDER.reTrim){ GUIDER.reTrim=new RegExp("^\\s*$");} }; GUIDER.first=function{ var i; PREGO.fire; for(i=0;i<GUIDER.using.length;i++){ HINT.using.push(GUIDER.using[i]);} fair; mw.loader.load(HINT.using); HINT.live=true; GUIDER.live=true; mw.hook("wikipage.content").add(GUIDER.furnish); }; GUIDER.flat=function{ if(BOX.$box){ BOX.$box.hide;} if(BOX.$collapsed){ BOX.$collapsed.hide;} if(BOX.$null){ BOX.$null.hide;} if(GUIDER.$pagename){ GUIDER.$pagename.hide;} }; GUIDER.foreign=function{ var req=["general-form-reset","go"],i; if(!API.Api){ API.Api=new mw.Api;} UPDATE.fetch; for(i=0;i<HINT.errors.length;i++){ req.push("linter-category-"+HINT.errors[i]);} API.Api.loadMessagesIfMissing(req).done(GUIDER.form).fail(API.fault); }; GUIDER.form=function{ var submit=mw.message("go").text,$b=$(" "),$div=$(" "),$x=$(" "); $x.css({"color":"#FF0000", "font-weight":"bolder"}).text("X"); $b.addClass("mw-ui-button mw-ui-progressive").click(GUIDER.fire).css({"color":"#FFFFFF"}) .text(submit); GUIDER.$formText.append($b); $b=$(" "); $b.addClass("mw-ui-button").append($x).attr({type:"reset"}) .click(GUIDER.flat).css({"display":"block", "float":(HINT.ltr?"right":"left")}); GUIDER.$formText.append($b); $div.css({"clear":"both"}); GUIDER.$formPage.append($div); $b=$(" "); $b.addClass("mw-ui-button").append($x.clone).attr({type:"reset"}) .click(GUIDER.flat).click(GUIDER.filled).css({"float":(HINT.ltr?"right":"left")}); GUIDER.$formPage.append($b); $b=$(" "); $b.addClass("mw-ui-button mw-ui-progressive").click(GUIDER.find).css({"color":"#FFFFFF"}) .text(submit); GUIDER.$formPage.append($b); mw.hook(PREGO.signature+".ready").add(GUIDER.finish); }; GUIDER.from=function($at){ var $e; if(API.single){ $e=$at.children; if(!$e.length){ $e=$(""); $e.attr({target:"_blank"}); $at.append($e);} $e.attr({href:mw.util.getUrl(API.single)}).text(API.single); $at.show; }else{ $at.hide;} }; GUIDER.furnish=function($area){ var $v=$("head"),$e=$v.find("title"); $e.remove; $e=$(" "); $e.text(Signature); $v.prepend($e); HINT.$page=$area; HINT.$page.empty; face; $v=HINT.$body.find("#firstHeading,#section_0"); if(!$v.length){ $v=$("h1");} $v.eq(0).text(Signature); $v=$(" "); $v.css({"clear":"both"}); GUIDER.$doc=$(" "); GUIDER.$doc.text(Signature+"@PerfektesChaos"); $e=$(" "); $e.css({"font-size":"smaller"}).css("margin-"+(HINT.ltr?"left":"right"),"2em").text(Version); $v.append(GUIDER.$doc,$e); GUIDER.$desc=$(" "); GUIDER.$desc.css({"font-size":"111%"}).text(" "); $v.append($v,GUIDER.$desc); HINT.$page.append($v); GUIDER.$formText=$(" "); GUIDER.$textarea=$(" "); GUIDER.$textarea.addClass("mw-ui-input").attr({name:"wikitext"}) .css({"margin-top":"2em", "max-width":"100%", "width":"100%"}); GUIDER.$formText.append(GUIDER.$textarea); GUIDER.$formPage=$(" "); GUIDER.$formPage.css({"clear":"both", "margin-top":"3em"}); GUIDER.$input=$(" "); GUIDER.$input.addClass("mw-ui-input").attr({maxlength:255,name:"pagename",size:50,type:"text"}).css({"float":(HINT.ltr?"left":"right"), "width":"auto", "max-width":"auto"}).keyup(GUIDER.filled).mouseup(GUIDER.filled); GUIDER.$formPage.append(GUIDER.$input); GUIDER.$rev=$(" "); GUIDER.$rev.addClass("mw-ui-input").attr({disabled:true,inputmode:"numeric",maxlength:12,name:"revision",placeholder:"oldid",size:8,type:"text"}).css({"display":"inline-block", "margin-left":"1.5em", "margin-right":"1.5em", "width":"auto", "max-width":"auto"}).keyup(GUIDER.figure).mouseup(GUIDER.figure); GUIDER.$formPage.append(GUIDER.$rev); HINT.$page.append(GUIDER.$formText,GUIDER.$formPage); GUIDER.$pagename=$(" "); GUIDER.$pagename.attr({id:Signature+"-pagename"}).css({"background-color":"#"+BOX.bgcOk, "float":(HINT.ltr?"left":"right"), "margin-bottom":"1em", "padding":"4px"}).hide; HINT.$page.prepend(GUIDER.$pagename); HINT.$textarea=GUIDER.$textarea; mw.loader.using(HINT.using,GUIDER.foreign); mw.hook(PREGO.signature+".$button").fire(GUIDER.facet,Signature); }; PREGO.features=function(applied){ var i,n,s,v,vals; if(typeof applied==="object"&&applied){ n=PREGO.pars.length; for(i=0;i<n;i++){ v=PREGO.pars[i]; s=v[0]; if(typeof applied[s]===v[1]){ HINT[s]=applied[s];}} if(typeof applied.layer==="boolean"){ delete applied.layer; mw.hook(PREGO.signature+".forward").fire(Signature,applied);}} if(HINT.spaces){ HINT.spaces=HINT.spaces.trim;} if(PREGO.live){ PREGO.form; }else if(LINTER.live){ LINTER.live=false; LINTER.first; }else{ if(HINT.spaces){ if(HINT.spaces==="*"){ HINT.live=true; }else if(HINT.spaces!=="-"){ vals=HINT.spaces.split(" "); s=HINT.nsn+""; for(i=0;i=0){ mw.loader.using(HINT.using,BOX.feed);}} }; PREGO.feed=function{ var sign="ext.gadget."+PREGO.signature,rls; if(!mw.loader.getState(sign)){ rls={}; rls[sign]="loading"; mw.loader.state(rls); REPOS.fire(PREGO.site,PREGO.store+PREGO.signature+PREGO.sub,false,{action:"raw",ctype:"text/javascript",bcache:1,maxage:PREGO.maxage});} }; PREGO.fiat=function{ var s=PREGO.$spaces.val,i,k,got,rooms; if(s.indexOf("-")>=0){ s="-"; }else if(s.indexOf("*")>=0){ s="*"; }else{ got=s.trim.split(" "); s=""; if(got.length>0){ if(typeof PREGO.rooms!=="object"){ PREGO.follow=function(a,b){ return(a0){ rooms.sort(PREGO.follow); s=rooms.join(" ");}}} PREGO.$spaces.val(s); }; PREGO.field=function($applying){ PREGO.$spaces=$applying; PREGO.$spaces.change(PREGO.fiat); }; PREGO.fire=function{ PREGO.feed; mw.hook(PREGO.signature+".fetch").fire(Signature,PREGO.features); }; PREGO.form=function{ var support=".wikipedia.org/wiki/"+HINT.doc.substr(3),docs={"en":"//en"+support, "de":"//de"+support}, dialog,opts; opts=[{signature:"spaces",type:"text",show:HINT.texts["^^spaces"],val:(HINT.spaces?HINT.spaces:""),field:PREGO.field},{signature:"launch",type:"checkbox",show:HINT.texts["^^launch"],val:HINT.launch},{signature:"last",type:"checkbox",show:HINT.texts["^^last"],val:HINT.last},{signature:"lazy",type:"checkbox",show:HINT.texts["^^lazy"],val:HINT.lazy}]; dialog={script:Signature,support:docs,suffix:HINT.texts["^suffix"],opts:opts}; mw.hook(PREGO.signature+".form").fire(dialog); }; REPOS.fire=function(at,access,append,alter){ var source,syntax; if(typeof REPOS.requests!=="object"){ REPOS.requests={};} if(typeof REPOS.requests[access]!=="boolean"){ REPOS.requests[access]=true; if(append){ source=access+append; }else{ source=access;} if(at){ source=REPOS.foundation(at,source,alter); if(typeof alter==="object"&&alter&&typeof alter.ctype==="string"){ syntax=alter.ctype;} }else{ syntax=alter;} mw.loader.load(source,syntax);} }; REPOS.foundation=function(at,access,alter){ var s=access,r=encodeURI(s); if(typeof alter==="object"&&alter){ r="/w/index.php?title="+r; if(access.substr(-3)===".js"){ alter.ctype="text/javascript"; }else if(access.substr(-4)===".css"){ alter.ctype="text/css";} alter.action="raw"; for(s in alter){ r=r+"&"+s+"="+encodeURI(alter[s]);} }else{ r="/wiki/"+r;} if(typeof at==="string"&&at){ switch(at){ case "meta": r="meta.wikimedia.org"+r; break; case "mw": r="www.mediawiki.org"+r; break; case "w:en": r="en.wikipedia.org"+r; break; default: r=window.location.host+r;} r="https://"+r;} return r; }; TMPLXPAND.first=function{ TMPLXPAND.live=true; HINT.live=true; EDIT.live=true; EDIT.selector="#output"; mw.loader.using(HINT.using,TMPLXPAND.further); }; TMPLXPAND.further=function{ mw.hook("wikipage.content").add(BOX.flip); }; UPDATE.feed=function(apply){ if(typeof UPDATE.o!=="object"){ UPDATE.o={};} if(typeof UPDATE.o.unknown!=="object"){ UPDATE.o.unknown=[];} if($.inArray(apply,HINT.errors)<0){ HINT.errors.push(apply); UPDATE.o.unknown.push(apply);} UPDATE.flush; }; UPDATE.fetch=function{ var storage=mw.storage.get(Signature),i,k,parsed,s,unknown; if(typeof storage==="string"){ try{ parsed=JSON.parse(storage); if(typeof parsed==="object"&&parsed){ if(typeof parsed.translations==="object"&&parsed.translations){ UPDATE.o={translations:parsed.translations};} if(typeof parsed.unknown==="object"&&parsed.unknown&&typeof parsed.unknown.length==="number"&&parsed.unknown.length){ unknown=[]; for(i=0;i<parsed.unknown.length;i++){ 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); unknown.push(s);}}}} if(unknown.length){ if(typeof UPDATE.o==="object"){ UPDATE.o.unknown=unknown; }else{ UPDATE.o={unknown:unknown};}} if(unknown.length!==parsed.unknown.length){ UPDATE.flush;}}} }catch(e){ } if(typeof UPDATE.o!=="object"){ UPDATE.flush;}} }; UPDATE.flush=function{ var storage; if(typeof UPDATE.o==="object"){ storage=JSON.stringify(UPDATE.o);} if(storage){ mw.storage.set(Signature,storage); }else{ mw.storage.remove(Signature);} }; WIKED.fetch=function{ 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;} }; first; }(window.mediaWiki,window.jQuery)); /// EOF lintHint/r.js