User:PerfektesChaos/js/WikiSyntaxTextMod/rI.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:PerfektesChaos/js/WikiSyntaxTextMod/rI. |
/// PerfektesChaos/js/WikiSyntaxTextMod/rI.js
/// 2023-04-03 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#39BE52CA#
/// License:CC-by-sa/4.0
///<nowiki>
if(typeof mediaWiki!=="object"){
mw={config:false,libs:{WikiSyntaxTextMod:{}
},log:function(){"use strict";}
};}
(function(mw){
"use strict";
var version=7.61,sign="WikiSyntaxTextMod",sub="I",rls,self,WSTM;
if(typeof mw.loader==="object"){
rls={};
self="user:PerfektesChaos/"+sign+"/"+sub;
rls[self]="loading";
mw.loader.state(rls);}
if(typeof mw.libs[sign]!=="object"){
mw.libs[sign]={};}
WSTM=mw.libs[sign];
if(typeof WSTM.w!=="object"){
WSTM.w={img:{}};}
if(typeof WSTM.w.img!=="object"){
WSTM.w.img={};}
WSTM.w.img.vsn=version;
WSTM.w.img.self=self;
if(typeof WSTM.bb!=="object"){
WSTM.bb={};}
if(typeof WSTM.debugging!=="object"){
WSTM.debugging={};}
}(mw));
mw.libs.WikiSyntaxTextMod.bb.bbI=function(WSTM){
"use strict";
if(typeof WSTM.util!=="object"){
WSTM.util={};}
if(typeof WSTM.util.fiatObjects!=="function"){
WSTM.util.fiatObjects=function(adult,activate,assign){
var elt,obj,s;
if(typeof adult[activate]!=="object"){
adult[activate]=(assign?assign:{});}
if(assign){
obj=adult[activate];
for(s in assign){
elt=assign[s];
if(typeof elt==="object"){
WSTM.util.fiatObjects(obj,s,elt);}}}
};}
WSTM.util.fiatObjects(WSTM,"debugging",{loud:false});
};
mw.libs.WikiSyntaxTextMod.bb.bbI(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.bbI;
mw.libs.WikiSyntaxTextMod.bb.img=function(WSTM){
"use strict";
var IMG;
WSTM.util.fiatObjects(WSTM,"w",{img:{}});
IMG=WSTM.w.img;
IMG.d={
"alt":{lone:false,type:"string",group:"alt"},
"baseline":{lone:true,type:false,group:"v"},
"border":{lone:true,type:false,group:"border"},
"bottom":{lone:true,type:false,group:"v"},
"center":{lone:true,type:false,group:"h"},
"class":{lone:false,type:"string",group:"class"},
"disablecontrols":{lone:false,type:"string",group:"mc"},
"endtime":{lone:false,type:"time",group:"me"},
"framed":{lone:true,type:false,group:"f"},
"frameless":{lone:true,type:false,group:"f"},
"lang":{lone:false,type:"string",group:"lang"},
"left":{lone:true,type:false,group:"h"},
"link":{lone:false,type:"string",group:"link"},
"lossy":{lone:false,type:"string",group:"lossy"},
"middle":{lone:true,type:false,group:"v"},
"noicon":{lone:true,type:false,group:"mi"},
"none":{lone:true,type:false,group:"h"},
"noplayer":{lone:true,type:false,group:"mp"},
"page":{lone:false,type:"number",group:"page"},
"px":{lone:false,type:true,group:"px"},
"right":{lone:true,type:false,group:"h"},
"starttime":{lone:false,type:"time",group:"ms"},
"sub":{lone:true,type:false,group:"v"},
"super":{lone:true,type:false,group:"v"},
"text-bottom":{lone:true,type:false,group:"v"},
"text-top":{lone:true,type:false,group:"v"},
"thumbnail":{lone:true,type:"string",group:"f"},
"thumbtime":{lone:false,type:"time",group:"mt"},
"top":{lone:true,type:false,group:"v"},
"upright":{lone:true,type:"number",group:"upright"}
};
IMG.pattern=["page","px","upright","f","h","v","class","link","alt","mi","mp","ms","me","mt","mc","unknown","title"];
IMG.factory=function(apply){
var e,i,k,m,n,q,s,t,v;
if(!this.language){
this.language={};
for(s in this.d){
this.language[s]=s;}}
if(apply<=0){
t="";
for(s in this.d){
t=WSTM.lang.translate.feed(t,"$"+s,s,WSTM.lang.translate.read,false);}
t=t.substr(0,t.length-1);
if(typeof this.re!=="object"){
this.re={};}
this.re.beg=new RegExp("^("+t+")\\b","i");
s="[ "+WSTM.str.spaces+"]";
t=WSTM.lang.translate.feed("|","$px","px",WSTM.lang.translate.read,true);
t="^([0-9]*)("+s+"*[x*×]"+s+"*([0-9]+))?"+s+"*("+t+")$";
this.re.px=new RegExp(t,"i");
t="^("+s+"*[:_=]?"+s+"*)([0-9]+)?([.,]([0-9]*))?$";
this.re.vnum=new RegExp(t,"");
t="^("+s+"*[:_=]?"+s+"*)(.+)$";
this.re.vstr=new RegExp(t,"");
t="^("+s+"*[_=]?"+s+"*)([0-9]?[0-9]+)?(:([0-5]?[0-9]))?(\\.([0-9]*))?$";
this.re.vtim=new RegExp(t,"");
n=WSTM.lang.translate.read.length;
for(s in this.d){
e=this.d[s];
q=WSTM.lang.translate.d["$"+s];
if(q){
for(i=0;i<n;i++){
v=q[WSTM.lang.translate.read[i]];
switch(typeof v){
case "string":
if(!this.language[v]){
this.language[v]=s;}
break;
case "object":
m=v.length;
for(k=0;k<m;k++){
t=v[k];
if(t){
if(typeof t==="object"){
t=WSTM.lang.translate.fiat(t);}
if(!this.language[t]){
this.language[t]=s;}}}
break;}}}}}
if(apply>=0){
n=WSTM.lang.translate.write.length;
for(s in this.d){
e=this.d[s];
e.write=s;
q=WSTM.lang.translate.d["$"+s];
if(q){
for(i=0;i<n;i++){
t=WSTM.lang.translate.write[i];
v=q[t];
switch(typeof v){
case "string":
e.write=v;
i=n;
break;
case "object":
v=v[0];
if(v){
e.write=WSTM.lang.translate.fiat(v);}
i=n;
break;}}}}}
};
IMG.fault=function(action,about,accumulate){
if(!accumulate.error$){
WSTM.errors.found("imgPar"+action,false,about+"\n("+accumulate.file$+")");
accumulate.error$=true;}
};
IMG.feature=function(attr,adapt,alter,apply,accumulate){
var r;
switch(attr){
case "disablecontrols":
case "lang":
r=this[attr](apply,accumulate);
if(r){
r=adapt.write+r;}
break;
case "px":
r=apply+adapt.write;
break;
case "thumbnail":
r=WSTM.hooks.fire("thumbnail",alter);
if(!r){
r=adapt.write;}
r=r+(apply?apply:"");
break;
default:
r=adapt.write+(apply?apply:"");}
return r;
};
IMG.feed=function(attr,apply,alter,attempt,accumulate){
var r=attempt,stored,what;
if(attr){
what=this.d[attr];
if(what.lone||apply){
if(accumulate.title||accumulate.unknown){
accumulate.all$=true;}
stored=accumulate[attr];
if(stored){
if(stored===apply||!apply){
r=false;
}else if(attr==="px"&&apply){
accumulate[attr]=apply;
}else if(stored===true&&apply){
accumulate.all$=true;
accumulate[attr]=apply;
}else{
stored=false;
this.fault("ValueConflict",attempt,accumulate);}
}else{
accumulate[attr]=(apply?apply:true);
stored=true;}
if(stored&&r){
r=this.feature(attr,what,alter,apply,accumulate);}
}else{
this.fault("MissingValue",alter,accumulate);}
}else{
if(accumulate.unknown){
this.fault("Unrecognized",accumulate.unknown,accumulate);
}else{
accumulate.unknown=attempt;}}
return r;
};
IMG.file=function(assert){
var r=false,g,s;
if(typeof this.re!=="object"){
this.re={};}
if(typeof this.re.tit!=="object"){
this.re.ext=new RegExp("\\.("+WSTM.w.link.mediatypes+")$","i");
this.re.tit=new RegExp("^[^/#|{}\n]+\\.[a-zA-Z]+[0-9]?$");}
if(assert){
s=WSTM.str.trim(assert);
g=this.re.tit.exec(s);
if(g){
g=this.re.ext.exec(s);
if(g){
r=g[1].toLowerCase();
}else{
WSTM.errors.found("fileTypeUnkown",false,s);}
}else{
WSTM.errors.found("fileInvalid",false,s);}}
};
IMG.fix=function(assign,accumulate){
var g=this.re.beg.exec(assign),r=assign;
if(g){
r=this.front(g[1],assign,accumulate);
}else{
g=this.re.px.exec(assign);
if(g){
r=this.px(g[4],g[1],g[3],accumulate);
}else{
r=this.feed(false,false,false,assign,accumulate);}}
return r;
};
IMG.flip=function(assignment,accumulate){
var lapsus=false,n=WSTM.w.img.pattern.length,r=assignment,show="",i,k,q,s,select,single,type,what;
if(accumulate.noicon||accumulate.noplayer){
delete accumulate.noicon;
delete accumulate.noplayer;
accumulate.all$=true;}
if(accumulate.end){
accumulate.endtime=accumulate.end;
delete accumulate.end;
accumulate.all$=true;}
if(accumulate.start){
accumulate.starttime=accumulate.start;
delete accumulate.start;
accumulate.all$=true;}
if(typeof accumulate.framed!=="undefined"&&typeof accumulate.px!=="undefined"){
this.fault("Contradiction","framed ./. px",accumulate);}
if(!this.cross){
this.cross=new Array(n);
for(i=0;i<n;i++){
select=this.pattern[i];
this.cross[i]=[];
for(s in this.d){
what=this.d[s];
if(what.group===select){
this.cross[i].push(s);}}
if(select==="h"){
this.horizontal=this.cross[i];}}}
if(accumulate.thumbnail){
for(k=0;k<this.horizontal.length;k++){
s=this.horizontal[k];
if(typeof accumulate[s]!=="undefined"){
if(single){
single=false;
break;
}else{
single=s;}}}
if(single){
s=":"+WSTM.g.projLang+":";
if(WSTM.lang.chr.rtl.indexOf(s)<0){
if(single==="right"){
accumulate.all$=true;
accumulate.right=undefined;}
}else{
if(single==="left"){
accumulate.all$=true;
accumulate.left=undefined;}}}}
for(i=0;i<n;i++){
type=this.cross[i];
single=false;
for(k=0;k<type.length;k++){
s=type[k];
if(typeof accumulate[s]!=="undefined"){
if(single){
lapsus=true;
this.fault("Contradiction",single+" ./. "+s,accumulate);
}else if(!lapsus){
if(accumulate[s]===true){
q=false;
}else{
q=accumulate[s];}
s=this.feature(s,this.d[s],false,q,accumulate);
if(s){
if(show){
show=show+"|";}
show=show+s;
single=s;}}}}}
if(!lapsus){
if(accumulate.unknown){
show=show+"|"+accumulate.unknown;}
if(accumulate.all$){
r=show;}}
return r;
};
IMG.format=function(arglist){
var current={"all$":false,
"error$":false,
"file$":arglist.score,title:false,unknown:false},i=-99,r="",show=arglist.sequence,sparse=WSTM.str.trim(show),story=sparse,s,single;
this.file(arglist.score);
while(story){
i=story.indexOf("|");
if(i>0){
single=story.substr(0,i);
story=story.substr(i+1);
}else if(i){
single=story;
story=false;
}else if(!i){
single=false;
story=story.substr(1);}
if(single){
single=WSTM.str.trim(single,true,true);}
if(single){
s=this.fix(single,current);
if(s){
if(r){
r=r+"|";}
r=r+s;}}}
if(!current.error$){
r=this.flip(r,current);}
if(sparse.charCodeAt(sparse.length-1)===124&&!arglist.last){
r=r+"|";}
if(current.title){
if(show.charCodeAt(show.length-1)===32){
r=r+" ";}}
return r;
};
IMG.front=function(attribute,assign,accumulate){
var r=assign,setting=false,slip=attribute.toLowerCase(),seed=this.language[slip],suffix=assign.substr(attribute.length),what=this.d[seed],i,j,k,s,got;
if(what){
switch(what.type){
case "link":
break;
case "number":
if(suffix){
s=WSTM.str.trimL(suffix);
got=this.re.vnum.exec(s);
if(got){
i=WSTM.str.parseIntNumber(got[2],10);
j=got[4];
if(i||j){
if(j){
switch(seed){
case "upright":
j=j.substr(0,1);
if(j==="0"){
if(i===0){
j="1";
}else{
j=false;}}
break;
default:
j=false;}
}else{
j=false;}
if(i||j){
setting="="+i;
if(j){
setting=setting+"."+j;}}
}else if(WSTM.str.trim(got[1])){
seed=false;
this.fault("InvalidValue",assign,accumulate);}
}else{
seed=false;}}
break;
case "string":
suffix=WSTM.str.trimL(suffix);
got=this.re.vstr.exec(suffix);
if(got){
if(got[1]){
if(slip==="disablecontrols"){
setting=this.disablecontrols(got[2]);
if(!setting){
seed=false;}
}else{
setting="="+got[2];}
}else if(seed==="alt"||seed==="link"){
if(got[0]==="="){
setting="=";
}else{
seed=false;}
}else{
seed=false;}
}else if(!what.lone){
seed=false;}
break;
case "time":
suffix=WSTM.str.trim(suffix);
got=this.re.vtim.exec(suffix);
if(got){
if(!got[3]){
got[4]=got[2];
got[3]=true;
got[2]=false;}
if(got[2]){
i=got[2];
}else{
i=0;}
if(got[3]){
if(got[4]){
j=parseInt(got[4],10);
}else{
j=0;}
}else if(i){
j=0;}
if(got[6]){
k=parseInt(got[6],10);
}else{
k=0;}
setting="=";
if(i){
setting=setting+i+":";}
if(j||k){
setting=setting+(j<10?"0":"")+j;
if(k){
setting=setting+"."+got[6];}
}else if(i){
setting=setting+"00";
}else{
setting=setting+"0";}
}else{
seed=false;}
break;
default:
if(suffix){
seed=false;}}
r=this.feed(seed,setting,slip,assign,accumulate);
}else{
mw.log(WSTM.debugging,".w.img.front() what?\n"+assign,2);}
return r;
};
IMG.disablecontrols=function(assign){
var r=false,pars={fullscreen:[false,"fullscreen"],options:[false,"options"],timedtext:[false,"timedText"]
},e;
for(e in pars){
if(assign.search(new RegExp("\\b"+e+"\\b","i"))>=0){
pars[e][0]=true;}}
for(e in pars){
if(pars[e][0]){
if(r){
r=r+",";
}else{
r="=";}
r=r+pars[e][1];}}
return r;
};
IMG.lang=function(assign,accumulate){
var r=false,got;
if(typeof this.re.svg!=="object"){
this.re.svg=new RegExp("\\.svg$","i");
this.re.lang=new RegExp("^([a-z][a-z][a-z]?)(-[a-z]+)?$","i");}
if(accumulate.file$.match(this.re.svg)){
if(assign.substr(0,1)==="="){
r=WSTM.str.trim(assign.substr(1));
got=this.re.lang.exec(r);
if(got){
r="="+got[1].toLowerCase();
if(got[2]){
r=r+"-"+got[2];}
}else{
r=false;}}
}else{
this.fault("LangNoSVG",accumulate.file$,accumulate);}
return r;
};
IMG.px=function(attribute,ahead,after,accumulate){
var setting="";
if(ahead===0||after===0){
this.fault("InvalidValue","0px",accumulate);}
if(ahead){
setting=ahead.toString();}
if(after){
setting=setting+"x"+after;}
if(typeof accumulate.px!=="undefined"){
if(setting===accumulate.px){
setting=false;
}else{
this.fault("ValueConflict",setting+"px ./. "+accumulate.px+"px",accumulate);
setting=accumulate.px+"px|"+setting;}}
if(setting){
return this.feed("px",setting,attribute,true,accumulate);}
};
};
mw.libs.WikiSyntaxTextMod.bb.img(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.img;
(function(WSTM){
"use strict";
var sub="I",self=WSTM.w.img.self,version=WSTM.w.img.vsn,rls;
if(typeof WSTM.main!=="object"){
WSTM.main={};}
if(!WSTM.main.bb){
WSTM.main.bb={};}
WSTM.main.bb[sub]={load:true,vsn:version};
if(typeof WSTM.main.wait==="function"){
WSTM.main.wait(sub,version);}
if(typeof mw.loader==="object"&&typeof mw.hook!=="undefined"){
rls={};
rls[self]="ready";
mw.loader.state(rls);
mw.hook("WikiSyntaxTextMod/"+sub+".ready")
.fire([sub,version]);}
}(mw.libs.WikiSyntaxTextMod));
/// EOF</nowiki>WikiSyntaxTextMod/rI.js