User:PerfektesChaos/js/editorContent/r.js

This is an old revision of this page, as edited by PerfektesChaos (talk | contribs) at 16:07, 24 March 2013 (1.0). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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/editorContent/r.js
/// 2013-03-22 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#A0C2733E#
/// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA)
///<nowiki>
(function(mw,$){
"use strict";
var EdiCt,version=1.0;
if(typeof mw.libs.editorContent!=="object"||!mw.libs.editorContent){
mw.libs.editorContent={};}
EdiCt=mw.libs.editorContent;
EdiCt.doc="[[w:en:User:PerfektesChaos/js/editorContent]]";
EdiCt.type="editorContent";
EdiCt.vsn=version;
if(!EdiCt.loaded){
EdiCt.config={CodeEditor:{css:"\\.css$",javascript:"\\.js$",lua:["/#s[^/]*/#M:",2]
},VisualEditor:false,WikEd:true
};
EdiCt.g={nsN:mw.config.get("wgNamespaceNumber")};
EdiCt.wikis={dewiki:{s:"Spielwiese"},enwiki:{s:"sandbox"}
};}
EdiCt.fire=function(){
var cnf=EdiCt.config;
EdiCt.furnish(EdiCt.config,EdiCt.opt);
EdiCt.g.stuff=mw.config.get("wgPageName");
if(typeof cnf.VisualEditor!=="boolean"){
cnf.VisualEditor=EdiCt.fulfil(cnf.VisualEditor);}
if(!cnf.VisualEditor){
EdiCt.visualEditor();}
if(EdiCt.g.nsN>0&&EdiCt.g.nsN%2===0&&EdiCt.g.nsN!==828){
EdiCt.codeEditor();}
if(cnf.WikEd){
if(!mw.config.get("wgCodeEditorCurrentLanguage")){
mw.loader.using(["jquery.client"],EdiCt.wikEd);}}
};
EdiCt.flip=function(apply){
var env,r=apply;
if(typeof r==="string"){
if(r.indexOf("#")>=0){
if(r.indexOf("#M")>=0){
env=mw.config.get("wgFormattedNamespaces");
if(env){
r=r.replace(/#M/g,env["828"]);}}
if(r.indexOf("#s")>=0){
env=mw.config.get("wgDBname");
env=this.wikis[env];
if(env){
r=r.replace(/#s/g,env.s);}}}}
return r;
};
EdiCt.fulfil=function(apply){
var i,n,r=false,re=false;
switch(typeof apply){
case "boolean":
r=apply;
break;
case "string":
re=apply;
break;
case "object":
if(apply){
n=apply.length;
if(n){
for(i=1;i<n;i++){
if(apply[i]===this.g.nsN){
re=apply[0];
break;}}}}
break;}
if(re){
re=new RegExp(re);
r=re.test(this.g.stuff);}
return r;
};
EdiCt.furnish=function(already,add){
var p,v;
if(typeof add==="object"&&add){
for(p in add){
v=add[p];
if(typeof already[p]==="object"){
if(v){
this.furnish(already[p],v);
}else{
already[p]=false;}
}else if(already[p]===false||v!==true){
already[p]=v;}}}
};
EdiCt.codeEditor=function(){
var mode,v,base="|css|javascript|json|lua|",depend=["ext.codeEditor","ext.codeEditor.ace","jquery.ui.resizable","jquery.wikiEditor"],select=mw.config.get("wgCodeEditorCurrentLanguage");
if(!select){
for(mode in this.config.CodeEditor){
v=this.config.CodeEditor[mode];
switch(typeof v){
case "string":
if(this.fulfil(this.flip(v))){
select=mode;}
break;
case "object":
if(v){
if(v.length){
v[0]=this.flip(v[0]);
if(this.fulfil(v)){
select=mode;}}}
break;}}}
if(select){
select=select.toLowerCase();
mw.config.set("wgCodeEditorCurrentLanguage",select);
if(base.indexOf("|"+select+"|")<0){
depend.push("ext.codeEditor.ace.modes");}
mw.loader.load(depend);}
};
EdiCt.visualEditor=function(){
if(!EdiCt.config.VisualEditor){
mw.util.$content.find("#ca-ve-edit").remove();}
};
EdiCt.wikEd=function(){
EdiCt.g.client=$.client.profile();
if(!EdiCt.g.client){
EdiCt.g.client={};}
if(EdiCt.g.client.layout==="gecko"){
if(EdiCt.fulfil(EdiCt.config.WikEd)){
mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript&maxage=604800&smaxage=86400&*","text/javascript");}}
};
if(!EdiCt.loaded){
EdiCt.loaded=true;
if(EdiCt.g.nsN>=0){
EdiCt.g.scope=mw.config.get("wgAction");
if(EdiCt.g.scope==="edit"||EdiCt.g.scope==="submit"){
mw.loader.using(["user","mediawiki.util"],EdiCt.fire());}}
mw.loader.state("ext.gadget."+EdiCt.type,"ready");}
}(mediaWiki,jQuery));
/// EOF</nowiki>editorContent/r.js