Jump to content

User:PerfektesChaos/js/citoidWikitext/r.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.
/// User:PerfektesChaos/js/citoidWikitext.js
/// 2018-09-03 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#E9AD6BFE#
/// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA)
///<nowiki>
(function(mw){
"use strict";
var Version=4.2,Signature="citoidWikitext",HELP={site:"w:en",support:"user:PerfektesChaos/js/"+Signature},PREGO={maxage:604812,signature:"preferencesGadgetOptions",site:"w:en",store:"User:PerfektesChaos/js/",sub:"/r.js"},REPOS={maxage:86400,site:"w:en",store:"User:PerfektesChaos/js/"},CITWT;
function feed(assigned,access){
var p,rls;
if(!mw.loader.getState(assigned)){
rls={};
rls[assigned]="loading";
mw.loader.state(rls);
p={bcache:1};
if(typeof CITWT.suite==="string"){
CITWT.suite=(CITWT.suite==="r"?"r":"d");
}else{
CITWT.suite=(Version>1?"r":"d");}
p.maxage=(CITWT.suite==="r"?REPOS.maxage:100);
REPOS.fire(REPOS.site,REPOS.store+access,"/"+CITWT.suite+".js",p);}}
function fetch(access){
var sub="/"+access;
PREGO.feed();
feed(CITWT.signature+sub,Signature+sub);}
function finesse(assigned,alike){
var s=assigned.wgTitle;
if(alike){
s=s.replace(/\/.*$/,"");}
return "|sandbox."+assigned.wgDBname+"="+assigned.wgNamespaceNumber+":"+s+"|";}
function fire(){
var env=mw.config.get(["wgAction","wgArticleId","wgCanonicalSpecialPageName","wgDBname","wgIsProbablyEditable","wgNamespaceNumber","wgPageContentModel","wgTitle","wgUserName","wgWikibaseItemId"]),load,re,seek,store,stored;
switch(env.wgAction){
case "edit":
case "submit":
switch(env.wgNamespaceNumber){
case 0:
load=true;
break;
case 2:
load=(!env.wgTitle.indexOf(env.wgUserName+"/"));
break;
case 10:
load=(env.wgTitle.substr(0,3)==="Bib");
if(load){
re="^Bib(DOI|ISBN|PMID)/([0-9].*)$";
re=new RegExp(re);
load=re.exec(env.wgTitle);
if(load){
CITWT.bibRecord={launch:(env.wgArticleId?false:true),sign:load[1],subject:load[2]};}}
break;
default:
if(env.wgNamespaceNumber%2===0&&typeof window.sessionStorage==="object"){
store=window.sessionStorage.getItem(CITWT.type);
if(store){
seek=finesse(env,true);
load=(store.indexOf(seek)>=0);}}}
if(!load&&typeof CITWT.pages==="object"&&CITWT.pages){
switch(typeof CITWT.pages[env.wgNamespaceNumber]){
case "object":
re=CITWT.pages[env.wgNamespaceNumber];
if(re&&typeof re.test!=="function"){
re=false;}
break;
case "string":
re=CITWT.pages[env.wgNamespaceNumber];
if(re){
re=new RegExp(re);}
break;}
if(re){
load=(re.test(env.wgTitle));}}
if(load&&env.wgIsProbablyEditable&&env.wgPageContentModel==="wikitext"){
fetch("core");}
break;
case "view":
if(env.wgNamespaceNumber===-1){
if(env.wgCanonicalSpecialPageName==="Blankpage"){
fetch("prego");}
}else if(env.wgNamespaceNumber>3&&typeof env.wgWikibaseItemId==="string"&&env.wgWikibaseItemId.toUpperCase()==="Q3938"&&typeof window.sessionStorage==="object"){
store=finesse(env);
try{
stored=window.sessionStorage.getItem(CITWT.type)||"|";
if(stored.indexOf(store)<0){
store=stored+store.substr(1);
window.sessionStorage.setItem(CITWT.type,store);}
}catch(e){
}}
break;}}
function first(){
var signature="ext.gadget."+Signature,s=mw.loader.getState(signature),rls;
if(s!=="loaded"&&s!=="ready"){
rls={};
rls[signature]="loaded";
mw.loader.state(rls);
if(typeof mw.libs[Signature]!=="object"||!mw.libs[Signature]){
mw.libs[Signature]={};}
CITWT=mw.libs[Signature];
if(typeof CITWT.vsn==="string"){
CITWT.vsn="*"+Version+" "+CITWT.vsn;
}else{
CITWT.vsn=""+Version;}
CITWT.type=Signature;
CITWT.signature="ext.gadget."+Signature;
CITWT.support="[["+HELP.site+":"+HELP.support+"]]";
fire();
rls[signature]="ready";
mw.loader.state(rls);
mw.hook(CITWT.type+".ready").fire();}}
PREGO.feed=function(){
var sign="ext.gadget."+PREGO.signature,rls;
if(!mw.loader.getState(sign)){
rls={};
rls[sign]="loading";
mw.loader.state(rls);
REPOS.fire(PREGO.site,PREGO.store+PREGO.signature+PREGO.sub,false,{action:"raw",ctype:"text/javascript",bcache:1,maxage:PREGO.maxage});}
};
REPOS.fire=function(at,access,append,alter){
var source,syntax;
if(typeof REPOS.requests!=="object"){
REPOS.requests={};}
if(typeof REPOS.requests[access]!=="boolean"){
REPOS.requests[access]=true;
if(append){
source=access+append;
}else{
source=access;}
if(at){
source=REPOS.foundation(at,source,alter);
if(typeof alter==="object"&&alter&&typeof alter.ctype==="string"){
syntax=alter.ctype;}
}else{
syntax=alter;}
mw.loader.load(source,syntax);}
};
REPOS.foundation=function(at,access,alter){
var s=access,r=encodeURI(s);
if(typeof alter==="object"&&alter){
r="/w/index.php?title="+r;
if(access.substr(-3)===".js"){
alter.ctype="text/javascript";
}else if(access.substr(-4)===".css"){
alter.ctype="text/css";}
alter.action="raw";
for(s in alter){
r=r+"&"+s+"="+encodeURI(alter[s]);}
}else{
r="/wiki/"+r;}
if(typeof at==="string"&&at){
switch(at){
case "meta":
r="meta.wikimedia.org"+r;
break;
case "mw":
r="www.mediawiki.org"+r;
break;
case "w:en":
r="en.wikipedia.org"+r;
break;
default:
r=window.location.host+r;}
r="https://"+r;}
return r;
};
first();
}(window.mediaWiki));
/// EOF</nowiki>citoidWikitext/r.js