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

Content deleted Content added
3.0
3.2
Line 1:
/// User:PerfektesChaos/js/lintHint/r.js
/// 2018-0506-0906 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#3015094E9AAC1976#
/// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA)
///<nowiki>
(function(mw,$){
"use strict";
var Version=3.02,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.api.messagesstorage","mediawiki.util"],$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},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={},TEACH={},WIKITEXT={live:false};
HINT.texts={
"desc":{"en":"Show LintErrors analysis live.","de":"Zeige LintErrors-Analyse live.",
Line 93:
switch(s.substr(i+1)){
case Signature:
TEACH.fetch();
GUIDER.first();
listen=true;
Line 101 ⟶ 100:
PREGO.fire();
break;}}
break;
case "ExpandTemplates":
PREGO.fire();
fair(WIKITEXT.first);
break;
case "LintErrors":
Line 130 ⟶ 133:
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;}}
Line 155 ⟶ 160:
if(live){
fair();
TEACH.fetch();
PREGO.fire();}
HINT.pub={doc:"[["+HINT.doc+"]]",type:Signature,vsn:Version};
Line 299 ⟶ 303:
};
BOX.feed=function(){
TEACH.fetch();
if(HINT.launch&&!HINT.launched&&!EDIT.live){
API.full();
Line 400 ⟶ 405:
if(HINT.$textarea&&!GUIDER.last&&typeof e.dsr==="object"&&e.dsr&&typeof e.dsr[0]==="number"&&typeof e.dsr[1]==="number"){
$td=$("<td>");
$td.click(BOX.find).datacss({"rangebackground-color",e.dsr:"#FFFFFF"}).data("sort-valuerange",ie.dsr)
.data("sort-value",i).text(" ↓ ");
if(typeof BOX.swift==="string"){
$td.attr({title:BOX.swift});}
Line 499 ⟶ 504:
};
BOX.full=function(){
var source;
if(HINT.live){
if(BOX.$box){
Line 516 ⟶ 520:
if(EDIT.live){
if(!EDIT.$source){
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());
Line 668 ⟶ 673:
if(!API.Api){
API.Api=new mw.Api();}
TEACH.fetch();
for(i=0;i<HINT.errors.length;i++){
req.push("linter-category-"+HINT.errors[i]);}
Line 796 ⟶ 802:
var s="ext.gadget."+PREGO.signature;
if(mw.loader.getState(s)!=="ready"){
REPOS.fire(PREGO.site,PREGO.store+PREGO.signature+PREGO.sub,false,{action:"raw",ctype:"text/javascript",bcache:1,maxage:604813PREGO.maxage});}
};
PREGO.fiat=function(){
Line 889 ⟶ 895:
TEACH.feed=function(apply){
if(typeof TEACH.o!=="object"){
TEACH.o=[]{};}
if(typeof TEACH.o.push(applyunknown!=="object");{
TEACH.o.unknown=[];}
if($.inArray(apply,HINT.errors)<0){
HINT.errors.push(apply);
TEACH.o.unknown.push(apply);}
TEACH.flush();
};
TEACH.fetch=function(){
var gotstorage=mw.storage.get(Signature),i,k,leave,parsed,s,webLsunknown;
if(typeof window.localStoragestorage==="objectstring"){
webLs=window.localStorage;
if(webLs&&typeof webLs.getItem==="function"){
try{
parsed=JSON.parse(gotstorage);
got=webLs.getItem(Signature);
if(typeof TEACH.o!parsed==="object"&&parsed){
if(got){
if(typeof parsed.translations==="object"&&parsed.translations){
parsed=JSON.parse(got);
TEACH.o={translations:parsed.translations};}
if(typeof parsed.unknown==="object"&&parsed.unknown&&typeof parsed.unknown.length==="number"&&parsed.unknown.length){
TEACH.o=parsed;
unknown=[];
for(i=0;i<TEACHparsed.ounknown.length;i++){
s=TEACH.o[i];
s=parsed.unknown[i];
if(typeof s==="string"&&s){
s=s.trim();
if(gots){
k=$.inArray(s,HINT.errors);
if(k<0){
HINT.errors.push(s);
unknown.push(s);}}}}
if(TEACH.ounknown.length){
if(typeof TEACH.o==="object"){
TEACH.o.unknown=unknown;
}else{
TEACH.o={unknown:unknown};}}
s=false;}
if(unknown.length!==parsed.unknown.length){
}else{
TEACH.flush();}}}
s=false;}
if(!s){
TEACH.o.splice(i,1);
leave=true;}}}}
if(typeof TEACH.o!=="object"){
TEACH.o=[];}
if(got&&(leave||!TEACH.o.length)){
TEACH.flush();}
}catch(e){
}}}
if(typeof TEACH.o!=="object"){
TEACH.o=parsedflush();}}
};
TEACH.flush=function(){
var webLsstorage;
if(typeof windowTEACH.localStorageo==="object"){
webLs.setItem(Signature,storage=JSON.stringify(TEACH.o));}
webLs=window.localStorage;
if(!sstorage){
if(webLs&&typeof webLs.removeItem==="function"&&typeof webLs.setItem==="function"){
mw.storage.set(Signature,storage);
try{
if(TEACH.o.length){
webLs.setItem(Signature,JSON.stringify(TEACH.o));
}else{
webLsmw.removeItemstorage.remove(Signature);}
};
}catch(e){
WIKITEXT.first=function(){
}}}
WIKITEXT.live=true;
HINT.live=true;
EDIT.live=true;
EDIT.source="#output";
mw.loader.using(HINT.using,WIKITEXT.further);
};
WIKITEXT.further=function(){
mw.hook("wikipage.content").add(BOX.flip);
};
first();