User:PerfektesChaos/js/refNames/core/r.js: Difference between revisions

Content deleted Content added
1.2
1.5 2023-05-01
 
(One intermediate revision by the same user not shown)
Line 1:
/// User:PerfektesChaos/js/refNames/core/r.js
/// 20222023-0805-0901 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#355C5B80A8D94BCE#
/// License:CC-by-sa/4.0
///<nowiki>
mw.hook("refNames.config").fire({trigger:[0],rooms:[0,2,4,100],warn:["^q\\d+$","^ref\\d+$"]});
(function(mw,$){
"use strict";
var Version=1.25,Signature="refNames",THIS={lapsus:false,launch:false,reUscore:false,show:"&lt;ref&gt;",sub:"core",using:["mediawiki.api","mediawiki.storage"],warn:["^:?\\d+$","^:$","^Reference[A-Z]$","^auto(?:generated)?\\d*$",String.fromCharCode(0x5B,0x09,0x0A,0x22,0x23,0x25,0x26,0x27,0x3C,0x3E,0x5B,0x5C,0x5D,0x60,0xA0,0xAD,0xB4,0x02C6,0x02DC,0x2002,0x2003,0x2009,0x200A,0x200B,0x200C,0x200D,0x200E,0x200F,0x2018,0x2019,0x201A,0x201C,0x201D,0x201E,0x202F,0x2032,0x2033,0x2039,0x203A,0x5D)],$widget:false
},PARSER={reQuot:false,reWS:false,pending:false,$textarea:false},SOURCE={before:[".wikibase-entity-usage",".templatesUsed",".hiddencats",".limitreport"],locked:true,pics:{drag:["de","OOjs_UI_icon_trash-destructive.svg"],drop:["9b","OOjs_UI_icon_trash-invert.svg"],exch:["e9","OOjs_UI_icon_reload-invert.svg"],edit:["8a","OOjs_UI_icon_edit-ltr-progressive.svg"],wait:["de","Ajax-loader.gif"]
},section:"section",$box:false,$editor:false,$wrapper:false},VIEW={};
function failure(apply){
Line 169 ⟶ 170:
k=m;}}
return r;}
PARSER.fault=function(all,at,alert,about){
var i,n,s;
if(typeof window.console==="object"&&typeof window.console.warn==="function"){
i=-1;
s=Signature+" #"+at+" "+alert;
n=0;
do{
i=all.indexOf("\n",i+1);
n++;
}while(i>=0&&i<at);
s=Signature+" #"+at+" @"+n+" "+alert;
if(about){
s=s+" -- "+about;}
if(!PARSER.reWS){
PARSER.reWS=new RegExp("\\s+");}
i=at;
while(all.charCodeAt(i)!==0x3C&&i>=0){
i--;}
n=all.indexOf(">",i+1);
if(n<0){
n=i+100;}
s=s+"\n"+all.substring(i,n+1).replace(PARSER.reWS," ");
window.console.warn(s);}
};
Line 186 ⟶ 202:
if(k<0||k>after){
r.lock=true;
PARSER.fault(all,at,"Unbalanced delimiter",about+"="+s);
}else if(k===i+1){
r.lock=true;
PARSER.fault(all,at,"Missing identifier",about+"="+s+s);
}else{
r.set=PARSER.focus(all.substring(i+1,k));
r.more=k+1;}
}else if(k===0x2F||k===0x3E){
PARSER.fault(all,at,"Identifier missing",about+"=");
r.lock=true;
}else{
Line 203 ⟶ 219:
if(k===i){
r.lock=true;
PARSER.fault(all,at,"Missing identifier",about+"=");
k=after+1;
break;}
Line 235 ⟶ 251:
"wikitext":false};}
if(typeof r[s]==="string"){
PARSER.fault(all,at,"Duplicated keyword",s);
lock=true;
}else{
Line 244 ⟶ 260:
break;
default:
PARSER.fault(all,at,"Unknown keyword",s);
lock=true;}}
}while(!lock);
Line 261 ⟶ 277:
}else{
PARSER.lock=true;
PARSER.fault(all,i,"Trailing garbage");}}}
return r;
};
Line 502 ⟶ 518:
}else{
PARSER.lock=true;
PARSER.fault(all,i,"Missing </ref>");}}
if(PARSER.pending){
if(r.next<PARSER.pending.max){
Line 818 ⟶ 834:
SOURCE.fresh();
group=SOURCE.grouped[SOURCE.pre.group];
if(group){
for(i=0;i<group.length;i++){
if(s===group[i].name){
Line 825 ⟶ 842:
SOURCE.exec={group:SOURCE.pre.group,seek:SOURCE.start,shift:s};
SOURCE.$deny.hide();
SOURCE.$doit.show();}}}
if(lapsus){
SOURCE.$input.css({"border-color":"#FF0000"});