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

Content deleted Content added
3.2
3.3
Line 1:
/// User:PerfektesChaos/js/lintHint/r.js
/// 2018-0607-06 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#9AAC19763140BA74#
/// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA)
///<nowiki>
(function(mw,$){
"use strict";
var Version=3.23,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","obsolete-tag","pwrap-bug-workaround","self-closed-tag","stripped-tag","tidy-font-bug","tidy-whitespace-bug","unclosed-quotes-in-heading"],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"],["layer","boolean"],["lazy","boolean"],["spaces","string"]],signature:"preferencesGadgetOptions",site:"w:en",store:"User:PerfektesChaos/js/",sub:"/r.js"},REPOS={},TEACHTMPLXPAND={live:false},WIKITEXTUPDATE={},WIKED={live:false};
HINT.texts={
"desc":{"en":"Show LintErrors analysis live.","de":"Zeige LintErrors-Analyse live.",
Line 103:
case "ExpandTemplates":
PREGO.fire();
fair(WIKITEXTTMPLXPAND.first);
break;
case "LintErrors":
Line 303:
};
BOX.feed=function(){
TEACHUPDATE.fetch();
if(HINT.launch&&!HINT.launched&&!EDIT.live){
API.full();
Line 370:
s=mw.message(s).text();
}else{
TEACHUPDATE.feed(e.type);
if(HINT.later){
s=e.type;
Line 519:
API.single=mw.config.get("wgPageName");}
if(EDIT.live){
if(!EDIT.$sourcefire(){;
if(!EDIT.source){
switch(HINT.source){
case "wikitext":
case "proofread-page":
EDIT.source="#wpTextbox1";
break;}}
if(EDIT.source){
EDIT.$source=HINT.$page.find(EDIT.source);
if(!(EDIT.$source.length||WIKITEXT.live)){
BOX.$collapsed.hide();
EDIT.live=false;}
}else{
EDIT.live=false;}}
if(EDIT.live&&EDIT.$source&&EDIT.$source.length){
EDIT.listen=false;
API.fire(EDIT.$source.val());
HINT.$textarea=EDIT.$source;}
}else{
HINT.launch=true;
Line 557 ⟶ 540:
.append($e);
BOX.$box.append(BOX.$other);}
};
WIKITEXTCODMIRROR.furtherfetch=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 TEACH.o!uo==="objectnumber"&&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.sourceselector="#wpTextbox1";
break;}}
if(EDIT.selector){
EDIT.$source=HINT.$page.find(EDIT.sourceselector);
if(!(EDIT.$source.length||WIKITEXT.live)){
EDIT.live=false;}
}else{
EDIT.live=false;}}
if(EDIT.live&&EDIT.$source&&EDIT.$source.length){
HINT.$textarea=EDIT.$source;}
API.fire(r=EDIT.$source.val());}
return r;
};
EDIT.fine=function(){
Line 563 ⟶ 582:
EDIT.$source.focusin(EDIT.focus);
BOX.$collapsed.css({"background-color":"#"+BOX.bgcOk});}
};
EDIT.fire=function(){
var source;
if(!TMPLXPAND.live){
source=CODMIRROR.fetch();
if(EDIT.!source){
WIKED.fetch();}}
if(!source){
source=EDIT.fetch();}
if(source){
EDIT.listen=false;
API.fire(source);
}else{
BOX.$collapsed.hide();}
};
EDIT.focus=function(){
Line 673 ⟶ 706:
if(!API.Api){
API.Api=new mw.Api();}
TEACHUPDATE.fetch();
for(i=0;i<HINT.errors.length;i++){
req.push("linter-category-"+HINT.errors[i]);}
Line 801 ⟶ 834:
PREGO.feed=function(){
var s="ext.gadget."+PREGO.signature;
if(!mw.loader.getState(s)!=="ready"){
mw.loader.state(s,"loading");
REPOS.fire(PREGO.site,PREGO.store+PREGO.signature+PREGO.sub,false,{action:"raw",ctype:"text/javascript",bcache:1,maxage:PREGO.maxage});}
};
Line 893 ⟶ 927:
return r;
};
TEACHTMPLXPAND.feedfirst=function(apply){
WIKITEXTTMPLXPAND.live=true;
if(typeof TEACH.o!=="object"){
HINT.live=true;
TEACH.o={};}
EDIT.live=true;
if(typeof TEACH.o.unknown!=="object"){
EDIT.sourceselector="#output";
TEACH.o.unknown=[];}
mw.loader.using(HINT.using,WIKITEXTTMPLXPAND.further);
};
TMPLXPAND.further=function(){
mw.hook("wikipage.content").add(BOX.flip);
};
UPDATE.feed=function(apply){
if(typeof UPDATE.o!=="object"){
TEACHUPDATE.o={};}
if(typeof TEACHUPDATE.o.unknown!=="object"){
TEACHUPDATE.o.unknown=[];}
if($.inArray(apply,HINT.errors)<0){
HINT.errors.push(apply);
TEACHUPDATE.o.unknown.push(apply);}
TEACHUPDATE.flush();
};
TEACHUPDATE.fetch=function(){
var storage=mw.storage.get(Signature),i,k,parsed,s,unknown;
if(typeof storage==="string"){
Line 910 ⟶ 954:
if(typeof parsed==="object"&&parsed){
if(typeof parsed.translations==="object"&&parsed.translations){
TEACHUPDATE.o={translations:parsed.translations};}
if(typeof parsed.unknown==="object"&&parsed.unknown&&typeof parsed.unknown.length==="number"&&parsed.unknown.length){
unknown=[];
Line 923 ⟶ 967:
unknown.push(s);}}}}
if(unknown.length){
if(typeof TEACHUPDATE.o==="object"){
TEACHUPDATE.o.unknown=unknown;
}else{
TEACHUPDATE.o={unknown:unknown};}}
if(unknown.length!==parsed.unknown.length){
TEACHUPDATE.flush();}}}
}catch(e){
}
if(typeof TEACHUPDATE.o!=="object"){
TEACHUPDATE.flush();}}
};
TEACHUPDATE.flush=function(){
var storage;
if(typeof TEACHUPDATE.o==="object"){
storage=JSON.stringify(TEACHUPDATE.o);}
if(storage){
mw.storage.set(Signature,storage);
Line 943 ⟶ 987:
mw.storage.remove(Signature);}
};
WIKITEXTWIKED.firstfetch=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"){
WIKITEXT.live=true;
WIKED.wikEd=window.wikEd;}
HINT.live=true;
if(WIKED.wikEd&&!WIKED.wikEd.disabled&&WIKED.wikEd.useWikEd&&WIKED.wikEd.turnedOn&&WIKED.wikEd.highlightSyntax){
EDIT.live=true;
WIKED.wikEd.UpdateTextarea();}
EDIT.source="#output";
mw.loader.using(HINT.using,WIKITEXT.further);
};
WIKITEXT.further=function(){
mw.hook("wikipage.content").add(BOX.flip);
};
first();