User:PerfektesChaos/js/paneMarker/r.js

/// mw:User:PerfektesChaos/js/paneMarker/r.js /// 2012-06-13 PerfektesChaos@de.wikipedia /// Fingerprint:#0#FDC44762# /// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA) /// (function(mw,$){ "use strict"; if(typeof mw.libs.paneMarker!=="object"){ mw.libs.paneMarker={opt:{}};} mw.libs.paneMarker.vsn=1.2; mw.libs.paneMarker.heads="|dewiki|"; mw.libs.paneMarker.favicon=function{ var $apple,$head=$(document).find("head"),$favicon,i,n,apple=false,png=["wmf","f7"], show,site=this.site; if(site==="commonswiki"){ apple=["commons","70"]; png=["commons","e7"]; }else if(site==="metawiki"){ png=["meta","96"]; }else if(site==="testwiki"){ apple=["wikipedia","f1"]; png=["testwiki","b6"]; }else if(site==="mediawikiwiki"){ apple=["mediawiki","b6"]; png=["mediawiki","fa"]; }else if(site.slice(-4)==="wiki"){ apple=["wikipedia","f1"]; png=["wikipedia","fb"]; }else if(site.slice(-9)==="wikibooks"){ png=["wikibooks","7e"]; }else if(site.slice(-8)==="wikinews"){ apple=["wikinews","a9"]; png=["wikinews","cc"]; }else if(site.slice(-9)==="wikiquote"){ png=["wikiquote","cb"]; }else if(site.slice(-10)==="wikisource"){ png=["wikisource","f4"]; }else if(site.slice(-11)==="wikiversity"){ png=["wikiversity","95"]; }else if(site.slice(-10)==="wiktionary"){ png=["wikipedia","fb"]; }else{ apple=["wmf","a9"];} if($head.length){ $favicon=$head.find("link").filter(function{ return(this.rel==="shortcut icon"); }); $apple=$head.find("link").filter(function{ return(this.rel==="apple-touch-icon"); }); if($apple.length===1){ show=false; switch(typeof this.config.appleIcon){ case "string": show=this.config.appleIcon; break; case "boolean": if(!this.config.appleIcon){ break;} default: if(apple){ show=this.file("Apple-touch-icon-red-",apple[0],apple[1]);}} if(show){ $apple.detach; $apple.attr("href",show); $head.append($apple);}} n=$favicon.length; if(n){ show=false; switch(typeof this.config.faviconPNG){ case "string": show=this.config.faviconPNG; break; case "boolean": if(!this.config.faviconPNG){ break;} default: show=this.file("Favicon-red-",png[0],png[1]);} if(show||this.config.faviconICO){ for(i=0;i1){ $favicon=$favicon.eq(0);} if(typeof this.config.faviconICO==="string"){ $favicon.attr("href",this.config.faviconICO); $favicon.attr("type","image/x-icon"); $head.append($favicon); if(show){ $favicon=$favicon.clone;}} if(show){ $favicon.attr("type","image/png"); $favicon.attr("href",show); $head.append($favicon);}}}} }; mw.libs.paneMarker.file=function(album,assign,access){ var r="//upload.wikimedia.org/wikipedia/commons/"+access.substr(0,1)+"/"+access+"/"+album+assign+".png"; return r; }; mw.libs.paneMarker.flag=function(action){ var c=-1,learn=true; if(typeof this.config.chars==="boolean"){ c=this.config.chars; }else if(this.heads.indexOf(this.site)<0){ c=this.config["char"+action]; learn=false;} if(c){ if(learn){ c=this.config["char"+action]; learn=!c;} if(learn){ switch(action){ case "Diff": c=916; break; case "History": c=8595; break; case "Vitally": if(c===-1){ if(!this.lazy){ c=false; break;}} c="*"; break; default: c=false;}} if(c){ if(typeof c==="number"){ c=String.fromCharCode(c);} if(typeof c==="string"){ if(this.config.rightleft){ document.title=document.title+" "+c; }else{ document.title=c+" "+document.title;}}}} }; mw.libs.paneMarker.flip=function{ var e,i,o,s,t; if(this.nsN>0){ o=mw.config.get("wgNamespaceIds"); for(e in o){ if(o.hasOwnProperty(e)){ if(e.length<4){ if(o[e]===this.nsN){ o=mw.config.get("wgFormattedNamespaces"); s=o[this.nsN]; o=mw.config.get("wgPageName"); o=o.replace(/_/ig," "); if(!o.indexOf(s+":")){ t=document.title; i=t.indexOf(o); if(i>=0){ document.title=(i?t.substr(0,i):"")+e.toUpperCase+t.substr(i+s.length);}} break;}}}}} }; mw.libs.paneMarker.fresh=function{ if(typeof this.opt==="object"&&this.opt){ this.config=this.opt; }else{ this.config={};} this.site=mw.config.get("wgDBname"); this.nsN=mw.config.get("wgNamespaceNumber"); this.flip; switch(mw.config.get("wgAction")){ case "edit": case "submit": if(jQuery.browser){ if(jQuery.browser.msie){ if(jQuery.browser.version<9){ this.lazy=true;}}} if(!this.lazy){ this.favicon;} 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){ if(mw.config.get("wgCanonicalSpecialPageName")==="Upload"){ this.favicon; this.flag("Vitally");}} break;} }; mw.libs.paneMarker.furnish=function{ mw.libs.paneMarker.fresh; }; if(window&&!mw.libs.paneMarker.loaded){ mw.libs.paneMarker.loaded=true; mw.loader.using(["user","mediawiki.util"], mw.libs.paneMarker.furnish);} mw.loader.state("ext.gadget.paneMarker","ready"); }(mediaWiki,jQuery)); /// EOF paneMarker/r.js