User:PerfektesChaos/js/WikiSyntaxTextMod/rC.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/rC. |
/// PerfektesChaos/js/WikiSyntaxTextMod/rC.js
/// 2024-10-01 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#EC8713D0#
/// @license:CC-by-sa/4.0 GPLv3
///<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="C",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={};}
if(typeof WSTM.w.chr!=="object"){
WSTM.w.chr={};}
WSTM.w.chr.vsn=version;
WSTM.w.chr.self=self;
if(typeof WSTM.bb!=="object"){
WSTM.bb={};}
if(typeof WSTM.debugging!=="object"){
WSTM.debugging={};}
}(mw));
mw.libs.WikiSyntaxTextMod.bb.bbC=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.bbC(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.bbC;
mw.libs.WikiSyntaxTextMod.bb.chr=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM,"w",{chr:{lang:{},re:{tab:false}}
});
if(!WSTM.w.chr.detected){
WSTM.w.chr.detected={ampersand:false,exchange:0,nbHyphen:false,ordMasc:false,tab:false,tabEOL:false,white:false
};}
WSTM.w.chr.fallback=function(adjust){
var r=false;
if(adjust>=8544){
r=((adjust>=8544&&adjust<=8575)||(adjust>=10005&&adjust<=10015)||(adjust>=12288&&adjust<=12301)||(adjust>=65279&&adjust<=65374));}
return r;
};
WSTM.w.chr.fashion=function(adjust,address){
var r=false,s=adjust,c,i,x;
for(i=address;i>=0;i--){
c=s.charCodeAt(i);
if(c>=this.detected.exchange){
if((c>=8544&&c<=8575)||(c>=12288&&c<=12301)||(c>=65281&&c<=65374)){
x=this.format(c,s,i);
if(x!==c){
r=typeof x;
if(r==="number"){
s=WSTM.str.setChar(s,x,i);
}else if(r==="string"){
s=WSTM.str.setString(s,i,1,x);
}else{
s=r;}
r=s;}
}else if(c>=10005&&c<=10015){
switch(c){
case 10005:
case 10006:
c=215;
break;
case 10013:
case 10014:
case 10015:
c=8224;
break;}
if(c<10000){
s=WSTM.str.setChar(s,c,i);
r=s;}}}}
return r;
};
WSTM.w.chr.filter=function(all){
var d=false,l=false,s=all.source,c,i,k;
for(i=s.length-1;i>=0;i--){
c=s.charCodeAt(i);
if(c<128){
if(c<32){
switch(c){
case 10:
if(s.charCodeAt(k+1)===10){
WSTM.w.encountered.indent=true;}
for(k=i-1;k>=0;k--){
c=s.charCodeAt(k);
if(c>32||c===10){
if(c===61){
k++;
if(s.charCodeAt(k)===9){
k--;}}
break;
}else if(c===9){
this.detected.tabEOL=true;}}
if(k<i-1){
this.detected.white=true;
k++;
s=WSTM.str.setString(s,k,i-k,"");
i=k;}
break;
case 13:
break;
case 9:
this.detected.tab=true;
break;
case 11:
case 12:
s=WSTM.str.setChar(s,10,i);
l=true;
break;
default:
s=WSTM.str.setChar(s,"",i);
l=true;
break;}
}else if(c===38){
if(s.substr(i+1,5)!=="nbsp;"){
this.detected.ampersand=true;}}
}else{
if(c<=160){
s=WSTM.str.setChar(s,"&#"+c+";",i);
l=true;
}else if(c<8193){
switch(c){
case 186:
this.detected.ordMasc=true;
break;
case 847:
c=this.form(c);
s=WSTM.str.setChar(s,c,i);
l=true;
break;}
}else if(c>8193&&c<8289){
switch(c){
case 8194:
case 8195:
case 8196:
case 8197:
case 8200:
s=WSTM.str.setChar(s,32,i);
l=true;
break;
case 8198:
case 8201:
s=WSTM.str.setChar(s," ",i);
d=true;
break;
case 8239:
s=WSTM.str.setChar(s," ",i);
d=true;
break;
case 8203:
s=WSTM.str.setChar(s," ",i);
d=true;
break;
case 8204:
s=WSTM.str.setChar(s,"‌",i);
d=true;
break;
case 8205:
s=WSTM.str.setChar(s,"‍",i);
d=true;
break;
case 8209:
this.detected.nbHyphen=true;
break;
case 8206:
case 8207:
case 8234:
case 8235:
case 8236:
case 8237:
case 8238:
WSTM.w.encountered.bidichar=true;
case 8202:
case 8232:
case 8233:
case 8287:
case 8288:
c=this.form(c);
s=WSTM.str.setChar(s,c,i);
l=true;
break;}
}else if(c===8960){
s=WSTM.str.setChar(s,248,i);
l=true;
}else if((c>=57344&&c<=63743)||(c>=983040&&c<=1114111)){
s=WSTM.str.setChar(s,"&#"+c+";",i);
l=true;
}else if(this.fallback(c)){
if(this.detected.exchange){
if(this.detected.exchange>c){
this.detected.exchange=c;}
}else{
this.detected.exchange=c;}}}}
if(WSTM.warn.char){
this.fishing(s);}
c=s.charCodeAt(0);
while(c===10){
s=s.substr(1);
c=s.charCodeAt(0);
this.detected.white=true;}
k=s.length-1;
c=s.charCodeAt(k);
while(c===10){
s=s.substr(0,k);
k--;
c=s.charCodeAt(k);
this.detected.white=true;}
this.whitespace=(this.detected.tab?" \n\t":" \n");
if(d){
this.detected.ampersand=true;
all.learnt=true;
}else if(l){
all.learnt=true;}
all.source=s;
};
WSTM.w.chr.fishing=function(analyse){
var wch=WSTM.warn.char,m=wch.length,max=0,min=4294967295,n=analyse.length,c,got,i,k;
for(k=0;k<m;k++){
c=wch[k];
if(c<min){
min=c;}
if(c>max){
max=c;}}
for(i=0;i<n;i++){
c=analyse.charCodeAt(i);
if(c>=min&&c<=max){
for(k=0;k<m;k++){
if(c===wch[k]){
if(!got){
got={};}
if(typeof got[c]!=="number"){
got[c]=0;}
got[c]++;
break;}}}}
if(got){
for(c in got){
WSTM.warn.found("char",got[c]+"× "+c);}}
};
WSTM.w.chr.fixed=function(adjust){
var r=false;
if(adjust&&adjust<65534){
r=adjust;
switch(r){
case 8206:
case 8207:
WSTM.w.encountered.bidichar=true;
case 34:
case 38:
case 39:
case 60:
case 62:
case 160:
case 710:
case 732:
case 8201:
case 91:
case 93:
case 123:
case 124:
case 125:
r=false;
break;
case 8203:
case 8204:
case 8205:
r=0;
break;
case 8194:
case 8195:
r=32;
break;}}
return r;
};
WSTM.w.chr.fixTab=function(adjust){
var r=false;
if(adjust.indexOf("\t")>=0){
if(!WSTM.w.chr.re.tab){
WSTM.w.chr.re.tab=new RegExp("\\t","g");}
r=adjust.replace(WSTM.w.chr.re.tab," ");}
return r;
};
WSTM.w.chr.flat=function(adjust,assign,alert){
var r;
if(assign){
r=WSTM.str.charEntityHTML5single(adjust);
if(alert&&WSTM.warn.entity&&WSTM.warn.entity.indexOf(adjust)>=0){
WSTM.warn.found("entity","&"+adjust.substr(1));}
}else{
r=WSTM.str.charEntityCode(adjust);
if(alert&&WSTM.warn.entity&&WSTM.warn.entity.indexOf("#"+r)>=0){
WSTM.warn.found("entity","&#"+r+";");}}
if(r){
switch(r){
case 32:
r=" ";
break;
case 34:
case 38:
case 39:
case 60:
case 62:
case 32:
case 35:
case 42:
case 58:
case 59:
case 61:
case 91:
case 93:
case 95:
case 123:
case 124:
case 125:
case 96:
case 160:
case 168:
case 175:
case 180:
case 184:
case 710:
case 711:
case 728:
case 730:
case 731:
case 732:
case 733:
case 173:
case 8201:
case 8202:
case 8209:
case 8239:
r=false;
break;
case 8194:
case 8195:
case 8196:
case 8197:
case 8200:
r=32;
break;
case 8198:
case 8201:
r=" ";
break;
case 8204:
case 8205:
r=false;
break;
case 8232:
case 8233:
case 847:
case 8203:
case 8287:
case 8288:
r=this.form(r);
break;
case 8206:
case 8207:
case 8234:
case 8235:
case 8236:
case 8237:
case 8238:
r=this.form(r);
WSTM.w.encountered.bidichar=true;
break;
case 65279:
r="";
break;
default:
if(r>=10240){
if(WSTM.w.chr.lang.cjk){
r=(r>=11904&&r<=65131);
}else{
r=false;}
}else if(r>8193){
r=this.form(r);
}else if(r<160){
r=false;}
break;}}
if(r){
if(typeof r==="number"){
r=String.fromCharCode(r);}
if(adjust===r){
r=false;}}
return r;
};
WSTM.w.chr.flip=function(all){
var got,i,s,shift;
if(this.detected.ampersand){
this.re.fiat();
if(WSTM.warn.entity){
s="";
for(i=0;i<WSTM.warn.entity.length;i++){
s=s+"&"+WSTM.warn.entity[i]+";";}
WSTM.warn.entity=s;}
if(WSTM.warn.char){
if(typeof WSTM.warn.entity!=="string"){
WSTM.warn.entity="";}
for(i=0;i<WSTM.warn.char.length;i++){
WSTM.warn.entity=WSTM.warn.entity+"&#"+WSTM.warn.char[i]+";";}}
got={i:0,k:0};
do{
got=all.find("&",got.i,got.k,true,false);
if(got){
s=all.fetch(got.k,got.i);
if(s){
shift=this.flipper(s);
if(shift){
all.flip(got.k,got.i,s.length,shift);}}
got.i=0;
got.k++;}
}while(got);}
};
WSTM.w.chr.flipper=function(adjust){
var m=false,r=false,s=adjust,c,e,f,j,k,l;
for(k=0;k<2;k++){
l=(k===1);
r=this.re.entities[k];
r.lastIndex=0;
do{
j=r.lastIndex;
f=r.exec(s);
if(f){
e=f[0];
if(e!==" "){
c=this.flat(e,l,false);
if(typeof c==="string"){
m=true;
j=f.index;
s=s.substr(0,j)+c+s.substr(j+e.length);
r.lastIndex=j+1;}}}
}while(f);}
return(m?s:false);
};
WSTM.w.chr.flushChars=function(adjust){
var c,i,n,s;
if(adjust.children){
n=adjust.children.length;
for(i=0;i<n;i++){
this.flushChars(adjust.children[i]);}
}else if(adjust.lookup){
if(adjust.mode<=WSTM.o.WikiTom.TextOnly){
s=adjust.source;
if(s){
n=false;
for(i=s.length;i>=0;i--){
c=s.charCodeAt(i);
if(c>=WSTM.w.chr.detected.exchange){
s=WSTM.w.chr.fashion(s,i);
n=true;
break;}}
if(n){
if(adjust.source!==s){
adjust.fresh(s);}}}}}
};
WSTM.w.chr.flushEntities=function(adjust){
var c,e,f,i,j,k,l,m,n,s,r;
if(adjust.children){
n=adjust.children.length;
for(i=0;i<n;i++){
this.flushEntities(adjust.children[i]);}
}else if(adjust.lookup){
if(adjust.mode<=WSTM.o.WikiTom.TextOnly){
s=adjust.source;
if(s){
m=false;
i=s.indexOf("&");
if(i>=0){
this.re.fiat();
for(k=0;k<2;k++){
l=(k===1);
r=this.re.entities[k];
r.lastIndex=0;
do{
j=r.lastIndex;
f=r.exec(s);
if(f){
e=f[0];
if(e!==" "){
c=this.flat(e,l,true);
if(typeof c==="string"){
j=f.index;
m=j+e.length;
s=s.substr(0,j)+c+s.substr(m);
r.lastIndex=j+1;}}}
}while(f);}}
if(m){
if(adjust.source!==s){
adjust.fresh(s);}}}}}
};
WSTM.w.chr.form=function(adjust){
var c=adjust;
switch(adjust){
case 8194:
case 8195:
case 8200:
c=32;
break;
case 8206:
WSTM.w.encountered.bidichar=true;
c="‎";
break;
case 8207:
WSTM.w.encountered.bidichar=true;
c="‏";
break;
case 847:
case 8196:
case 8197:
case 8198:
case 8203:
case 8232:
case 8233:
case 8234:
case 8235:
case 8236:
case 8237:
case 8238:
c="&#x"+WSTM.str.hexcode(adjust,4,false)+";";
break;
case 8202:
c="";
break;
case 8287:
c=" ";
break;
case 8288:
c="";
break;
case 8960:
c=248;
break;
default:
if(this.fallback(c)){
if(this.detected.exchange){
if(this.detected.exchange>adjust){
this.detected.exchange=adjust;}
}else{
this.detected.exchange=adjust;}}}
return c;
};
WSTM.w.chr.format=function(adjust,around,address){
var cb=0,cf=0,r=adjust,c,i,n;
if(around){
n=around.length;
if(address>0){
cb=around.charCodeAt(address-1);
if(cb===59){
if(address>4){
i=around.lastIndexOf("&",address-2);
if(i>=0){
c=around.substr(i,address-i);
if(around.charCodeAt(i+1)===35){
c=WSTM.str.charEntityCode(c);
}else{
c=WSTM.str.charEntityHTML5single(c);
if(c){
c=this.fixed(c);}}
if(c){
cb=c;}}}}}
if(address<n-1){
cf=around.charCodeAt(address+1);
if(cf===38){
if(address<n-4){
i=around.indexOf(";",address+2);
if(i>address){
c=around.substr(address+1,i-address);
if(around.charCodeAt(address+2)===35){
c=WSTM.str.charEntityCode(c);
}else{
c=WSTM.str.charEntityHTML5single(c);
if(c){
c=this.fixed(c);}}
if(c){
cf=c;}}}}}}
if(cb!==32||(cf!==10&&cf!==32)){
if(adjust>=8544&&adjust<=8575){
if(cb<11904&&cf<11904){
switch(adjust){
case 8544:
r=73;
break;
case 8545:
r="II";
break;
case 8546:
r="III";
break;
case 8547:
r="IV";
break;
case 8548:
r=86;
break;
case 8549:
r="VI";
break;
case 8550:
r="VII";
break;
case 8551:
r="VIII";
break;
case 8552:
r="IX";
break;
case 8553:
r=88;
break;
case 8554:
r="XI";
break;
case 8555:
r="XII";
break;
case 8556:
r=76;
break;
case 8557:
r=67;
break;
case 8558:
r=68;
break;
case 8559:
r=77;
break;
case 8560:
r=105;
break;
case 8561:
r="ii";
break;
case 8562:
r="iii";
break;
case 8563:
r="iv";
break;
case 8564:
r=118;
break;
case 8565:
r="vi";
break;
case 8566:
r="vii";
break;
case 8567:
r="viii";
break;
case 8568:
r="ix";
break;
case 8569:
r=120;
break;
case 8570:
r="xi";
break;
case 8571:
r="xii";
break;
case 8572:
r=108;
break;
case 8573:
r=99;
break;
case 8574:
r=100;
break;
case 8575:
r=109;
break;}}
}else if(adjust===65279){
r="";}}
return r;
};
WSTM.w.chr.re.fiat=function(){
var s0,s1;
if(!this.entities){
s0="&#(x?[0-9A-Fa-f]+|[0-9]+);";
s1="&[A-Za-z]+[A-Za-z123]+;";
this.entities=[new RegExp(s0,"g"),new RegExp(s1,"g")];}
};
};
mw.libs.WikiSyntaxTextMod.bb.chr(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.chr;
(function(WSTM){
"use strict";
var sub="C",self=WSTM.w.chr.self,version=WSTM.w.chr.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/rC.js