User:PerfektesChaos/js/isbnLib/r.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. |
Documentation for this user script can be added at User:PerfektesChaos/js/isbnLib/r. |
/// PerfektesChaos/js/isbnLib/r.js
/// 2018-08-24 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#3BDCA5E2#
/// ISBN utility package
(function(mw,$){
"use strict";
var LIB="isbnLib",Version=2.8,PRIVATE={wstmBB:"SU"};
if(typeof mw.libs[LIB]!=="object"||!mw.libs[LIB]){
mw.libs[LIB]={};}
mw.libs[LIB].vsn=Version;
mw.libs[LIB].type=LIB;
LIB=mw.libs[LIB];
/// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA)
if(typeof LIB.doc!=="string"){
LIB.doc="[[w:en:User:PerfektesChaos/js/"+LIB.type+"]]";}
PRIVATE.catalogs={
de:["http://swb.bsz-bw.de/DB=2.1/CMD?ACT=SRCHA&IKT=1007&TRM=#","https://portal.dnb.de/opac.htm?method=simpleSearch&query=#"],en:["http://catalog.loc.gov/vwebv/search?searchCode=ISBL&searchType=1&searchArg=#"],fr:["http://catalogue.bnf.fr/search.do?mots0=NRC;-1;0;#&pageRech=rav"],nl:["http://opc4.kb.nl/LNG=NE/CMD?ACT=SRCH&IKT=1007&TRM=#"],pl:["http://koha.biblos.pk.edu.pl/cgi-bin/koha/opac-search.pl?idx=nb&q=#"],pt:["http://aleph20.letras.up.pt/F/?func=find-b&find_code=ISBN&request=#","http://porbase.bnportugal.pt/ipac20/ipac.jsp?menu=search&index=ISBN&term=#"],sv:["http://libris.kb.se/hitlist?q=linkisxn:#"],qqq:["http://www.worldcat.org/search?q=isbn:#"]
};
PRIVATE.countries978=[
["bg",954],["cs",80],["da",87],["de",3],["el",960,9963],["en",0,1],["es",84,950,956,958,959,968,970,980,987,9942,9945,9962,9968,9972,9974,9977,9978,99905,99922,99923,99924,99925,99926,99934,99939,99953,99954],["et",9949,9985],["fi",951,952],["fr",2],["he",965],["hu",963],["it",88],["ja",4],["ko",89,9946],["nl",90],["nn",82],["no",82],["pl",83],["pt",85,972,989],["ru",5],["sk",80],["sl",961],["sv",91],["th",974],["tr",975,9944],["uk",966],["zh",7]];
function feed(about){
var rls,s;
if(typeof about==="object"&&typeof about[0]==="string"){
LIB.loaded=true;
LIB.wstm[about[0]]=true;
for(s in LIB.wstm){
LIB.loaded=LIB.loaded&&LIB.wstm[s];}
if(LIB.loaded){
rls={};
rls["ext.gadget."+LIB.type+"/*"]="ready";
mw.loader.state(rls);
mw.hook("isbnLib.ready").fire(LIB);}}}
function fill(){
if(typeof LIB.catalogs!=="object"||!LIB.catalogs||typeof LIB.catalogs.qqq!=="object"||!LIB.catalogs.qqq||typeof LIB.catalogs.qqq.length!=="number"||typeof LIB.catalogs.qqq[0]!=="string"){
LIB.catalogs=PRIVATE.catalogs;}}
function fine(){
var r;
if(typeof LIB.loaded==="boolean"&&LIB.loaded&&typeof mw.libs.WikiSyntaxTextMod==="object"&&typeof mw.libs.WikiSyntaxTextMod.util==="object"&&typeof mw.libs.WikiSyntaxTextMod.util.isbn==="object"){
r=mw.libs.WikiSyntaxTextMod.util.isbn;}
return r;}
function first(){
var i,rls,s,self,signature,state,sub;
if(typeof LIB.wstm!=="object"){
rls={};
self="ext.gadget."+LIB.type;
rls[self+"/*"]="loading";
mw.loader.state(rls);
LIB.wstm={};
sub=(Version>0?"r":"d");
for(i=0;i<PRIVATE.wstmBB.length;i++){
s=PRIVATE.wstmBB.substr(i,1);
LIB.wstm[s]=false;
signature="user:PerfektesChaos/WikiSyntaxTextMod/"+s;
state=mw.loader.getState(signature);
if(!state){
rls={};
rls[signature]="loading";
mw.loader.state(rls);
mw.loader.load("https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/WikiSyntaxTextMod/"+sub+s+".js&bcache=1&maxage=604812&action=raw&ctype=text/javascript");}
if(state==="ready"){
feed([s]);
}else{
mw.hook("WikiSyntaxTextMod/"+s+".ready")
.add(feed);}}
rls={};
rls[self]="ready";
mw.loader.state(rls);}}
LIB.factory=function(attribute){
var wstmUisbn=fine(),r;
if(wstmUisbn){
r=wstmUisbn.factory(attribute);
}else{
r=null;}
return r;
};
LIB.finder=function(assign){
var r=[],b,g,i,k,s,u;
fill();
for(i=0;i<LIB.catalogs.qqq.length;i++){
r.push(LIB.catalogs.qqq[i]);}
if(typeof assign==="string"&&assign!=="qqq"){
b=assign.split(" ");
for(k=0;k<b.length;k++){
s=b[k];
if(typeof LIB.catalogs[s]==="object"){
g=LIB.catalogs[s];
for(i=0;i<g.length;i++){
u=g[i];
if($.inArray(u,r)<0){
r.push(u);}}}}}
return r;
};
LIB.flip=function(adjust){
var wstmUisbn=fine(),r;
if(wstmUisbn){
r=wstmUisbn.flip(adjust,function(){});
}else{
r=null;}
return r;
};
LIB.focus=function(about){
var r=false,s=about.replace(/-/g,""),k=s.length,g,i,n;
if(k===13){
k=s.substr(0,3);
if(k==="979"){
switch(s.substr(3,2)){
case "10":r="fr"; break;
case "11":r="ko"; break;
case "12":r="it"; break;}
}else if(k==="978"){
k=10;
s=s.substr(3);}}
if(k===10){
switch(s.substr(0,1)){
case "0":
case "1":r="en"; break;
case "2":r="fr"; break;
case "3":r="de"; break;
case "4":r="ja"; break;
case "5":r="ru"; break;
case "6":
n=s.substr(0,3);
break;
case "7":r="zh"; break;
case "8":
n=s.substr(0,2);
break;
case "9":
switch(s.substr(0,2)){
case "90":
case "94":r="nl"; break;
case "91":r="sv"; break;
case "92":r="mul"; break;
default:
if(s.substr(1,1)==="9"){
if(s.substr(2,1)==="9"){
n=5;
}else{
n=4;}
}else{
n=3;}
n=s.substr(0,n);}
break;}
if(n){
n=parseInt(n,10);
for(i=0;i<PRIVATE.countries978.length;i++){
g=PRIVATE.countries978[i];
for(k=1;k<g.length;k++){
if(g[k]===n){
r=g[0];
break;}}
if(r){
break;}}}}
return r;
};
LIB.format=function(adjust,additional){
var wstmUisbn=fine(),r;
if(wstmUisbn){
r=wstmUisbn.format(adjust,false,function(){});
if(r[0]){
if(!additional){
r=r[1];}
}else{
r=false;}
}else{
r=null;}
return r;
};
LIB.furnish=function(add){
var cat,g,i,j,s,slang,user;
switch(typeof add){
case "string":
user={qqq:[add]};
break;
case "object":
if(add){
if(add.length==="number"){
user={qqq:add};
}else{
user=add;}}
break;}
if(user){
fill();
if(typeof LIB.reLang!=="object"){
LIB.reLang=new RegExp("^[a-z][a-z]+$");
LIB.reURL1=new RegExp("^\\S+$");
LIB.reURL2=new RegExp("^https?://[^/#]+\\.[^/#]+/.*#");}
for(slang in user){
if(typeof slang==="string"&&LIB.reLang.test(slang)){
g=user[slang];
if(typeof g==="object"&&g&&typeof g.length==="number"){
if(typeof LIB.catalogs[slang]!=="object"){
LIB.catalogs[slang]=[];}
cat=LIB.catalogs[slang];
for(i=0;i<g.length;i++){
s=g[i];
if(typeof s==="string"&&LIB.reURL1.test(s)&&LIB.reURL2.test(s)){
for(j=0;j<cat.length;j++){
if(cat[j]===s){
s=false;
break;}}
if(s){
cat.push(s);}}}}}}}
};
first();
}(window.mediaWiki,window.jQuery));
/// EOF</nowiki>isbnLib/r.js