Jump to content

User:PerfektesChaos/js/WikiSyntaxTextMod/rU.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/// PerfektesChaos/js/WikiSyntaxTextMod/rU.js
/// 2022-01-30 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#C327FFD1#
/// @license:CC-by-sa/4.0 GPLv3
///<nowiki>
if(typeof mediaWiki!=="object"){
mw={libs:{WikiSyntaxTextMod:{}
},log:function(){"use strict";}
};}
(function(mw){
"use strict";
var version=7.59,sign="WikiSyntaxTextMod",sub="U",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.util!=="object"){
WSTM.util={};}
WSTM.util.vsn=version;
WSTM.util.self=self;
if(typeof WSTM.bb!=="object"){
WSTM.bb={};}
if(typeof WSTM.debugging!=="object"){
WSTM.debugging={};}
}(mw));
mw.libs.WikiSyntaxTextMod.bb.utilU=function(WSTM){
"use strict";
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});
WSTM.util.fiatObjects(WSTM,"util",{code:{},date:{},dnb:{},gtin:{},isbn:{},issn:{},re:{},regexp:{},translate:{}
});
WSTM.util.isArray=function(anything){
var r=(anything!==null);
if(r){
r=(typeof anything==="object");
if(r){
r=(anything.constructor.toString().substr(0,17).indexOf("function Array()")>=0);}}
return r;
};
WSTM.util.isElement=function(array,access){
var r=false,i;
if(typeof array==="object"&&array&&typeof array.length==="number"){
for(i=0;i<array.length;i++){
if(array[i]===access){
r=true;
break;}}}
return r;
};
WSTM.util.isEscValid=function(attempt){
var i=0,r=false,s;
do{
i=attempt.indexOf("%",i);
if(i>=0){
s=attempt.substr(i+1,2);
if(s.length===2){
if(s==="00"){
r="%00";
break;}
if(typeof WSTM.util.re.hex2!=="object"){
WSTM.util.re.hex2=new RegExp("[0-9A-Fa-f][0-9A-Fa-f]");}
if(WSTM.util.re.hex2.test(s)){
i=i+2;
}else{
r="%"+s;
break;}
}else{
r="%"+s;
break;}}
}while(i>=0);
return r;
};
WSTM.util.isO_639_1=function(ask){
var s="|aa|ab|ae|af|ak|am|an|ar|as|av|ay|az|ba|be|bg|bh|bi|bm|bn|bo|br|bs|ca|ce|ch|co|cr|cs|cu|cv|cy|da|de|dv|dz|ee|el|en|eo|es|et|eu|fa|ff|fi|fj|fo|fr|fy|ga|gd|gl|gn|gu|gv|ha|he|hi|ho|hr|ht|hu|hy|hz|ia|id|ie|ig|ii|ik|io|is|it|iu|ja|jv|ka|kg|kj|kk|kl|km|kn|ko|kr|ks|ku|kv|kw|ky|la|lb|lg|li|ln|lo|lt|lv|mg|mh|mi|mk|ml|mn|mr|ms|mt|my|na|nb|nd|ne|ng|nl|nn|no|nr|nv|oc|oj|om|or|os|pa|pi|pl|ps|pt|qu|rm|rn|ro|ru|rw|sa|sc|sd|se|sg|sh|si|sk|sl|sm|sn|so|sq|sr|ss|st|su|sv|sw|ta|te|tg|th|ti|tk|tl|tn|to|tr|ts|tt|tw|ty|ug|uk|ur|uz|ve|vi|vo|wa|wo|xh|yi|yo|za|zh|zu|";
return(s.indexOf(ask)>0);
};
WSTM.util.isURL=function(attempt,allow,any){
var r=false,got,i,n,parts,s,scheme;
if(typeof this.re.whitespace!=="object"){
this.re.nonAlNum2=new RegExp("[^a-z0-9][^a-z0-9]");
this.re.all0alpha=new RegExp("^[^a-z]+$");
this.re.alphaNum=new RegExp("[a-z0-9]+");
this.re.nonAlNumBeg=new RegExp("^[^a-z0-9]");
this.re.nonAlNumEnd=new RegExp("[^a-z0-9]$");
this.re.whitespace=new RegExp("\\S\\s+\\S");
this.re.urlPort=new RegExp("^(.+):[0-9]+$");
this.re.urlProtocol=new RegExp("^(?:(https?|s?ftp):)?//.","i");
this.re.urlPunycode=new RegExp("^xn--[a-z0-9]+(-[a-z0-9]+)?$","i");}
if(this.re.whitespace.test(attempt)){
r="whitespace";
}else if(allow){
}else{
got=this.re.urlProtocol.exec(attempt);
if(got){
scheme=got[1];
if(scheme){
scheme=scheme.toLowerCase();
}else{
scheme="http";}
s=attempt.substr(got[0].length-1);
i=s.indexOf("/");
if(i>0){
s=s.substr(0,i);}
}else{
r="scheme:resource";}}
if(s&&s.indexOf(":")>0&&"http https ftp".indexOf(scheme)>=0){
got=this.re.urlPort.exec(s);
if(got){
s=got[1];
}else{
r="port";
s=false;}}
if(s&&!any){
s=s.toLowerCase();
parts=s.split(".");
n=parts.length;
if(n>1){
for(i=0;i<n;i++){
s=parts[i];
if(!this.re.alphaNum.test(s)){
if(WSTM.str.isASCII(s)){
if(s.substr(0,4)==="xn--"){
if(!this.re.urlPunycode.test(s)){
r="Punycode: "+s;}
}else if(i===n-1&&this.re.all0alpha.test(s)){
r="TLD: ."+s;
}else if(this.re.nonAlNumBeg.test(s)||this.re.nonAlNumEnd.test(s)){
r="."+s+".";
break;
}else if(this.re.nonAlNum2.test(s)){
r="."+s+".";
break;}
}else if(i===n-1){
if(!WSTM.lang.fetch("TLD.IDN").test(s)){
r="TLD (IDN): ."+s;}}}}
}else{
r="TLD-";}}
return r;
};
WSTM.util.roman2int=function(attempt){
var s=attempt.toUpperCase(),d,i,j,k,l,r;
if(typeof this.romanDigits!=="object"){
this.romanDigits={"I":1,
"V":5,
"X":10,
"L":50,
"C":100,
"D":500,
"M":1000};}
for(i=0;i<s.length;i++){
k=this.romanDigits[s.charAt(i)];
if(k){
d=d||[];
d.push(k);
}else{
d=false;
break;}}
if(d){
r=0;
j=0;
l=true;
for(i=d.length-1;i>=0;i--){
k=d[i];
if(k>j){
r=r+k;
l=true;
}else if(k<j){
r=r-k;
l=false;
}else if(l){
r=r+k;
}else{
r=r-k;}
j=k;}
r=r+"";}
return r||attempt;
};
};
mw.libs.WikiSyntaxTextMod.bb.utilU(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.utilU;
mw.libs.WikiSyntaxTextMod.bb.dating=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM.util,"date",{domax:[false,31,29,31,30,31,30,31,31,30,31,30,31],units:["era","year","month","dom","hour","minute","second","msec","mysec"],words:{doweek:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dow:{n:3},month:[false,"January","February","March","April","May","June","July","August","September","October","November","December"],mon:{n:3}},re:{}
});
WSTM.util.date.fetch=function(attempt,ahead,alien){
var s=WSTM.str.trim(attempt),got,o,r;
if(typeof this.re.yyyy!=="object"){
this.re.dd=new RegExp("^-([0-3]?[0-9])([T ].*)?$");
this.re.hh=new RegExp("^([0-2][0-9])(:.*)?$");
this.re.min=new RegExp("^:([0-5][0-9])(:.*)?$");
this.re.mon=new RegExp("^-([01]?[0-9])(-.+)?$");
this.re.ss=new RegExp("^:([0-6][0-9])([. ].*)?$");
this.re.yyyy=new RegExp("^([1-9][0-9]*)(-.+)?$");}
got=this.re.yyyy.exec(s);
if(got){
r={year:parseInt(got[1],10)};
s=got[2];
if(s){
got=this.re.mon.exec(s);
if(got){
r.month=parseInt(got[1],10);
s=got[2];
if(s){
got=this.re.dd.exec(s);
if(got){
r.dom=parseInt(got[1],10);
s=got[2];
if(s){
s=s.substr(1);}
}else{
r=false;
s=false;}
}else{
r=false;
s=false;}
}else{
r=false;}}}
if(s){
got=this.re.hh.exec(s);
if(got){
if(!r){
r={};}
r.hour=parseInt(got[1],10);
s=got[2];
if(s){
got=this.re.min.exec(s);
if(got){
r.minute=parseInt(got[1],10);
s=got[2];
if(s){
got=this.re.ss.exec(s);
if(got){
r.second=parseInt(got[1],10);
s=got[2];
}else{
r=false;}
}else{
r=false;}
}else{
r=false;}}}}
if(!r){
o=WSTM.lang.l;
if(typeof o.en==="object"&&typeof o.en.date==="object"&&typeof o.en.date.fetch==="function"){
r=o.en.date.fetch(attempt);}
if(!r&&typeof o[alien]==="object"&&typeof o[alien].date==="object"&&typeof o[alien].date.fetch==="function"){
r=o[alien].date.fetch(attempt);}}
if(r){
r=this.formal(r,ahead);}
return(r||false);
};
WSTM.util.date.fiat=function(attempt){
var ih=0,im=0,ims=0,is=0;
switch(typeof attempt.date){
case "boolean":
case "object":
break;
default:
if(typeof attempt.year==="number"&&typeof attempt.month==="number"&&typeof attempt.dom==="number"){
if(typeof attempt.hour==="number"){
ih=attempt.hour;
if(typeof attempt.minute==="number"){
im=attempt.minute;
if(typeof attempt.second==="number"){
is=attempt.second;
if(typeof attempt.msec==="number"){
ims=attempt.msec;
if(typeof attempt.mysec==="number"){
ims=ims+0.001*attempt.mysec;}}}}}
attempt.date=new Date(attempt.year,attempt.month-1,attempt.dom-1,ih,im,is,ims);
}else{
attempt.date=false;}}
return attempt.date;
};
WSTM.util.date.fill=function(at,assembly){
var m,min,r,s;
if(typeof at.monAbbr==="object"){
if(typeof at.monAbbr.n==="number"){
min=at.monAbbr.n;}
for(m in at.monAbbr){
if(typeof this.re!=="object"){
this.re={};}
if(typeof this.re.digits!=="object"){
this.re.digits=new RegExp("^\\d+$");}
if(typeof m==="number"||this.re.digits.test(m)){
s=at.monAbbr[m].toLowerCase();
assembly[s]=m;
r=true;}}}
if(typeof at.monFull==="object"){
for(m in at.monFull){
s=at.monFull[m].toLowerCase();
assembly[s]=m;
r=true;
if(min&&s.length>min){
s=s.substr(0,min);
assembly[s]=m;}}}
return r;
};
WSTM.util.date.filler=function(at){
var o={},live=this.fill(at,o),i,l,x;
if(typeof at.consider==="object"){
for(i=0;i<at.consider.length;i++){
x=WSTM.lang.l[at.consider[i]];
if(typeof x==="object"&&typeof x.date==="object"){
l=this.fill(x.date,o);
live=(live||l);}}}
if(live){
at.greg12={};
for(x in o){
i=o[x];
switch(typeof i){
case "number":
at.greg12[x]=i;
break;
case "string":
at.greg12[x]=parseInt(i,10);
break;}}
}else{
at.greg12=null;}
};
WSTM.util.date.find=function(attempt,at){
var r,s;
if(typeof at.greg12!=="object"){
this.filler(at);}
if(at.greg12){
s=attempt.toLowerCase();
if(typeof at.greg12[s]==="number"){
r=at.greg12[s];}}
return(r||false);
};
WSTM.util.date.formal=function(attempt,ahead){
var r=attempt,j,m,n;
if(r){
if(typeof r.year==="number"){
j=r.year;
this.further(r);
}else{
r.year=false;}}
if(r){
if(typeof r.month==="number"){
m=r.month;
if(m<1||m>12){
r=false;}
}else{
r.month=false;}}
if(r){
if(typeof r.dom==="number"){
n=r.dom;
if(n>0&&n<=31){
if(m){
if(n>this.full(r)){
r=false;}
}else if(j){
r=false;}
}else{
r=false;}
}else{
r.dom=false;}}
if(r){
if(typeof r.hour==="number"){
if(r.hour<0||r.hour>23){
r=false;}
}else{
r.hour=false;}}
if(r){
if(typeof r.minute==="number"){
if(r.minute<0||r.minute>59){
r=false;}
}else{
r.minute=false;}}
if(r){
if(typeof r.second==="number"){
if(r.second<0||r.second>60){
r=false;
}else{
if(typeof r.minute==="number"){
if(r.second===60&&r.minute!==59){
r=false;}
}else if(typeof r.hour==="number"){
r=false;}}
}else{
r.second=false;}}
if(r&&ahead&&j&&m&&n){
if(typeof this.current!=="object"){
this.current=new Date();}
if(j>this.current.getUTCFullYear()){
r=false;
}else if(j===this.current.getUTCFullYear()&&m>this.current.getUTCMonth()){
if(m>this.current.getUTCMonth()+1||n>this.current.getUTCDate()){
r=false;}}}
return(r||false);
};
WSTM.util.date.format=function(attempt,apply){
var r="",f,n,o;
switch(typeof apply){
case "number":
r=this.formatISO(attempt,apply);
break;
case "object":
if(apply){
o=WSTM.lang.l;
if(typeof o[apply[0]]==="object"){
o=o[apply[0]];
if(apply[1]&&typeof o[apply[1]]==="object"&&typeof o[apply[1]].date==="object"&&typeof o[apply[1]].date.format==="function"){
f=o[apply[1]].date.format;
}else if(typeof o.date==="object"&&typeof o.date.format==="function"){
f=o.date.format;}}
if(typeof apply[3]==="number"){
n=apply[3];}}
break;
case "string":
r=this.formatPHP(attempt,apply);
break;}
if(f){
r=f(attempt,apply [2],n);
}else if(!r){
r=this.formatISO(attempt,n);}
return r;
};
WSTM.util.date.formatISO=function(attempt,amount){
var r="",i,k,n,o;
if(attempt.year){
r=""+attempt.year;
n=4-r.length;
if(n){
r=WSTM.str.makeString(48,n)+r;}
if(typeof this.isoFormat!=="object"){
this.isoFormat={month:{n:10,sep:"-"},dom:{n:10,sep:"-"},hour:{n:10,sep:" "},minute:{n:10,sep:":"},second:{n:10,sep:":"},msec:{n:100,sep:"."},mysec:{n:100,sep:""}
};}
k=(typeof amount==="number"?amount:this.units.length);
for(i=2;i<=k;i++){
o=this.units[i];
n=attempt[o];
if(typeof n==="number"){
o=this.isoFormat[o];
r=r+o.sep;
if(n<o.n){
r=r+"0";
if(o.n===100&&n<10){
r=r+"0";}}
r=r+n;
}else{
break;}}}
return r;
};
WSTM.util.date.formatPHP=function(attempt,apply,assign){
var r="",i,n,o,s,v;
if(typeof this.phpCodes!=="object"){
this.phpCodes={Y:{s:"year",n:4},y:{s:"year",n:2,m:2},L:true,M:{s:"month",o:"mon"},F:{s:"month",o:"month"},m:{s:"month",n:1},n:{s:"month",n:2},t:true,W:true,z:true,j:{s:"dom",n:1},d:{s:"dom",n:2},D:true,l:true,w:true,N:true,G:{s:"hour",n:1},H:{s:"hour",n:2},g:true,h:true,a:true,A:true,i:{s:"minute",n:2},s:{s:"second",n:2},c:true,r:true,U:true,e:true,I:true,O:true,P:true,T:true,Z:true,'"':true};}
for(i=0;i<=apply.length;i++){
s=apply.substr(i,1);
switch(typeof this.phpCodes[s]){
case "object":
o=this.phpCodes[s];
if(typeof o.s==="string"){
if(typeof attempt[o.s]==="number"){
v=attempt[o.s];
if(typeof o.n==="number"){
switch(o.n){
case 2:
if(typeof o.m==="number"){
if(v<100){
if(v<10){
v="0"+v;}
}else{
v=WSTM.str.substrEnd(""+v,2);}
}else{
if(v<10){
v="0"+v;}}
break;
case 4:
if(v<1000){
v=WSTM.str.substrEnd("000"+v,4);}
break;}
}else if(typeof o.o==="string"){
v=this.furnish(v,o.o,assign);}
r=r+v;}}
break;
case "boolean":
switch(s){
case '"':
i++;
n=apply.indexOf('"',i);
if(n<0){
r=r+apply.substr(i);
i=apply.length;
}else{
r=r+apply.substring(i,n);
i=n;}
break;
case "A":
case "a":
if(typeof attempt.hour==="number"){
if(attempt.hour>12){
v="PM";
}else{
v="AM";}
if(s==="a"){
v=v.toLowerCase();}
r=r+v;}
break;
case "c":
r=r+this.formatISO(attempt);
break;
case "D":
case "l":
case "N":
case "w":
if(this.fiat(attempt)){
v=attempt.date.getDay();
switch(s){
case "D":
v=this.furnish(v,"dow",assign);
break;
case "l":
v=this.furnish(v,"doweek",assign);
break;
case "N":
if(!v){
v=7;}
break;
case "w":
break;}
r=r+v;}
break;
case "e":
case "I":
case "O":
case "P":
case "T":
case "Z":
if(this.fiat(attempt)){
v=attempt.date.getTimezoneOffset();
switch(s){
case "e":
case "T":
if(!v){
v="UTC";
break;}
case "O":
case "P":
o=(v<0);
if(o){
v=v*-1;}
n=v%60;
v=v-n*60;
if(n<10){
n="0"+n;}
if(v<10){
v="0"+v;}
if(s==="P"){
v=":"+v;}
v=n+v;
if(o){
v="-"+v;
}else{
v="+"+v;}
break;
case "I":
v="0";
break;
case "Z":
v=v*60;
break;}
r=r+v;}
break;
case "g":
case "h":
if(typeof attempt.hour==="number"){
v=(attempt.hour>12?attempt.hour-12:attempt.hour);
if(s==="h"&&v<10){
v="0"+v;}
r=r+v;}
break;
case "L":
r=r+(this.further(attempt)?"1":"0");
break;
case "r":
r=r+this.formatPHP(attempt,"D, j M Y H:i:s O");
break;
case "t":
r=r+this.full(attempt);
break;
case "U":
if(this.fiat(attempt)){
r=r+attempt.date.getTime()*1000;}
break;
case "W":
case "z":
if(typeof attempt.month==="number"&&typeof attempt.dom==="number"){
v=attempt.dom-1;
if(attempt.month===2){
v+=31;}
if(typeof attempt.year==="number"){
if(attempt.month>2){
for(n=attempt.month-1;
n===2;
n--){
v+=this.domax[n];}
this.fiat(attempt);
if(!attempt.leap){
v--;}}
if(s==="W"){
if(typeof attempt.jan1!=="number"){
o=new Date(attempt.year,0,0);
attempt.jan1=o.getDay();}
if(attempt.jan1<4){
v-=attempt.jan1;}
v=Math.ceil(++v / 7);}
r=r+v;
}else if(s==="z"&&attempt.month<=2){
r=r+v;}}
break;}
break;
default:
r=r+s;}}
return r;
};
WSTM.util.date.full=function(attempt){
var r=0,m;
if(typeof attempt.month==="number"){
m=attempt.month;
if(m>=1&&m<=12){
r=this.domax[m];
if(m===2){
this.further(attempt);
if(!attempt.leap){
r=28;}}}}
return r;
};
WSTM.util.date.furnish=function(at,as,assign,again){
var o,r,s;
if(typeof assign==="object"&&typeof assign[as]==="object"){
o=assign[as];
if(typeof o.length==="number"){
r=o[at];
}else if(as.length===3&&typeof o.n==="number"){
s=(as==="mon"?"month":"doweek");
if(typeof assign[s]==="object"&&typeof assign[s][at]==="string"){
r=assign[s][at].substr(0,o.n);
if(typeof o.suffix==="string"){
r=r+o.suffix;}}}}
if(!r){
if(again){
r="<"+at+">";
}else{
r=this.furnish(at,as,this.words,true);}}
return r;
};
WSTM.util.date.further=function(attempt){
var r,j;
if(typeof attempt.leap==="boolean"){
r=attempt.leap;
}else{
r=false;
if(typeof attempt.year==="number"&&(typeof attempt.bc==="undefined"||!attempt.bc)){
j=attempt.year;
if(j>0&&j<=2100){
if(!j%4&&(j%100||!j%400)){
r=true;}}}
attempt.leap=r;}
return r;
};
};
mw.libs.WikiSyntaxTextMod.bb.dating(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.dating;
mw.libs.WikiSyntaxTextMod.bb.idcodes=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM.util,"code",{re:{}});
WSTM.util.code.fetch=function(attempt,amount,allowX,about){
var k=0,n=attempt.length,r=new Array(amount),c,i;
for(i=0;i<n;i++){
c=attempt.charCodeAt(i);
if(c>=48&&c<=57){
c-=48;
if(k<amount){
r[k]=c;
}else{
r=false;
WSTM.errors.found("badCodeDigitcount",false,about+": "+attempt);
break;}
k++;
}else if(c===88||c===120){
if(allowX&&i===n-1){
if(allowX===true||allowX===k+1){
r[k]=10;
k++;
}else{
r=false;}
}else{
r=false;}
if(!r){
WSTM.errors.found("badCodeX",false,about+": "+attempt);}
break;
}else if(c!==32&&c!==45){
c=String.fromCharCode(c);
if(WSTM.str.sticks.indexOf(c)<0&&WSTM.str.spaces.indexOf(c)<0){
r=false;
WSTM.errors.found("badCodeChar",false,about+": "+attempt);
break;}}}
if(r){
if(k<amount){
r.splice(k,amount-k);}}
return r;
};
WSTM.util.code.dnb=function(adjust){
return WSTM.util.dnb.failure(adjust,"DNB");
};
WSTM.util.code.doi=function(adjust,allow){
return WSTM.util.doi.format(adjust,allow);
};
WSTM.util.code.ean=function(adjust){
return WSTM.util.gtin.format(adjust,"EAN");
};
WSTM.util.code.gnd=function(adjust){
return WSTM.util.dnb.failure(adjust,"GND",8,false);
};
WSTM.util.code.gtin=function(adjust){
return WSTM.util.gtin.format(adjust,"GTIN");
};
WSTM.util.code.isbn=function(adjust,accept){
return WSTM.util.isbn.format(adjust,(accept?accept:false));
};
WSTM.util.code.issn=function(adjust){
return WSTM.util.issn.format(adjust);
};
WSTM.util.code.lang=function(adjust){
var r=WSTM.str.trim(adjust),parts=r.split("-"),s;
r=parts[0].toLowerCase();
switch(r.length){
case 2:
if(!WSTM.util.isO_639_1(r)){
r=false;}
break;
case 3:
if(typeof WSTM.util.code.re.baselang!=="object"){
WSTM.util.code.re.baselang=new RegExp("^[a-z]+$");}
if(!WSTM.util.code.re.baselang.test(r)){
r=false;}
break;
default:
r=false;}
if(r){
if(parts.length>1){
if(parts.length===2){
s=parts[1];
if(typeof WSTM.util.code.re.baselang!=="object"){
WSTM.util.code.re.baselang=new RegExp("^[a-z]+$");}
if(WSTM.util.code.re.baselang.test(r)){
switch(s.length){
case 2:
s=s.toUpperCase();
break;
case 4:
s=WSTM.str.capitalize(s);
break;
default:
s=false;}
}else{
s=false;}
if(s){
r=r+"-"+s;
}else{
r=[adjust,"Invalid; bad subset ID"];}
}else{
r=[adjust,"Invalid; too many hyphens"];}}
if(r===adjust){
r=false;}
}else{
r=[adjust,"Invalid; bad ID"];}
return r;
};
WSTM.util.code.lccn=function(adjust,apply){
return WSTM.util.lccn.format(adjust,apply);
};
WSTM.util.code.pmc=function(adjust){
if(typeof WSTM.util.code.re.pmc!=="object"){
WSTM.util.code.re.pmc=new RegExp("^[1-9][0-9]{4,9}$");}
return(!WSTM.util.code.re.pmc.test(adjust));
};
WSTM.util.code.pmid=function(adjust){
if(typeof WSTM.util.code.re.pmid!=="object"){
WSTM.util.code.re.pmid=new RegExp("^[1-9]([0-9]{1,9})?$");}
return(!WSTM.util.code.re.pmid.test(adjust));
};
WSTM.util.code.urn=function(adjust){
return WSTM.util.urn.failure(adjust);
};
WSTM.util.code.viaf=function(adjust){
if(typeof WSTM.util.code.re.viaf!=="object"){
WSTM.util.code.re.viaf=new RegExp("^[1-9][0-9]{3,13}$");}
return(!WSTM.util.code.re.viaf.test(adjust));
};
WSTM.util.code.zdb=function(adjust){
return WSTM.util.dnb.failure(adjust,"ZDB",4,true);
};
};
mw.libs.WikiSyntaxTextMod.bb.idcodes(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.idcodes;
mw.libs.WikiSyntaxTextMod.bb.dnb=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM.util,"dnb");
WSTM.util.dnb.failure=function(attempt,about,amount,alt){
var j=attempt.indexOf("/"),dnb,s,r;
if(j>0){
s=attempt.substr(0,j);
}else{
s=attempt;}
dnb=WSTM.util.code.fetch(s,11,true,about);
if(dnb){
j=dnb.length;
if(amount&&j<=amount){
r=amount;}
if(!r&&typeof alt==="boolean"){
if(attempt.indexOf("-")<0){
r=alt;
}else{
r=(!alt);}}
if(!r&&j<=8){
if(typeof WSTM.util.re.dnbX!=="object"){
WSTM.util.re.dnbX=new RegExp("^[1-9][0-9]{3,6}-[0-9xX]$");}
if(WSTM.util.re.dnbX.test(s)){
r=((11-this.faith(dnb))%11!==dnb[j-1]);
j=false;
}else{
r=true;}}
if(!r&&j&&!alt){
r=(this.faith(dnb)!==dnb[j-1]);}
}else{
r=true;}
return r;
};
WSTM.util.dnb.faith=function(assert){
var n=assert.length,k=n,r=0,i;
n--;
for(i=0;i<n;i++){
r=r+k*assert[i];
k=k-1;}
r=(11-r%11)%11;
return r;
};
};
mw.libs.WikiSyntaxTextMod.bb.dnb(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.dnb;
mw.libs.WikiSyntaxTextMod.bb.doi=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM.util,"doi");
WSTM.util.doi.failure=function(attempt){
var r=this.format(attempt,false),s;
if(r){
s=attempt.replace(/&(#x200[9A-F]|lrm|rlm|zwn?j);/,"");
if(s!==attempt){
r=s;}}
return r;
};
WSTM.util.doi.format=function(adjust,allow){
var r=false,i,s;
if(adjust.substr(0,3)==="10."){
s=adjust.substr(3);
i=s.indexOf("/");
if(i>3){
if(typeof this.re!=="object"){
this.re={};
this.re.org=new RegExp("^[1-9][0-9]{3,7}$","");
this.re.doi="-0-9/A-Z.a-z()_;,:";
this.re.iw=new RegExp("^["+this.re.doi+"&#]{3,}$","");
this.re.doi=new RegExp("^[/0-9.A-Za-z(<](?:["+this.re.doi+"<>]+|\\[|\\])+"+"[0-9A-Za-z#+)]$","");}
if(this.re.org.test(s.substr(0,i))){
s=s.substr(i+1);
if(!allow){
if(!this.re.iw.test(s)){
r="invalid character in ID: "+adjust;}}
if(!r){
s=WSTM.str.decodeXML(s);
if(!this.re.doi.test(s)){
r="bad selector '"+s+"'";}}
}else{
r="bad number '"+s.substr(0,i)+"'";}
}else{
r="missing '/'";}
}else{
r="leading '10.' missing";}
return(r?[false,r]:false);
};
};
mw.libs.WikiSyntaxTextMod.bb.doi(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.doi;
mw.libs.WikiSyntaxTextMod.bb.gtin=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM.util,"gtin");
WSTM.util.gtin.faith=function(assert){
var lead=true,r=0,i,k;
for(i=0;i<12;i++){
k=assert[i];
r+=k;
if(lead){
lead=false;
}else{
r+=k+k;
lead=true;}}
r=(10-r%10)%10;
return r;
};
WSTM.util.gtin.fashion=function(acquired){
var r="",i;
for(i=0;i<4;i++){
r=r+String.fromCharCode(acquired[i]+48);}
r=r+"-";
for(i=4;i<12;i++){
r=r+String.fromCharCode(acquired[i]+48);}
r=r+"-"+String.fromCharCode(acquired[12]+48);
return r;
};
WSTM.util.gtin.format=function(attempt,about){
var r=WSTM.util.code.fetch(attempt,13,false,"GTIN");
if(r){
if(r.length===13){
if(this.faith(r)===r[12]){
if(attempt.indexOf("-")>0){
r=WSTM.str.trim(attempt);
if(r===attempt){
r=false;}
}else{
r=this.fashion(r);}
}else{
r=false;
WSTM.errors.found("badCodeCheckdig",false,about+": "+attempt);}
}else{
r=false;
WSTM.errors.found("badCodeDigitcount",false,about+": "+attempt);}}
return r;
};
};
mw.libs.WikiSyntaxTextMod.bb.gtin(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.gtin;
mw.libs.WikiSyntaxTextMod.bb.isbn=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM.util,"isbn");
WSTM.util.isbn.grouping=false;
WSTM.util.isbn.factory=function(attribute){
return "(^|"+(attribute?"\\W":"[ \n]")+")(ISBN)(?:(?:["+WSTM.str.sticks+" ]?(10|13):?)?) *(?::? *|&nbsp;|&#160;|(=))? *["+WSTM.str.sticks+"]?([0-9](?:["+WSTM.str.sticks+" .0-9]|&nbsp;|&#160;)+"+"[0-9X])"+"([ -.]*[^"+WSTM.str.sticks+". 0-9X]|\\.? *$)";
};
WSTM.util.isbn.faith=function(attempt,amount){
var d=new Array(amount),k=0,n=attempt.length,r=-1,c,i;
for(i=0;i<n;i++){
c=attempt.charCodeAt(i);
if(c>=48&&c<=57){
d[k]=c-48;
k++;
}else if(c!==32&&c!==45){
r=-2;
i=n+1;}}
if(i===n){
if(amount===13){
if(k===12){
r=WSTM.util.gtin.faith(d);
}else{
r=-3;}
}else{
if(k===9){
k=0;
for(i=0;i<9;i++){
k+=(i+1)*d[i];}
r=k%11;
if(r===10){
r=40;}
}else{
r=-3;}}}
return r;
};
WSTM.util.isbn.fault=function(alert,about,another){
if(typeof another==="function"){
another.call(null,alert,about);
}else{
WSTM.errors.found(alert,false,about);}
};
WSTM.util.isbn.flip=function(adjust,another){
var g=this.format(adjust,false,another),r=false,n,s;
if(typeof g[0]==="number"){
s=(g[1]?g[1]:adjust).replace(/-/g,"");
n=s.length;
s=s.substr(0,n-1);
if(n===10){
n=13;
s="978"+s;
}else{
n=10;
s=s.substr(3);}
n=this.faith(s,n);
if(n>=0){
s=s+(n===40?"X":n);
g=this.format(s,false,false);
r=g[1];}}
return r;
};
WSTM.util.isbn.fold=function(ahead,area,adjust){
var f=this.grouping[(ahead?1:0)],id=area,j=adjust.indexOf("-"),r=false,s=adjust,d,g,i,n,k,m;
if(j<0){
j=false;
}else{
if(!j){
s=adjust.substr(1);
j=false;
}else{
s=s.substr(0,j)+s.substr(j+1);}
k=s.indexOf("-");
while(k>=0){
s=s.substr(0,k)+s.substr(k+1);
k=s.indexOf("-");
j=false;}}
if(f){
n=f.length;
for(i=0;i<n;i++){
g=f[i];
m=g[0];
if(m===area){
f=false;
break;}}
if(f){
s=area+s;
for(i=0;i<n;i++){
g=f[i];
m=g[0];
if(m<10){
k=1;
}else if(m<100){
k=2;
}else if(m<1000){
k=3;
}else if(m<10000){
k=4;
}else{
k=5;}
if(m===parseInt(s.substr(0,k),10)){
id=m;
s=s.substr(k);
f=false;
break;}}}
if(!f){
n=g.length;
for(i=1;i<n;i++){
f=g[i];
k=parseInt(s.substr(0,f[0]),10);
for(m=1;m<f.length;m++){
d=f[m];
if(k>=d[0]&&k<=d[1]){
r=d[2];
n=-1;
break;}}}}}
if(r){
if(j){
if(j===r&&id===area){
r=false;}}
if(r){
g=s.substr(r);
r=id+"-"+s.substr(0,r);
if(g){
r=r+"-"+g;}}}
return r;
};
WSTM.util.isbn.format=function(adjust,ask,another){
var chain=false,i=0,impact=0,last=false,lazy=false,loop=true,max=(ask?ask:13),n=adjust.length,naked=0,r=[false,false],shift="",scope="",c,j,lead,lean,slang,swap;
while(loop){
c=adjust.charCodeAt(i);
lead=(c>=48&&c<=57);
if(lead){
if(last){
impact=1;
this.fault("badISBNdigitAfterX",adjust.substr(0,i+1),another);}
}else{
switch(c){
case 32:
case 46:
case 173:
case 8208:
case 8209:
case 8210:
case 8211:
case 8212:
case 8213:
case 8259:
case 8722:
case 9472:
case 38:
lazy=true;
case 45:
if(c===38){
swap=adjust.substr(i,6);
if(swap==="&nbsp;"||swap==="&#160;"||
swap==="&#xA0;"||swap==="&#xa0;"){
i+=5;
}else{
loop=false;}}
if(chain){
if(naked<max){
shift=shift+"-";}
chain=false;
}else if(naked===max){
if(c===45){
impact=2;
this.fault("badISBNhyphenAfterEnd",adjust.substr(0,i+1),another);
}else if(!lazy){
loop=false;}}
break;
case 88:
case 120:
if(last){
impact=3;
this.fault("badISBNmultipleX",adjust.substr(0,i+1),another);
}else{
last=true;
if(ask){
lead=(naked===ask-1);
}else{
lead=(naked===9);}
if(lead){
c=88;
}else{
impact=4;
this.fault("badISBNXbadPosition",adjust.substr(0,i+1),another);}}
break;
default:
loop=false;
break;}}
if(lead){
if(!impact){
if(naked===max){
impact=5;
this.fault("badISBNtooManyDigits1",adjust.substr(0,i+1),another);
}else{
c=String.fromCharCode(c);
naked++;
shift=shift+c;
scope=scope+c;
chain=true;}}}
if(impact>0){
loop=false;}
if(loop){
i++;
loop=(i<n);}}
if(!impact){
if(ask){
if(naked!==ask){
impact=6;
this.fault("badISBNtooManyDigits2",adjust.substr(0,i+1),another);}
}else if(naked!==10&&naked!==13){
impact=7;
this.fault("badISBNcountingDigits","["+naked+"] "+adjust.substr(0,i+1),another);}
if(!impact){
if(naked===13){
j=shift.indexOf("-");
while(j>0&&j<3){
shift=shift.substr(0,j)+shift.substr(j+1);
j=shift.indexOf("-");}
c=shift.substr(0,3);
if(c!=="978"&&c!=="979"){
impact=8;
this.fault("badISBN13bookland",adjust.substr(0,i+1),another);
}else if(shift.substr(3,1)!=="-"){
shift=shift.substr(0,3)+"-"+shift.substr(3);}}
}else if(naked<5){
impact=-1;}}
if(!impact){
lean=(naked===13);
if(lean){
lead=(shift.charCodeAt(2)===57);
}else{
lead=false;}
j=shift.length;
n=j;
j--;
if(shift.charCodeAt(j)===45){
n--;
j--;
shift=shift.substr(0,n);}
c=this.faith(shift.substr(0,j),naked);
if(c<0){
impact=8-c;
switch(c){
case-1:
shift="badISBNcheckdigEmpty";
break;
case-2:
shift="badISBNcheckdigChar";
break;
case-3:
shift="badISBNcheckdigLength";
break;}
this.fault(shift,adjust.substr(0,i+1),another);
}else if(c!==shift.charCodeAt(j)-48){
impact=12;
this.fault("badISBNcheckdigWrong",adjust.substr(0,i+1),another);}}
if(!impact){
c=WSTM.str.substrEnd(shift,1);
if(lean){
if(shift.substr(3,1)!=="-"){
shift=shift.substr(0,3)+"-"+shift.substr(3);
n++;}}
if(shift.substr(n-2,1)!=="-"){
shift=shift.substr(0,n-1)+"-"+c;}
slang=shift.substr((lean?4:0));
slang=slang.substr(0,slang.length-2);
j=slang.indexOf("-");
while(j>0){
slang=slang.substr(0,j)+slang.substr(j+1);
j=slang.indexOf("-");}
n=1;
c=Number(slang.substr(0,1));
if(c===1){
if(lead&&slang.substr(1,1)==="0"){
n=2;
c=10;}
}else if(c===6){
n=-1;
c=false;
}else if(c>=8){
n=2;
c=Number(slang.substr(0,n));
if(c>94){
n=3;
c=Number(slang.substr(0,n));
if(c>989){
n=4;
c=Number(slang.substr(0,n));
if(c>9989){
n=5;
c=Number(slang.substr(0,n));}}}}
if(n>0){
swap=slang.substr(n);
if(lean){
scope=shift.substr(0,3)+"-";
n+=4;
}else{
scope="";}
if(!this.grouping){
this.furnish();}
swap=this.fold(lead,c,swap);
if(swap){
shift=scope+swap+WSTM.str.substrEnd(shift,2);
}else{
if(scope+c+"-"!==shift.substr(0,n)){
if(shift.charCodeAt(n)===45){
n++;}
shift=scope+c+"-"+shift.substr(n);}}}
r[0]=i;
if(shift!==adjust.substr(0,i)){
r[1]=shift;}
}else{
r[1]=impact;}
return r;
};
WSTM.util.isbn.furnish=function(){
this.grouping=[
[
[0,[2,[0,19,2],[20,69,3],[70,84,4],[85,89,5],[90,94,6],[95,99,7]]
],[1,[2,[0,9,2],[10,39,3],[40,54,4],[55,85,5]],[4,[8600,8697,5],[8698,9989,6],[9990,9999,7]]
],[2,[2,[0,19,2],[20,34,3],[35,39,5],[40,69,3],[70,83,4],[84,89,5],[90,94,6],[95,99,7]]
],[3,[2,[0,0,2],[5,19,2],[20,69,3],[70,84,4],[85,89,5],[90,94,6],[96,96,5],[97,98,7],[99,99,5]],[3,[34,36,4],[37,39,5],[950,953,7],[954,969,5]]
],[4,[2,[0,19,2],[20,69,3],[70,84,4],[85,89,5],[90,94,6],[95,99,7]]
],[5,[2,[0,19,2],[20,41,3],[45,69,3],[70,84,4],[85,89,5],[90,90,6],[91,91,5],[92,92,4],[93,94,5],[96,97,7],[98,98,5]],[3,[420,420,3],[421,429,4],[430,430,3],[431,439,4],[440,440,3],[441,449,4],[990,990,7],[991,999,4]],[4,[9500,9500,7],[9501,9599,4]]
],[7,[2,[0,9,2],[10,49,3],[50,79,4],[80,89,5],[90,99,6]]
],[80,[2,[0,19,2],[20,69,3],[70,84,4],[85,89,5],[90,99,6]]
],[81,[2,[0,19,2],[20,69,3],[70,84,4],[85,89,5],[90,99,6]]
],[82,[2,[0,19,2],[20,69,3],[70,89,4],[90,98,5],[99,99,6]]
],[83,[2,[0,19,2],[20,59,3],[60,69,5],[70,84,4],[90,99,6]]
],[84,[2,[0,14,2],[15,19,5],[20,69,3],[70,84,4],[85,89,5],[90,91,4],[93,94,6],[95,96,5],[97,99,4]],[3,[920,923,6],[924,929,5]]
],[85,[2,[0,19,2],[20,59,3],[60,69,5],[70,84,4],[85,89,5],[90,98,6],[98,99,5]]
],[86,[2,[0,29,2],[30,59,3],[60,79,4],[80,89,5],[90,99,6]]
],[87,[2,[0,29,2],[40,64,3],[70,79,4],[85,94,5],[97,99,6]]
],[88,[2,[0,19,2],[20,59,3],[60,84,4],[85,89,5],[90,94,6],[95,99,5]]
],[89,[2,[0,24,2],[25,54,3],[55,84,4],[85,94,5],[95,99,6]]
],[90,[2,[0,19,2],[20,49,3],[50,69,4],[70,79,5],[80,84,6],[85,89,4],[90,90,2],[91,93,6],[94,94,2],[95,99,6]]
],[91,[2,[0,1,1],[20,49,2],[50,64,3],[70,79,4],[85,94,5],[97,99,6]]
],[92,[2,[0,5,1],[60,79,2],[80,89,3],[90,94,4],[95,98,5],[99,99,6]]
],[94,[1,[0,5,3],[6,8,4],[9,9,5]]
],[600,[2,[0,9,2],[10,49,3],[50,89,4],[90,99,5]]
],[601,[2,[0,19,2],[20,69,3],[70,79,4],[80,84,5],[85,99,2]]
],[602,[2,[0,19,2],[20,79,3],[80,94,4],[95,99,5]]
],[603,[2,[0,4,2],[50,79,3],[80,89,4],[90,99,5]]
],[604,[2,[0,4,1],[50,89,2],[90,97,3],[98,99,4]]
],[605,[2,[0,9,2],[10,39,3],[40,59,4],[60,89,5]]
],[950,[2,[0,49,2],[50,89,3],[90,98,4],[99,99,5]]
],[951,[2,[0,1,1],[20,54,2],[55,88,3],[89,94,4],[95,99,5]]
],[952,[2,[0,19,2],[20,49,3],[50,59,4],[60,65,2],[66,66,4],[67,69,5],[70,79,4],[80,94,2],[95,98,4],[99,99,5]]
],[953,[2,[0,0,1],[10,14,2],[15,54,3],[55,59,5],[60,94,4],[95,99,5]]
],[954,[2,[0,20,2],[30,79,3],[80,89,4],[90,92,5],[93,99,4]]
],[955,[2,[0,0,1],[10,19,4],[20,54,2],[55,79,3],[80,94,4],[95,99,5]]
],[956,[2,[0,19,2],[20,69,3],[70,99,4]]
],[957,[2,[0,2,2],[3,4,4],[5,19,2],[20,20,4],[21,27,2],[28,30,5],[31,43,2],[44,81,3],[82,96,4],[97,99,5]]
],[958,[2,[0,59,2],[60,79,3],[80,94,4],[95,99,5]]
],[959,[2,[0,19,2],[20,69,3],[70,84,4]]
],[960,[2,[0,19,2],[20,65,3],[66,68,4],[69,69,3],[70,84,4],[85,92,5],[93,93,2],[94,97,4],[98,99,5]]
],[961,[2,[0,19,2],[20,59,3],[60,89,4],[90,99,5]]
],[962,[2,[0,19,2],[20,69,3],[70,84,4],[85,86,5],[87,89,4],[90,99,3]]
],[963,[2,[0,19,2],[20,69,3],[70,84,4],[85,89,5],[90,99,4]]
],[964,[2,[0,14,2],[15,24,3],[25,29,4],[30,54,3],[55,89,4],[90,96,5],[97,98,3],[99,99,4]]
],[965,[2,[0,19,2],[20,59,3],[70,79,4],[90,99,5]]
],[966,[2,[0,19,2],[20,29,4],[30,69,3],[70,89,4],[90,99,5]]
],[967,[2,[0,29,2],[30,49,3],[50,59,4],[60,89,2],[90,98,4]],[3,[990,989,4],[999,999,5]]
],[968,[2,[0,39,2],[40,49,3],[50,79,4],[80,89,5],[90,99,4]]
],[969,[2,[0,1,1],[20,39,2],[40,79,3],[80,99,4]]
],[970,[2,[0,59,2],[60,89,3],[90,90,4],[91,96,5],[97,99,4]]
],[971,[2,[0,1,3],[2,2,2],[3,5,4],[6,49,2],[50,84,3],[85,90,4],[91,99,5]]
],[972,[2,[0,1,1],[20,54,2],[55,79,3],[80,94,4],[95,99,5]]
],[973,[2,[0,0,1],[10,16,3],[17,19,4],[20,54,2],[55,75,3],[76,84,4],[85,88,5],[89,94,4],[95,99,5]]
],[974,[2,[0,19,2],[20,69,3],[70,84,4],[85,94,5],[95,99,4]]
],[975,[2,[0,0,5],[1,24,2],[25,59,3],[60,91,4],[92,98,5],[99,99,3]]
],[976,[2,[0,30,1],[40,59,2],[60,79,3],[80,94,4],[95,99,5]]
],[977,[2,[0,19,2],[20,49,3],[50,69,4],[70,99,3]]
],[978,[2,[0,19,3],[20,29,4],[30,79,5],[80,89,4],[90,99,3]]
],[979,[2,[0,9,3],[10,14,4],[15,19,5],[20,29,2],[30,39,4],[40,79,4],[95,99,5]]
],[980,[2,[0,19,2],[20,59,3],[60,99,4]]
],[981,[2,[0,19,2],[20,29,3],[30,99,4]]
],[982,[2,[0,9,2],[10,69,3],[70,89,2],[90,99,4]]
],[983,[2,[0,1,2],[2,19,3],[20,39,4],[40,44,5],[45,79,2],[80,89,3],[90,98,4],[99,99,5]]
],[984,[2,[0,39,2],[40,79,3],[80,89,4],[90,99,5]]
],[985,[2,[0,39,2],[40,59,3],[60,89,4],[90,99,5]]
],[986,[2,[0,11,2],[12,55,3],[56,79,4],[80,99,5]]
],[987,[2,[0,9,2],[10,19,4],[20,29,5],[30,49,2],[50,89,3],[90,94,4],[95,99,5]]
],[988,[2,[0,16,2],[17,19,5],[20,79,3],[80,96,4],[97,99,5]]
],[989,[2,[0,19,1],[20,54,2],[55,79,3],[80,94,4],[95,99,5]]
],[9937,[2,[0,29,1],[30,49,2],[50,79,3],[80,99,4]]
],[9938,[2,[0,79,2],[80,94,3],[95,99,4]]
],[9939,[2,[0,49,1],[50,79,2],[80,89,3],[90,99,4]]
],[9940,[2,[0,19,1],[20,49,2],[50,89,3],[90,99,4]]
],[9941,[2,[0,9,1],[10,39,2],[40,89,3],[90,99,4]]
],[9942,[3,[0,899,2],[900,994,3],[995,999,4]]
],[9943,[2,[0,29,2],[30,39,3],[40,99,4]]
],[9944,[2,[0,29,2],[30,49,3],[50,59,4],[60,89,2],[90,99,3]]
],[9945,[2,[0,0,2],[1,7,3],[8,39,2],[40,56,3],[57,57,2],[58,84,3],[85,99,4]]
],[9946,[2,[0,19,1],[20,39,2],[40,89,3],[90,99,4]]
],[9947,[2,[0,19,1],[20,79,2],[80,99,3]]
],[9948,[2,[0,39,2],[40,84,3],[85,99,4]]
],[9949,[2,[0,9,1],[10,39,2],[40,89,3],[90,99,4]]
],[9950,[2,[0,29,2],[30,84,3],[85,99,4]]
],[9951,[2,[0,29,2],[30,84,3],[85,99,4]]
],[9952,[2,[0,19,1],[20,39,2],[40,79,3],[80,99,4]]
],[9953,[2,[0,9,1],[10,39,2],[40,59,3],[60,89,2],[90,99,4]]
],[9954,[2,[0,19,1],[20,39,2],[40,79,3],[80,99,4]]
],[9955,[2,[0,39,2],[40,92,3],[93,99,4]]
],[9956,[2,[0,9,1],[10,39,2],[40,89,3],[90,99,4]]
],[9957,[2,[0,39,2],[40,69,3],[70,84,2],[85,99,4]]
],[9958,[2,[0,9,1],[10,49,2],[50,89,3],[90,99,4]]
],[9959,[2,[0,19,1],[20,79,2],[80,94,3],[95,99,4]]
],[9960,[2,[0,59,2],[60,89,3],[90,99,4]]
],[9961,[2,[0,29,1],[30,69,2],[70,94,3],[95,99,4]]
],[9962,[2,[0,54,2],[55,55,4],[56,59,2],[60,84,3],[85,99,4]]
],[9963,[2,[0,29,1],[30,54,2],[55,74,3],[75,99,4]]
],[9964,[2,[0,69,2],[70,94,3],[95,99,4]]
],[9965,[2,[0,39,2],[40,89,3],[90,99,4]]
],[9966,[2,[0,69,2],[70,74,4],[75,95,3],[96,99,4]]
],[9967,[2,[0,39,2],[40,89,3],[90,99,4]]
],[9968,[2,[0,49,2],[50,93,3],[94,99,4]]
],[9970,[2,[0,39,2],[40,89,3],[90,99,4]]
],[9971,[2,[0,59,1],[60,89,2],[90,98,3],[99,99,4]]
],[9972,[2,[0,9,2],[10,19,1],[20,24,3],[25,29,4],[30,59,2],[60,89,3],[90,99,4]]
],[9973,[2,[0,5,2],[6,8,3],[9,9,4],[10,69,2],[70,96,3],[97,99,4]]
],[9974,[2,[0,29,1],[30,54,2],[55,74,3],[75,94,4],[95,99,2]]
],[9975,[2,[0,0,1],[10,39,3],[40,44,4],[45,89,2],[90,94,3],[95,99,4]]
],[9976,[2,[0,50,1],[60,89,2],[90,98,3],[99,99,4]]
],[9977,[2,[0,89,2],[90,98,3],[99,99,4]]
],[9978,[2,[0,29,2],[30,39,3],[40,94,2],[95,98,3],[99,99,4]]
],[9979,[2,[0,49,1],[50,64,2],[65,65,3],[66,75,2],[76,89,3],[90,99,4]]
],[9980,[2,[0,30,1],[40,89,2],[90,98,3],[90,99,4]]
],[9981,[2,[0,9,2],[10,15,3],[16,19,2],[20,79,2],[80,94,3],[95,99,4]]
],[9982,[2,[0,79,2],[80,98,3],[99,99,4]]
],[9983,[2,[80,94,2],[95,98,3],[99,99,4]]
],[9984,[2,[0,49,2],[50,79,3],[90,99,4]]
],[9985,[2,[0,49,1],[50,79,2],[80,89,3],[90,99,4]]
],[9986,[2,[0,39,2],[40,89,3],[90,93,4],[94,96,3],[97,99,2]]
],[9987,[2,[0,39,2],[40,87,3],[88,99,4]]
],[9988,[2,[0,29,1],[30,54,2],[55,74,3],[75,99,4]]
],[9989,[2,[0,0,1],[10,19,3],[20,29,4],[60,94,3],[95,99,4]]
],[99901,[2,[0,49,2],[50,79,3],[80,99,2]]
],[99903,[2,[0,19,1],[20,89,2],[90,99,3]]
],[99904,[2,[0,59,1],[60,89,2],[90,99,3]]
],[99905,[2,[0,39,1],[40,79,2],[80,99,3]]
],[99906,[2,[0,29,1],[30,59,2],[60,69,2],[70,89,2],[90,99,1]]
],[99908,[2,[0,0,1],[10,89,2],[90,99,3]]
],[99909,[2,[0,39,1],[40,94,2],[95,99,3]]
],[99910,[2,[0,29,1],[30,89,2],[90,99,3]]
],[99911,[2,[0,59,2],[60,99,3]]
],[99912,[2,[0,39,1],[40,59,3],[60,89,2],[90,99,3]]
],[99913,[3,[0,299,1],[439,350,2],[600,604,3]]
],[99914,[2,[0,49,1],[50,89,2],[90,94,3]]
],[99915,[2,[0,49,1],[50,79,2],[80,99,3]]
],[99916,[2,[0,29,1],[30,69,2],[70,99,3]]
],[99917,[2,[0,29,1],[30,89,2],[90,99,3]]
],[99918,[2,[0,39,1],[40,79,2],[80,99,3]]
],[99919,[2,[0,29,1],[40,69,2],[90,99,3]]
],[99920,[2,[0,49,1],[50,89,2],[90,99,3]]
],[99921,[2,[0,9,1],[20,69,2],[70,79,3],[80,89,1],[90,99,2]]
],[99922,[2,[0,39,1],[40,69,2],[70,99,3]]
],[99923,[2,[0,19,1],[20,79,2],[80,99,3]]
],[99924,[2,[0,29,1],[30,79,2],[80,99,3]]
],[99925,[2,[0,39,1],[40,79,2],[80,99,3]]
],[99926,[2,[0,9,1],[10,59,2],[60,99,3]]
],[99927,[2,[0,29,1],[30,59,2],[60,99,3]]
],[99928,[2,[0,9,1],[10,79,2],[80,99,3]]
],[99929,[2,[0,49,1],[50,79,2],[80,99,3]]
],[99930,[2,[0,49,1],[50,79,2],[80,99,3]]
],[99931,[2,[0,49,1],[50,79,2],[80,99,3]]
],[99932,[2,[0,9,1],[10,59,2],[60,69,3],[70,79,1],[80,99,2]]
],[99933,[2,[0,29,1],[30,59,2],[60,99,3]]
],[99934,[2,[0,19,1],[20,79,2],[80,99,3]]
],[99935,[2,[0,29,1],[30,59,2],[60,69,3],[70,89,1],[90,99,2]]
],[99936,[2,[0,9,1],[10,59,2],[60,99,3]]
],[99937,[2,[0,19,1],[20,59,2],[60,99,3]]
],[99938,[2,[0,19,1],[20,59,2],[60,69,3],[90,99,2]]
],[99939,[2,[0,59,1],[60,89,2],[90,99,3]]
],[99940,[2,[0,9,1],[10,69,2],[70,99,3]]
],[99941,[2,[0,29,1],[30,79,2],[80,99,3]]
],[99942,[2,[0,49,1],[50,79,2],[80,99,3]]
],[99943,[2,[0,29,1],[30,59,2],[60,99,3]]
],[99944,[2,[0,49,1],[50,79,2],[80,99,3]]
],[99945,[2,[0,59,1],[60,89,2],[90,99,3]]
],[99946,[2,[0,29,1],[30,59,2],[60,99,3]]
],[99947,[2,[0,29,1],[30,69,2],[70,99,3]]
],[99948,[2,[0,49,1],[50,79,2],[80,99,3]]
],[99949,[2,[0,19,1],[20,89,2],[90,99,3]]
],[99950,[2,[0,49,1],[50,79,2],[80,99,3]]
],[99952,[2,[0,49,1],[50,79,2],[80,99,3]]
],[99953,[2,[0,29,1],[30,79,2],[80,99,3]]
],[99954,[2,[0,29,1],[30,69,2],[70,99,3]]
],[99955,[2,[0,19,1],[20,59,2],[60,89,3],[90,99,2]]
],[99956,[2,[0,59,2],[60,99,3]]
]
],[
[0,[1,[0,9,8]]
],[2,[1,[0,9,8]]
],[3,[1,[0,9,8]]
],[4,[1,[0,9,8]]
],[5,[1,[0,9,8]]
],[6,[1,[0,9,8]]
],[7,[1,[0,9,8]]
],[8,[2,[0,19,8],[20,21,3],[22,39,8],[40,79,4]],[3,[800,884,8],[885,899,5],[900,984,8],[985,986,7],[987,999,8]]
],[9,[1,[0,9,8]]
],[10,[2,[0,19,2],[20,69,3],[70,89,4]],[3,[900,975,5],[976,999,6]]
],[11,[2,[0,24,2],[25,54,3],[55,84,4],[85,94,5],[95,99,6]]
],[12,[2,[0,19,7],[20,29,3]],[3,[300,544,7],[545,599,4],[600,799,7],[800,849,5],[850,999,7]]
],[13,[1,[0,9,7]]
],[14,[1,[0,9,7]]
],[15,[1,[0,9,7]]
],[16,[1,[0,9,7]]
],[17,[1,[0,9,7]]
],[18,[1,[0,9,7]]
],[19,[1,[0,9,7]]
]
]];
};
};
mw.libs.WikiSyntaxTextMod.bb.isbn(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.isbn;
mw.libs.WikiSyntaxTextMod.bb.issn=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM.util,"issn");
WSTM.util.issn.faith=function(acquired){
var k=0,i;
for(i=0;i<7;i++){
k+=acquired[i]*(8-i);}
k=(11-k%11)%11;
return(k===acquired[7]);
};
WSTM.util.issn.fashion=function(acquired){
var i,n=acquired.length,r;
if(n===8){
r="";
for(i=0;i<4;i++){
r=r+String.fromCharCode(acquired[i]+48);}
r=r+"-";
for(i=4;i<7;i++){
r=r+String.fromCharCode(acquired[i]+48);}
if(acquired[7]===10){
r=r+"X";
}else{
r=r+String.fromCharCode(acquired[7]+48);}
}else if(n===13){
r="977-";
for(i=3;i<10;i++){
r=r+String.fromCharCode(acquired[i]+48);}
r=r+"-";
for(i=10;i<12;i++){
r=r+String.fromCharCode(acquired[i]+48);}
r=r+"-"+String.fromCharCode(acquired[12]+48);}
return r;
};
WSTM.util.issn.fetch=function(attempt){
var n=attempt.length,m,r;
if(n>=13&&attempt.substr(0,3)==="977"){
m=13;
}else{
m=8;}
r=WSTM.util.code.fetch(attempt,m,8,"ISSN");
return r;
};
WSTM.util.issn.format=function(adjust){
var issn=this.fetch(adjust),r=false,n;
if(issn){
n=issn.length;
if(n===8||n===13){
if(n===8){
if(!this.faith(issn)){
WSTM.errors.found("badISSNcheckdig",false,adjust);
issn=false;}
}else if(WSTM.util.gtin.faith(issn)!==issn[12]){
issn=false;
WSTM.errors.found("badISSNcheckdig",false,adjust);}
if(issn){
r=this.fashion(issn);
if(r===adjust){
r=false;}}
}else{
WSTM.errors.found("badISSNstrange",false,adjust);}}
return r;
};
};
mw.libs.WikiSyntaxTextMod.bb.issn(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.issn;
mw.libs.WikiSyntaxTextMod.bb.lccn=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM.util,"lccn");
WSTM.util.lccn.format=function(attempt,apply){
var r=false,d,got,j,s,small;
if(typeof this.re!=="object"){
this.re={};
this.re.pre=new RegExp("^ *([A-Za-z]{1,3})?([/0-9])(.+[^ \n])[ \n]*$","");
this.re.year=new RegExp("^([0-9][0-9])([0-9][0-9])([0-9]*)$","");
this.re.yearser=new RegExp("^(([0-9][0-9])|(20[0-9][0-9]))([/-])(.+)","");}
if(attempt){
got=this.re.pre.exec(attempt);
if(got){
s=got[1];
if(s){
small=s.toLowerCase();
if(s!==small){
r=small+got[2]+got[3];}
}else{
small=false;}
if(got[2]==="/"){
got=this.re.yearser.exec(got[3]);
if(got){
if(got[4]!=="/"){
got=false;}}
if(got){
j=got[3];
}else{
r=[r,"invalid slash segmentation"];}
}else{
s=got[2]+got[3];
got=this.re.yearser.exec(s);
if(got){
j=(got[4]==="-"?got[3]:false);
}else{
got=this.re.year.exec(s);
if(got){
if(got[1]==="20"){
j=got[1]+got[2];
got[5]=got[3];
}else{
j=got[1];
got[5]=got[2]+got[3];}}}}
}else{
r=[false,"invalid prefix"];}
if(j&&typeof r!=="object"){
d=j.length;
if(d!==2&&d!==4){
r=false;
}else if(apply==="/"){
r=(small?small+"/":"")+j+"/"+got[5];
}else if(apply==="-"||apply===true){
r=(small?small:"")+j+"-"+got[5];
}else{
r=(small?small:"")+j+got[5];}
if(r){
j=parseInt(j,10);
if(j>2000){
d=new Date();
if(j>d.getFullYear()){
r=false;}
}else if(j>100){
r=false;}}
if(!r){
r=[r,"invalid year: "+j];}}
if(typeof r==="string"){
r=[r,false];}}
return r;
};
};
mw.libs.WikiSyntaxTextMod.bb.lccn(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.lccn;
mw.libs.WikiSyntaxTextMod.bb.urn=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM.util,"urn");
WSTM.util.urn.sns=":3gpp:cablelabs:cgi:clei:dgiwg:dvb:ebu:epc:epcglobal:example:fdc:fipa:geant:ietf:iptc:isan:isbn:iso:issn:ivis:lex:liberty:mace:mpeg:nbn:nena:newsml:nfc:nzl:oasis:ogc:ogf:oid:oipf:oma:pin:publicid:s1000d:schac:service:smpte:swift:tva:uci:ucode:uuid:web3d:xmlorg:xmpp:";
WSTM.util.urn.failure=function(attempt){
var r=false,crash,got,small,space,subject,swap;
if(typeof this.re!=="object"){
this.re={};
this.re.chr=new RegExp("([^-A-Za-z0-9()+,.:=@;$_!*'%].*)$","");
this.re.org=new RegExp("^ *(urn:)([A-Za-z0-9]+:)?(.*[^ \n])[ \n]*","i");}
if(attempt){
got=this.re.org.exec(attempt);
if(got){
space=got[2];
if(space){
space=space.toLowerCase();
if(this.sns.indexOf(":"+space)>=0){
small="urn:"+space;
subject=got[3];
swap=WSTM.util.isEscValid(subject);
crash=this.re.chr.exec(subject);
if(crash){
r=[false,"bad character: "+crash[1]];
}else if(swap){
r=[false,"bad escaping: "+swap];
}else if(got[1]+got[2]!==small){
r=small+subject;}
}else{
r=[false,"unknown namespace"];}
}else{
r=[false,"missing namespace"];}
}else{
r=[false,"invalid scheme (urn:)"];}}
return r;
};
};
mw.libs.WikiSyntaxTextMod.bb.urn(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.urn;
mw.libs.WikiSyntaxTextMod.bb.regexp=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM.util,"regexp");
WSTM.util.regexp.fault=function(attempt){
var r=false;
if(attempt){
if(typeof attempt==="object"){
if(typeof attempt.ignoreCase!=="boolean"){
r="Object not RegExp";}
}else{
r="RegExp definition not object";}
}else{
r="Empty RegExp definition ("+attempt+")";}
return r;
};
WSTM.util.regexp.fiat=function(attempt,adjust,alert){
var r=false,s=false,lt,sf;
switch(typeof attempt){
case "string":
if(attempt){
lt=(typeof adjust==="string");
sf=(lt?adjust:"");
try{
r=new RegExp(attempt,sf);
}catch(err){
s=err+"\n"+attempt;
if(adjust){
s=s+"\nflags: "+adjust;}}
}else{
s="Empty string";}
break;
case "object":
s=this.fault(attempt);
if(!s){
r=attempt;}
break;
default:
s="Invalid type";}
if(s){
if(alert){
WSTM.main.fault(WSTM.lang.text.fetch("BadRegExp")+s,alert);
r=false;
}else{
r=s;}}
return r;
};
WSTM.util.regexp.flag=function(attempt,apply,about){
var r=apply,l,s;
if(attempt){
l=(typeof attempt==="string");
if(l){
l=(attempt.search(/[^gGiImMyY]/)<0);
if(l){
s=attempt.toLowerCase();
if(s.indexOf("g")<0){
if(r.indexOf("g")>=0){
r=r.replace(/g/,"");}}
if(s.indexOf("i")>=0){
r=r+"i";}
if(s.indexOf("y")>=0){
r=r+"y";}}}
if(!l){
WSTM.main.fault(WSTM.lang.text.fetch("BadRegExpFlag")+" "+attempt,about);}}
return r;
};
};
mw.libs.WikiSyntaxTextMod.bb.regexp(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.regexp;
mw.libs.WikiSyntaxTextMod.bb.translate=function(WSTM){
"use strict";
WSTM.util.fiatObjects(WSTM.util,"translate");
WSTM.util.translate.factory=function(adjust,about){
var n=adjust.length,r=new Array(n),e,f,i,m,s;
for(i=0;i<n;i++){
m=adjust[i];
f=(m.length<3?"g":m[2]);
s=m[0];
try{
e=new RegExp(s,f);
}catch(err){
WSTM.main.fault("RegExp error:\n"+err+"\n"+s+"\nin "+about+"["+i+"]",false);
r.splice(i,1);
i--;
break;}
r[i]=[e,m[1]];}
return r;
};
WSTM.util.translate.fiat=function(assign,apply,about){
var r=false,bug,s,sf,sh,sr;
if(WSTM.util.isArray(assign)){
if(assign.length>1){
bug=false;
sh=assign[1];
s=typeof sh;
if(s==="string"||s==="function"){
sr=assign[0];
if(sr===false||sr===true||sr===""){
sr="^.*$";}
switch(typeof sr){
case "string":
if(assign.length<3){
sf=apply;
}else{
sf=WSTM.util.regexp.flag(assign[2],apply,about);}
try{
r=[new RegExp(sr,sf),sh];
}catch(err){
bug=err+"\n"+sr;
if(typeof sf==="string"){
bug=bug+"\nflags:  "+sf;}
bug=["BadRegExp",bug];}
break;
case "object":
bug=WSTM.util.regexp.fault(sr);
if(bug){
bug=[bug,false];
}else{
r=[sr,sh];}
break;}
}else{
bug=["IsNotStringOrFunction",sh];}
if(bug){
WSTM.main.fault(WSTM.lang.text.fetch(bug[0]),bug[1]);}}}
return r;
};
WSTM.util.translate.flip=function(adjust,apply){
var n=apply.length,r=adjust,i,s,t,x;
for(i=0;i<n;i++){
t=apply[i];
x=t[1];
s=typeof x;
if(s==="string"){
r=r.replace(t[0],x);
}else if(s==="function"){
r=r.replace(t[0],x(1,i,0,r));}}
return r;
};
WSTM.util.translate.further=function(add,all,adhere,already){
var s=false,story=(typeof adhere==="string"?adhere:"'add.further'"),wstmTXT=WSTM.lang.text.fetch,c,e,f,i,j,k,learnt,n,source,x;
if(WSTM.util.isArray(add)){
learnt=(already?true:false);
n=add.length;
if(!all){
k=0;
all=new Array(n);
}else{
k=all.length;
all=all.concat(new Array(n));}
for(i=0;i<n;i++){
e=add[i];
if(WSTM.util.isArray(e)){
c=e.length;
if(learnt){
if(c>2){
x=e[2];
}else{
c=2;}
}else{
source=story+" #"+(i+1)+" ";
if(c<2){
s=source+wstmTXT("Not")+" min. Array(2)";
break;
}else if(typeof e[0]!=="string"){
s="regexp in "+source+wstmTXT("IsNotAString");
break;
}else if(typeof e[1]!=="string"&&typeof e[1]!=="function"){
s=wstmTXT("ReplacementIn")+" "+source+wstmTXT("IsNotStringOrFunction");
break;
}else if(c>4){
s=source+wstmTXT("HasMoreThan4Elements");
break;
}else if(c>2){
x=e[2];
if(typeof x==="string"){
x=x.toLowerCase();
for(j=x.length-1;j>=0;j--){
switch(x.charCodeAt(j)){
case 103:
case 105:
case 109:
case 121:
break;
default:
s="flag '"+x[j]+"' in "+source+wstmTXT("Invalid")+":  '"+e[2]+"'";
break;}}
}else{
if(c>3){
if(x&&x!==null&&x!==undefined){
s="flag in "+source+wstmTXT("IsNotAString");
break;}}
c=2;}}}
if(!s){
f=(c>2?x:"gm");
if(learnt){
x=new RegExp(e[0],f);
}else{
x=WSTM.util.regexp.fiat(e[0],f,false);
if(typeof x==="string"){
s="RegExp error:\n"+x+"\nin "+story+" #"+(i+1);
all.splice(k,1);
break;}}
all[k]=[x,e[1]];
k++;}
}else{
s=source+wstmTXT("IsNotAnArray");
break;}}
}else{
s=story+wstmTXT("IsNotAnArray");}
if(s){
WSTM.main.fault(s,false);}
return(s?false:all);
};
};
mw.libs.WikiSyntaxTextMod.bb.translate(mw.libs.WikiSyntaxTextMod);
delete mw.libs.WikiSyntaxTextMod.bb.translate;
(function(WSTM){
"use strict";
var sub="U",self=WSTM.util.self,version=WSTM.util.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/rU.js