/// User:PerfektesChaos/js/editorContent/r.js
/// 2018-08-24 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#2C390C63#
/// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA)
///<nowiki>
(function(mw,$){
"use strict";
var EdiCt="editorContent",Version=1.3;
if(typeof mw.libs[EdiCt]!=="object"||!mw.libs[EdiCt]){
mw.libs[EdiCt]={};}
mw.libs[EdiCt].type=EdiCt;
EdiCt=mw.libs[EdiCt];
EdiCt.signature="ext.gadget."+EdiCt.type;
if(mw.loader.getState(EdiCt.signature)!=="ready"){
EdiCt.vsn=Version;
EdiCt.support="User:PerfektesChaos/js/"+EdiCt.type;
EdiCt.doc="[[w:en:"+EdiCt.support+"]]";
EdiCt.config={CodeEditor:{css:"\\.css$",javascript:"\\.js$",lua:["/#s[^/]*/#M:",2]
},VisualEditor:false,WikEd:true
};
EdiCt.wikis={dewiki:{s:"Spielwiese"},enwiki:{s:"sandbox"}
};}
EdiCt.fire=function(){
var env=mw.config.get(["wgAction","wgPageContentModel","wgPageName"]);
if(typeof EdiCt.opt!=="object"){
EdiCt.opt=false;}
EdiCt.furnish(EdiCt.config,EdiCt.opt);
EdiCt.g.stuff=env.wgPageName;
EdiCt.g.model=env.wgPageContentModel;
EdiCt.g.scope=env.wgAction;
if(EdiCt.g.scope==="edit"||EdiCt.g.scope==="submit"){
EdiCt.fit();}
};
EdiCt.fit=function(){
var cnf=EdiCt.config;
if(this.g.model!=="wikitext"||(this.g.nsN>0&&this.g.nsN%2===0&&this.g.nsN!==828)){
mw.loader.using(["jquery.client"],EdiCt.codeEditor);}
if(cnf.WikEd){
if(!mw.config.get("wgCodeEditorCurrentLanguage")){
mw.loader.using(["jquery.client"],EdiCt.wikEd);}}
};
EdiCt.flip=function(apply){
var r=apply,env;
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 r=false,re=false,i,n;
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(){
EdiCt.g.client=$.client.profile();
if(!EdiCt.g.client){
EdiCt.g.client={name:"?"};}
if("chrome firefox".indexOf(EdiCt.g.client.name)<0){
mw.loader.using(["mediawiki.cookie"],EdiCt.codeEditorDisable);
}else{
EdiCt.codeEditorStart();}
};
EdiCt.codeEditorDisable=function(){
mw.hook("codeEditor.configure").add(function(){
var context=mw.util.$content.find("#wpTextbox1").data("wikiEditor-context");
if(context&&context.codeEditor&&context.api&&context.fn){
context.fn.disableCodeEditor();
context.api.removeFromToolbar(context,{"section":"main","group":"format",
"tools":"codeEditor"});
$.removeCookie("wikiEditor-0-codeEditor-enabled");}
});
};
EdiCt.codeEditorStart=function(){
var mode,v,base="|css|javascript|json|lua|",depend=["ext.codeEditor","ext.codeEditor.ace","jquery.ui","ext.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);}
if(typeof window.wikEd==="object"&&window.wikEd){
if(window.wikEd.useWikEd){
window.wikEd.turnedOn=false;}}
};
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("https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript","text/javascript");}}
};
function fire(){
var rls;
if(mw.loader.getState(EdiCt.signature)!=="ready"){
rls={};
rls[EdiCt.signature]="ready";
mw.loader.state(rls);
EdiCt.g={nsN:mw.config.get("wgNamespaceNumber")};
if(EdiCt.g.nsN>=0){
mw.loader.using(["user","user.options","mediawiki.util"],EdiCt.fire);}}}
fire();
}(window.mediaWiki,window.jQuery));
/// EOF</nowiki>editorContent/r.js