User:PerfektesChaos/js/paneMarker/r.js

/// User:PerfektesChaos/js/paneMarker/r.js /// 2016-10-08 PerfektesChaos@de.wikipedia /// Fingerprint:#0#12C19C64# /// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA) /// (function(mw,$){ "use strict"; var VERSION=3.2,PaneMk="paneMarker"; if(typeof mw.libs[PaneMk]!=="object"||!mw.libs[PaneMk]){ mw.libs[PaneMk]={opt:{}};} mw.libs[PaneMk].vsn=VERSION; mw.libs[PaneMk].type=PaneMk; PaneMk=mw.libs[PaneMk]; if(!PaneMk.prefs){ PaneMk.heads="|commonswiki|dewiki|"; PaneMk.doc="mw:User:PerfektesChaos/js/"+PaneMk.type+""; PaneMk.config={lazy:false,shortcut:true}; PaneMk.prefs={};} PaneMk.prefs.fetch=function{ var s,v,scope=" appleIcon faviconICO faviconPNG lazy chars charDiff charHistory charLinks charVitally lowChar favicon leave shortcut ",vals=mw.libs[this.supply].fetch(PaneMk.type); for(s in vals){ if(scope.indexOf(" "+s+" ")>0){ v=vals[s]; if(v!==""){ PaneMk.config[s]=v;}}} }; PaneMk.prefs.fiat=function(access,allow){ var r; if(typeof allow==="boolean"){ if(typeof PaneMk.config[access]==="boolean"){ r=PaneMk.config[access]; }else{ r=allow;} }else{ if(typeof PaneMk.config[access]==="string"){ r=PaneMk.config[access]; }else{ r="";}} return r; }; PaneMk.prefs.fire=function{ var signature; PaneMk.prefs.supply="preferencesGadgetOptions"; signature="ext.gadget."+PaneMk.prefs.supply; PaneMk.prefs.suffix="/r.js&bcache=1&maxage=604804&action=raw&ctype=text/javascript"; if(!mw.loader.getState(signature)){ mw.loader.state(signature,"loading"); mw.loader.load("https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/"+PaneMk.prefs.supply+PaneMk.prefs.suffix,"text/javascript");} mw.hook(PaneMk.prefs.supply+".ready").add(PaneMk.prefs.fired); }; PaneMk.prefs.fired=function{ PaneMk.furnish; mw.loader.state("ext.gadget."+PaneMk.type,"ready"); }; PaneMk.prefs.form=function{ mw.loader.load("https://www.mediawiki.org/w/index.php?title=User:PerfektesChaos/js/"+PaneMk.type+"/dialog"+this.suffix); }; PaneMk.facilitate=function{ var s=this.env.wgRelevantPageName; if(!s){ s=this.env.wgPageName;} window.document.title=s.replace(/_/g," ")+" * "+this.env.wgSiteName; }; PaneMk.favicon=function(apply){ var $apple,$head=$(window.document).find("head"),$favicon,apple=false,i,light=apply,n=0,offer=false,png=false,s; if($head.length){ if(apply){ png=["wmf","f7"]; if(this.site==="commonswiki"){ apple=["commons","70"]; png=["commons","e7"]; }else if(this.site==="metawiki"){ png=["meta","96"]; }else if(this.site==="testwiki"){ apple=["wikipedia","f1"]; png=["testwiki","b6"]; }else if(this.site==="mediawikiwiki"){ apple=["mediawiki","b6"]; png=["mediawiki","fa"]; }else if(this.site.slice(-4)==="wiki"){ apple=["wikipedia","f1"]; if(this.less){ png=["beta-wikipedia","25"]; }else{ png=["wikipedia","fb"];} }else if(this.site.slice(-9)==="wikibooks"){ png=["wikibooks","7e"]; }else if(this.site.slice(-8)==="wikinews"){ apple=["wikinews","a9"]; png=["wikinews","cc"]; }else if(this.site.slice(-9)==="wikiquote"){ png=["wikiquote","cb"]; }else if(this.site.slice(-10)==="wikisource"){ png=["wikisource","f4"]; }else if(this.site.slice(-11)==="wikiversity"){ png=["wikiversity","95"]; }else if(this.site.slice(-10)==="wiktionary"){ apple=["wiktionary","f8"]; png=["wiktionary","c0"]; }else{ apple=["wmf","a9"];} }else{ if(this.less&&typeof this.config.faviconPNG==="undefined"){ this.config.favicon=this.file("Favicon-","beta-wikipedia","14");} light=this.config.favicon;} if(apply){ $apple=$head.find("link").filter(function{ return(this.rel==="apple-touch-icon"); }); if($apple.length===1){ s=false; switch(typeof this.config.appleIcon){ case "string": s=this.config.appleIcon; break; case "boolean": if(!this.config.appleIcon){ break;} default: if(apple){ s=this.file("Apple-touch-icon-red-",apple[0],apple[1]);}} if(s){ $apple.detach; $apple.attr("href",s); $head.append($apple);}}} if(light){ $favicon=$head.find("link").filter(function{ return(this.rel==="shortcut icon"); }); n=$favicon.length;} if(n){ if(apply){ s=false; switch(typeof this.config.faviconPNG){ case "string": s=this.config.faviconPNG; break; case "boolean": if(!this.config.faviconPNG){ break;} default: s=this.file("Favicon-red-",png[0],png[1]);} offer=s,"image/png"; s=this.config.faviconICO; if(s){ if(typeof s==="string"){ offer.push([s,"image/x-icon"]);}} }else{ s=this.config.favicon; if(s){ if(typeof s==="string"){ offer=s,null; s=s.slice(-4).toLowerCase; switch(s){ case ".ico": offer[0][1]="image/x-icon"; break; case ".gif": case ".png": offer[0][1]="image/"+s.substr(1); break;}}}} if(offer){ for(i=0;i1){ $favicon=$favicon.eq(0);} for(i=0;i<offer.length;i++){ $favicon.attr("href",offer[i][0]); $favicon.attr("type",offer[i][1]); $head.append($favicon); if(i+1<offer.length){ $favicon=$favicon.clone;}}}}} }; PaneMk.file=function(album,assign,access){ var r="//upload.wikimedia.org/wikipedia/commons/"+access.substr(0,1)+"/"+access+"/"+album+assign+".png"; return r; }; PaneMk.fire=function{ mw.loader.using(["user","user.options","mediawiki.util","jquery.client"],this.prefs.fire); }; PaneMk.flag=function(action){ var c=true,learn=true; if(this.config.leave){ this.facilitate; }else if(this.heads.indexOf(this.site)<0){ c=this.config["char"+action]; learn=false;} if(typeof this.config.chars==="boolean"){ if(c===true){ c=this.config.chars;}} if(c){ if(learn){ c=this.config["char"+action]; if(c===undefined){ c=true; }else{ learn=false;}} if(learn){ switch(action){ case "Diff": c=(this.config.lowChar?"±":916); break; case "History": c=(this.config.lowChar?"^":8595); break; case "Links": c=(this.config.lowChar?">":8594); break; case "Vitally": if(c&&!this.config.lazy){ c=false; break;} c="*"; break; default: c=false;}} if(c){ if(!this.config.leave){ if(action==="Links"){ this.facilitate;}} if(typeof c==="number"){ if(c>0){ c=String.fromCharCode(c);}} if(typeof c==="string"){ if(this.config.rightleft){ window.document.title=window.document.title+" "+c; }else{ c=c+" "; if(window.document.title.indexOf(c)!==0){ window.document.title=c+window.document.title;}}}}} }; PaneMk.flip=function{ var s=false,e,o,$shortcut; if(typeof this.config.shortcut!=="boolean"){ this.config.shortcut=true;} if(this.config.shortcut){ $shortcut=$(".shortcut"); if($shortcut.length){ s=$shortcut.data("shortcut");}} if(!s&&this.nsN>0){ o=this.env.wgNamespaceIds; for(e in o){ if(e.length<4){ if(o[e]===this.nsN){ s=e.toUpperCase+":"+this.env.wgTitle; break;}}}} if(s){ window.document.title=s;} }; PaneMk.fresh=function{ var lenient=true,browser,s; if(typeof this.opt==="object"&&this.opt){ for(s in this.opt){ this.config[s]=this.opt[s];}} if(!mw.user.isAnon&&mw.libs[this.prefs.supply]){ this.prefs.fetch;} this.env=mw.config.get(["wgAction","wgCanonicalSpecialPageName","wgDBname","wgNamespaceIds","wgNamespaceNumber","wgPageName","wgRelevantPageName","wgServer","wgSiteName","wgTitle"]); this.site=this.env.wgDBname; this.nsN=this.env.wgNamespaceNumber; this.less=(this.env.wgServer.indexOf(".beta.wmflabs.org")>0); if(!this.config.lazy){ if($.client){ browser=$.client.profile; if(browser.name==="msie"){ this.config.lazy=(browser.versionNumber<10);}}} this.flip; switch(this.env.wgAction){ case "edit": case "submit": if(!this.config.lazy){ this.favicon(true); lenient=false;} this.flag("Vitally"); break; case "history": this.flag("History"); break; case "view": if(mw.util.getParamValue("diff")!==null){ this.flag("Diff"); }else if(this.nsN===-1){ switch(this.env.wgCanonicalSpecialPageName){ case "Blankpage": case "Gadgets": if(!mw.user.isAnon&&mw.libs[this.prefs.supply]){ this.prefs.form;} break; case "Emailuser": case "Upload": if(!this.config.lazy){ this.favicon(true); lenient=false;} this.flag("Vitally"); break; case "Whatlinkshere": this.flag("Links"); break;} }else{ this.flag("*");} break;} if(lenient){ if(this.less||typeof this.config.favicon==="string"){ this.favicon(false);}} }; PaneMk.furnish=function{ PaneMk.fresh; }; if(!PaneMk.loaded){ PaneMk.loaded=true; PaneMk.fire;} }(window.mediaWiki,window.jQuery)); /// EOF paneMarker/r.js