Jump to content

User:PerfektesChaos/js/jsonXMLutils/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.
/// jsonXMLutils.js
/// 2018-08-26 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#147F508B#
///<nowiki>
(function(mw,$){
"use strict";
var Version=1.8,Sign="jsonXMLutils",Shop="w:en:User:PerfektesChaos/js/",Spooling="//upload.wikimedia.org/wikipedia/commons/d/de/Ajax-loader.gif",Editor={},Hilite={},I18N={},TData={},TDJPP={},TDtxt={},Env,JXU;
TData.vorlagenmeister="|dewiki|dewikivoyage|huwiki|";
TDJPP.templateJSON="|dewiki|";
Hilite.dewiki=function(assign){
var style,$box;
if(assign==="xml"){
style=".source-xml {font-size: 90%;}";
$box=$("#intro-xml-page");
mw.util.addCSS(style);
$box.detach();
$box.css({"margin-bottom":"1em","margin-top":"1em",
"position":"relative","top":"auto"
});
Hilite.$highlight.eq(0).before($box);
$("#mw-content-text").empty();}
};
TData.dewiki=function(action,adjust){
var s=Env.wgTitle.replace(/\/.*$/,"");
return '<?mediawiki "{{XML-Warnung|'+s+'}}"?>\n'+adjust;
};
TData.huwiki=function(action,adjust){
var s=Env.wgTitle.replace(/\/.*$/,"");
return '<?mediawiki "{{XML|'+s+'}}"?>\n'+adjust;
};
TDJPP.otherLanguages=["simple","tokipona"];
I18N.texts={
btn_Submit:{en:"Submit",de:"Anwenden"},btn_TD_0:{en:"TemplateData generation",de:"TemplateData generieren"},btn_TD_00:{en:"TemplateData generator",de:"TemplateData Generator"},btn_TD_PP:{en:"TemplateData pretty print",de:"TemplateData formatieren"},btn_TD2XML:{en:"TemplateData to XML",de:"TemplateData zu XML"},btn_XML2TD:{en:"XML to TemplateData",de:"XML zu TemplateData"},PP_DescInvalid:{en:"ERROR: description text is not a string",de:"FEHLER: Beschreibungstext ist keine Zeichenkette"},PP_EqualSign:{en:"STRANGE! Equal sign '=' in parameter name. This will not work on transclusion.",de:"WIRR! Gleichheitszeichen '=' im Parameternamen. Das wird bei der Einbindung nicht funktionieren."},PP_H2:{en:"Recommendations and errors",de:"Empfehlungen und Fehlermeldungen"},PP_InvalidType:{en:"ERROR: Invalid type of a component",de:"FEHLER: Unerlaubter Datentyp einer Komponente."},PP_LabelLong:{en:"label seems to be rather long",de:"<code>label</code> scheint recht lang zu sein."},PP_LanguageCode:{en:"WARNING: Invalid language code",de:"WARNUNG: Fehlerhafter Sprachcode"},PP_Lethal:{en:"ERROR: Severe problem detected",de:"FEHLER: Erhebliches Problem gefunden"},PP_Lethals:{en:"ERROR: Severe problems detected",de:"FEHLER: Erhebliche Probleme gefunden"},PP_MandParams:{en:"ERROR: mandatory 'params' missing",de:"FEHLER: Pflichtparameter <code>params</code> nicht gefunden"},PP_ParamDup:{en:"ERROR: Duplicated parameter name",de:"FEHLER: Doppelter Parametername"},PP_PipeSymbol:{en:"STRANGE! Pipe symbol <code>|</code> in parameter name. This will not work on transclusion.",de:"WIRR! Pipe-Symbol <code>|</code> im Parameternamen. Das wird bei der Einbindung nicht funktionieren."},PP_QuotMark:{en:"STRANGE! Quotation mark <code>\"</code>"+" in parameter name.",de:"WIRR!"+" Begrenzer <code>\"</code>"+" im Parameternamen."},PP_RequiredAuto:{en:"CONFLICT"+" Both 'required' and 'autovalue'.",de:"Konfllkt:"+" Sowohl 'required'"+" als auch 'autovalue'."},PP_ShortDesc:{en:"description quite short",de:"Der Beschreibungstext"+" scheint recht kurz zu sein."},PP_TypeDeprecated:{en:"DEPRECATED: Parameter 'type';"+" remove <code>string/</code>",de:"VERALTET (Parameter <code>type</code>):"+" vorangestelltes"+" <code>string/</code> entfernen"},PP_TypeUnknown:{en:"WARNING: Parameter 'type'"+" value not recognized",de:"WARNUNG: Parameter <code>type</code> *"+" Wert nicht erkannt"},PP_UnknownItem:{en:"WARNING: Could not recognize",de:"WARNUNG: Komponente nicht erkannt"}
};
I18N.translate={
"als":"de","bar":"de",
"dsb":"de","frr":"de",
"gsw":"de","hsb":"de",
"ksh":"de","lb":"de",
"nds":"de","pdc":"de",
"pdt":"de","pfl":"de",
"sli":"de","stq":"de",
"vmf":"de"};
function face(){
if(typeof mw.libs[Sign]==="object"&&mw.libs[Sign]&&!JXU){
JXU=mw.libs[Sign];
JXU.vsn=Version;
JXU.doc="[["+Shop+Sign+"]]";}}
function facet(applied){
var r;
face();
if(JXU&&typeof JXU[applied]!=="undefined"){
r=JXU[applied];}
return r;}
Editor.fiat=function(){
mw.loader.load(Editor.sourcemods+"mode-xml.js");
mw.config.set("wgCodeEditorCurrentLanguage","xml");
};
Editor.fire=function(){
this.sourcebase="mediawiki/extensions/CodeEditor";
this.sourcebase=this.sourcebase.replace(/\//g,"%2F");
this.sourcebase="https://git.wikimedia.org/raw/"+this.sourcebase+"/HEAD/";
this.sourcemods="modules/ace/";
this.sourcemods=this.sourcemods.replace(/\//g,"%2F");
this.sourcemods=this.sourcebase+this.sourcemods;
mw.loader.using(["ext.codeEditor","ext.codeEditor.ace","jquery.ui","ext.wikiEditor"],Editor.fiat);
};
Hilite.fair=function(adjust,assign,after,abort){
var failed=abort,fine=function(a){
if(typeof a==="object"&&typeof a.parse==="object"&&typeof a.parse.text==="object"&&typeof a.parse.text["*"]==="string"){
after(a.parse.text["*"]);
}else if(typeof abort==="function"){
abort("API: Strange answer");
}else{
after("<pre>"+adjust+"</pre>");}
},source="<syntaxhighlight lang='"+assign+"' id='"+Sign+"-hilite-"+assign+"'>"+adjust+"</syntaxhighlight>";
if(failed===false){
failed=function(){};
}else if(typeof failed!=="function"){
failed=function(){after("<pre>"+adjust+"</pre>");};}
if(typeof Hilite.api!=="object"){
Hilite.api=new mw.Api();}
Hilite.api.post({action:"parse",contentmodel:"wikitext",disablepp:true,prop:"text",text:source
}).done(fine).fail(failed);
mw.loader.load(["ext.pygments"]);
};
Hilite.fetch=function(){
var style=".mw-code {padding-top: 0.5em;}.source-xml {font-size:      90%;overflow:       auto;padding-bottom: 1em;}";
Hilite.fair(Hilite.source,"xml",Hilite.fetched,false);
mw.util.addCSS(style);
};
Hilite.fetched=function(arrived){
var i,$h1;
for(i=0;i<Hilite.remove.length;i++){
Hilite.remove[i].remove();}
Hilite.$highlight=$(arrived);
$h1=$("#firstHeading");
$h1.after(Hilite.$highlight);
if(!Env.wgDBname){
Env.wgDBname=mw.config.get("wgDBname");}
if(typeof Hilite[Env.wgDBname]==="function"){
Hilite[Env.wgDBname]("xml");}
};
Hilite.fire=function(){
var large=facet("hiliteLarge"),$paras=mw.util.$content.find("p,pre"),i,j,s,segment,start,$para;
Hilite.remove=[];
Hilite.source=false;
for(i=0;i<$paras.length;i++){
$para=$paras.eq(i);
segment=$para.text();
if(segment){
j=segment.indexOf("<");
if(!j){
start=segment;
}else if(j>0){
start=segment.substr(j);
s=segment.substr(0,j).replace(/\s+/g,"");
j=s.length;}
if(!j){
if(start.substr(0,2)!=="<?"||large){
if(Hilite.source){
Hilite.source=Hilite.source+"\n"+segment;
}else{
Hilite.source=segment;}}
Hilite.remove.push($para);}}}
if(Hilite.source){
mw.loader.using(["mediawiki.api","ext.geshi.language.xml","ext.geshi.local"],Hilite.fetch);}
};
Hilite.flow=function($around){
var $img;
if(!$around.children().length){
$img=$("<img />");
$img.attr({src:Spooling,id:"ajax_throbber",height:"20",alt:"Ajax"});
$img.css({"margin-left":"10px"});
$around.append($img);}
$around.show();
};
I18N.facility=function(available){
var i,r,slang;
if(!Env.userLang){
Env.userLang=mw.config.get("wgUserLanguage").toLowerCase();}
slang=Env.userLang;
if(typeof available[slang]==="string"){
r=available[slang];
}else{
i=slang.indexOf("-",2);
if(i>0){
slang=slang.substr(0,i);
if(typeof available[slang]==="string"){
r=available[slang];}}}
if(!r){
if(typeof I18N.translate[slang]==="string"){
slang=I18N.translate[slang];
if(typeof available[slang]==="string"){
r=available[slang];}}
if(!r){
r=available.en;}}
return r;
};
I18N.fair=function(access,adapt,alter){
var el,r,say;
if(alter){
r=alter;
}else{
r=access;}
face();
if(JXU&&typeof JXU.config==="object"&&JXU.config&&typeof JXU.config[access]==="object"){
el=JXU.config[access];}
if(!el){
el=I18N.texts[access];}
if(el){
if(adapt){
say=I18N.facility(el);
if(say){
r=say;
}else if(typeof alter!=="string"){
r="???"+access+"???";}
}else{
if(!Env.wgDBname){
Env.wgDBname=mw.config.get("wgDBname");}
if(typeof el[Env.wgDBname]==="string"){
r=el[Env.wgDBname];
}else{
if(!Env.wgContentLanguage){
Env.wgContentLanguage=mw.config.get("wgContentLanguage");}
if(typeof el[Env.wgContentLanguage]==="string"){
r=el[Env.wgContentLanguage];}}}
}else if(adapt){
r="???"+access+"???";}
return r;
};
TData.fire=function(){
var rq={action:"templatedata"};
rq.titles="Template:"+Env.wgTitle.replace(/\/.*$/,"");
TData.api=new mw.Api();
TData.api.get(rq).done(TData.feed).fail(TData.fault);
};
TData.factory=function(){
var p,params,s,sign,story;
if(TData.templateData){
s=' <TemplateUsage output="collapse">\n'+'   <Group>\n';
if(typeof TData.templateData.params==="object"&&TData.templateData.params){
params=TData.templateData.params;
for(sign in params){
if(sign&&typeof params[sign]==="object"){
s=s+'     <Parameter name="'+sign+'"';
p=params[sign];
story=TData.feature(p,"label");
if(story){
s=s+' label="'+story.replace(/</g,"&lt;")
.replace(/>/g,"&gt;")+'"';}
if(typeof p.required==="boolean"&&p.required){
s=s+' null="false"';}
if(typeof p.type==="string"){
story=TDJPP.fence(p.type,false);
if(story!=="unknown"){
s=s+' type="'+story+'"';}}
s=s+'>\n';
story=TData.feature(p,"description");
if(story){
s=s+'       <Help>'+story.replace(/</g,"&#60;")
.replace(/>/g,"&#62;")+'</Help>\n';}
if(typeof p["default"]==="string"){
story=p["default"].replace(/^\s+/,"")
.replace(/\s+$/,"");
if(story){
s=s+'       <Default>'+story.replace(/</g,"&lt;")+'</Default>\n';}}
if(typeof p.autovalue==="string"){
story=p.autovalue.replace(/^\s+/,"")
.replace(/\s+$/,"");
if(story){
s=s+'       <Autovalue>'+story.replace(/</g,"&lt;")+'</Autovalue>\n';}}
s=s+'     </Parameter>\n';}}}
s=s+'   </Group>\n'+' </TemplateUsage>';
if(!Env.wgDBname){
Env.wgDBname=mw.config.get("wgDBname");}
if(typeof TData[Env.wgDBname]==="function"){
s=TData[Env.wgDBname]("2xml",s);}
s='<?xml version="1.0" encoding="utf-8"?>\n'+s;
Hilite.fair(s,"xml",TData.fiat,false);
Hilite.flow(TData.$throbber);
TData.lead=true;}
};
TData.fault=function(arrived){
window.console.log(arrived);
window.console.dir(arrived);
};
TData.feature=function(assembly,access){
var r,s,slang,t;
switch(typeof assembly[access]){
case "object":
if(typeof Env.wgContentLanguage!=="string"){
Env.wgContentLanguage=mw.config.get("wgContentLanguage");}
t=assembly[access];
if(t){
if(typeof t[Env.wgContentLanguage]==="string"){
r=t[Env.wgContentLanguage];}
if(!r){
slang=Env.wgContentLanguage+"-";
for(s in t){
if(!s.indexOf(slang)){
r=t[s];
if(r){
break;}}}}}
break;
case "string":
r=assembly[access];
break;}
if(r){
r=r.replace(/^\s+/,"")
.replace(/\s+$/,"")
.replace(/\\/g,"\\" );}
return r;
};
TData.feed=function(arrived){
var page,suitable;
if(typeof arrived.pages==="object"){
TData.templateData=false;
for(page in arrived.pages){
if(TData.templateData){
TData.fault(arrived);
}else{
TData.templateData=arrived.pages[page];}}
suitable="|edit|submit|";
TData.learn=(suitable.indexOf(Env.wgAction)>=0);
if(TData.templateData){
TData.live=true;
if(!Env.wgDBname){
Env.wgDBname=mw.config.get("wgDBname");}
suitable="|"+Env.wgDBname+"|";
TData.lmx=(TData.vorlagenmeister.indexOf(suitable)>=0||facet("vorlagenmeister"));}
$(TData.furnish);
}else{
TData.fault(arrived);}
};
TData.fetch=function(){
var $ta=TData.$field(),got,r,s;
if($ta){
s=$ta.val();
got=/<\s*templatedata\s*>/i.exec(s);
if(got){
s=s.substr(got.index+got[0].length);
got=/}\s*<\s*\/\s*templatedata\s*>/i.exec(s);
if(got){
s=s.substr(0,got.index+1);
try{
r=JSON.parse(s);
}catch(e){
TDJPP.flush();
r="<strong style='color:#FF0000'>ERROR in JSON</strong>";}}}}
return r;
};
TData.fiat=function(arrived){
var $highlight=$(arrived),$div=TData.$fold();
$div.append($highlight);
TData.$throbber.hide();
};
TData.$field=function(){
var $r=false,$form;
if(this.$textarea){
$r=this.$textarea;
}else{
$form=mw.util.$content.find("#editform");
if($form.length){
this.$textarea=$form.find("#wpTextbox1");
if(this.$textarea.length){
$r=this.$textarea;
}else{
this.$textarea=false;}}}
return $r;
};
TData.fine=function(){
var td;
if(TData.templateData&&TData.lead){
td=TData.templateData;
TData.lead=false;
}else if(TData.learn){
td=TData.fetch();}
if(td){
Hilite.fair(TDJPP.facility(td,3),"javascript",TData.finish,false);
Hilite.flow(TData.$throbber);}
};
TData.finish=function(arrived){
var $highlight=$(arrived),$div=TData.$fold(),$report=TDJPP.$failures();
if($report){
$div.append($report);}
$div.append($highlight);
TData.$throbber.hide();
};
TData.$fold=function(){
if(typeof this.$div==="object"){
this.$div.empty();
}else{
this.$div=$("<div />");
this.$div.attr({"id":Sign+"-code"});
this.$div.css({"margin-bottom":"1em","margin-top":"1em"});
if(this.learn){
$("#mw-content-text").prepend(this.$div);
}else{
$("#mw-content-text").append(this.$div);}}
return this.$div;
};
TData.$form=function(apply,$append){
var $r=$("<button />");
$r.attr({"id":Sign+"-"+apply.sign});
$r.click(apply.click);
$r.css({"margin-left":"2em"});
if(apply.i18n){
$r.text(I18N.fair(apply.i18n,true,apply.i18n));}
$append.append($r);
return $r;
};
TData.furnish=function(){
var $div=$("<div />"),button,$root;
if(TData.learn){
$root=$(".tdg-editscreen-main-helplink");
if(!$root.length){
$root=false;}}
if(!$root){
$root=$("#mw-content-text");}
$div.css({"margin-bottom":"1em","margin-top":"1em"});
$root.after($div);
if(TData.live){
button={click:TData.fine,i18n:"btn_TD_PP",sign:"btn_TD_PP"
};
TData.$form(button,$div);
if(TData.lmx){
button={click:TData.factory,i18n:"btn_TD2XML",sign:"btn_TD2XML"
};
TData.$form(button,$div);}}
button={click:TDtxt.fire,sign:"btn_TD_0"
};
if(TData.live){
button.i18n="btn_TD_00";
}else{
button.i18n="btn_TD_0";}
TData.$form(button,$div);
TData.$throbber=$("<span>");
$div.append(TData.$throbber);
TData.lead=true;
};
TDJPP.facility=function(apply,adjust){
var i=0,k=2,m=(typeof adjust==="number"?adjust:0),r="",s;
TDJPP.flush();
s=this.description(apply,k,m);
if(s){
r=s;
i=k;}
s=this.params(apply,k,i,m);
if(s){
if(r){
r=r+",\n  ";}
r=r+s;
i=k;}
s=this.sets(apply,k,i,m);
if(s){
if(r){
r=r+",\n  ";}
r=r+s;}
s=this.format(apply,k,i,m);
if(s){
if(r){
r=r+",\n  ";}
r=r+s;}
r="{ "+r+"\n}";
if(!Env.wgDBname){
Env.wgDBname=mw.config.get("wgDBname");}
s="|"+Env.wgDBname+"|";
if(typeof this[Env.wgDBname]==="function"){
r=this[Env.wgDBname](r);
}else if(TDJPP.templateJSON.indexOf(s)>=0){
r=this.further(r);}
this.fields(apply,["description","params","sets","maps","format","paramOrder","title"],"<templatedata>");
return r;
};
TDJPP.bad=["DescInvalid","InvalidType","MandParams","ParamDup","UnknownItem"];
TDJPP.extension={"description":[true,40,"ShortDesc"],"label":[false,25,"LabelLong"],
"param.description":[true,5,"ShortDesc"]
};
TDJPP.aliases=function(array,adjust){
var r="",i;
if(typeof array.length==="number"&&array.length){
for(i=0;i<array.length;i++){
if(i){
r=r+", ";}
r=r+this.fair(""+array[i]);}
r="[ "+r+" ]";
}else if(adjust>=4){
r="[ ]";}
return r;
};
TDJPP.description=function(apply,align,adjust){
var s=typeof apply.description,r;
switch(s){
case "object":
case "string":
r=this.folder(apply.description,adjust,align+15,"description");
break;
case "undefined":
if(adjust>1){
r='""';}
break;
default:
this.failed("InvalidType",".description: "+s);
r='"['+s+']"';}
if(r){
r='"description": '+r;
}else{
r="";}
return r;
};
TDJPP.param=function(apply,access,align,after,adjust){
var e=["label","description","type","required","suggested","default","autovalue","example","inherits","deprecated","aliases"],max=0,r="",i,n,p,s,slot,v;
if(access.indexOf('"')>=0){
this.failed("QuotMark",access);
}else if(access.indexOf("=")>=0){
this.failed("EqualSign",access);
}else if(access.indexOf("|")>=0){
this.failed("PipeSymbol",access);}
if(typeof apply.params[access]==="object"){
p=apply.params[access];}
if(p){
this.fields(p,e,"params:"+access);
for(i=0;i<e.length;i++){
s=e[i];
if(typeof p[s]!=="undefined"){
v=p[s];
if(v||adjust>=3){
switch(s){
case "label":
v=this.folder(v,adjust,after,0,s);
break;
case "description":
case "example":
slot="param."+s;
v=this.folder(v,adjust,after,0,slot);
break;
case "type":
v=this.fence(""+v,true);
case "default":
case "autovalue":
case "inherits":
v=this.fair(""+v);
break;
case "required":
if(v&&typeof p.autovalue==="string"&&p.autovalue){
this.failed("RequiredAuto",access);}
case "suggested":
if(typeof v==="boolean"){
v=(v?"true":"false");
}else{
v="true";}
break;
case "deprecated":
if(typeof v==="boolean"){
v=(v?"true":"false");
}else{
v=""+v;}
break;
case "aliases":
if(typeof v==="object"){
v=this.aliases(v);
}else{
v="[ ]";}
break;}}
}else{
v=undefined;}
if(!v&&adjust>=2){
switch(s){
case "label":
case "description":
v='""';
break;
case "type":
v='"unknown"';
break;
case "required":
v="false";
break;}}
if(v){
e[i]=[s,v];
n=s.length;
if(n>max){
max=n;}}}
for(i=0;i<e.length;i++){
p=e[i];
if(typeof p==="object"){
if(r){
if(i){
r=r+",";}
r=r+after;
if(i){
r=r+"  ";}}
s=p[0];
r=r+this.fair(s)+":"+this.fill(max-s.length+1)+p[1];}}
r="{ "+r+" }";
if(align<0){
r=after+r;
}else{
r=this.fill(align-access.length+1)+r;}
}else{
this.failed("InvalidType","params:"+access);
r=' "?? InvalidType ??"';}
r=this.fair(access)+":"+r;
return r;
};
TDJPP.params=function(apply,align,adjust){
var max=0,r="",i,k,n,ord,s,shift;
if(typeof apply.params==="object"&&apply.params){
if(typeof apply.paramOrder==="object"&&apply.paramOrder&&apply.paramOrder.length){
ord=apply.paramOrder;
}else{
ord=[];
for(s in apply.params){
s=""+s;
if($.inArray(s,ord)<0){
ord.push(s);
}else{
this.failed("ParamDup",s);}}}
for(i=0;i<ord.length;i++){
n=ord[i].length;
if(n>max){
max=n;}}
n=align;
if(max>3){
k=-1;
n+=6;
s=this.fill(align+3);
}else{
k=max;
n+=max+16;
s=this.fill(align+12);}
shift="\n"+this.fill(n);
for(i=0;i<ord.length;i++){
if(i){
r=r+",\n"+s;}
r=r+this.param(apply,ord[i],k,shift,adjust);}
}else{
this.failed("MandParams","?!?!");}
r='"params": {'+(k<0?"\n     ":" ")+r+"\n"+this.fill(align+10)+"}";
return r;
};
TDJPP.sets=function(apply,align,adjust){
var r="",i;
if(typeof apply.sets==="object"&&apply.sets&&typeof apply.sets.length==="number"&&apply.sets.length){
for(i=0;i<apply.sets.length;i++){
if(i){
r=r+", ";}
r=r+this.fair(apply.sets[i]);}
r='"sets": [ '+r+" ]";
}else if(adjust>=4){
r='"sets": [ ]';}
return r;
};
TDJPP.format=function(apply /*,align*/){
var r;
if(typeof apply.format==="string"&&apply.format){
if(/\bblock\b/i.test(apply.format)){
r='"block"';
}else{
r='"inline"';}
r='"format": '+r;
}else{
r="";}
return r;
};
TDJPP.failed=function(alert,add){
var cClass;
if(typeof this.complaints!=="object"){
this.complaints={};}
if(typeof this.complaints[alert]!=="object"){
this.complaints[alert]={};}
cClass=this.complaints[alert];
if(typeof cClass[add]==="number"){
cClass[add]=cClass[add]++;
}else{
cClass[add]=1;}
};
TDJPP.$failures=function(){
var m=0,details,n,strange,subject,$code,$div,$h2,$li1,$li2,$span,$ul1,$ul2,$r;
if(typeof this.complaints==="object"){
$r=$("<div />");
$r.attr({"id":Sign+"-JSON-report"});
$h2=$("<h2 />");
$h2.text(I18N.fair("PP_H2",true));
$r.append($h2);
$ul1=$("<ul />");
for(strange in this.complaints){
details=this.complaints[strange];
$li1=$("<li />");
$span=$("<span />");
if($.inArray(strange,TDJPP.bad)>=0){
m++;
$span.css({"color":"#FF0000","font-weight":"bold"});}
$span.html(I18N.fair("PP_"+strange,true));
$li1.append($span);
$ul2=$("<ul />");
for(subject in details){
$li2=$("<li />");
n=details[subject];
if(n>1){
$span=$("<span />");
$span.css({"margin-right":"2em"});
$span.text(n+"&times;");
$li2.append($span);}
$code=$("<code />");
$code.text(subject);
$li2.append($code);
$ul2.append($li2);}
$li1.append($ul2);
$ul1.append($li1);}
if(m){
$div=$("<div />");
$div.css({"border":"#FF0000 3px solid","color":"#FF0000",
"font-weight":"bold","padding":"1em"});
$div.text(I18N.fair("PP_Lethal"+(m>1?"s":""),true));
$r.append($div);}
$r.append($ul1);
}else{
$r=false;}
return $r;
};
TDJPP.fair=function(adapt,about){
var l,m,n,o;
if(typeof TDJPP.extension[about]==="object"){
n=adapt.length;
o=TDJPP.extension[about];
m=o[1];
if(o[0]){
l=(n<m);
}else{
l=(n>m);}
if(l){
this.failed(o[2],adapt);}}
return "\""+adapt.replace(/^\s+/,"")
.replace(/\s+$/,"")
.replace(/\n/g,"\\n")
.replace(/&nbsp;/g,"&#160;")
.replace(/\s+/g," ")
.replace(/\"/g,     '\\"' ) + "\"";
};
TDJPP.fence=function(attribute,alert){
var r=attribute.replace(/^\s+/,"")
.replace(/\s+$/,"")
.toLowerCase(),s="|boolean|content|date|line|number|string|unbalanced-wikitext|unknown|wiki-file-name|wiki-page-name|wiki-user-name|";
if(!r.indexOf("string/")){
if(alert){
this.failed("TypeDeprecated",r);}
r=r.substr(7);}
if(s.indexOf("|"+r+"|")<0){
if(alert){
this.failed("TypeUnknown",r);}
r="unknown";}
return r;
};
TDJPP.fields=function(apply,array,about){
var s;
for(s in apply){
if($.inArray(s,array)<0){
this.failed("UnknownItem",s+" @ "+about);}}
};
TDJPP.fill=function(amount){
var r="",i;
for(i=0;i<amount;i++){
r=r+" ";}
return r;
};
TDJPP.flush=function(){
this.complaints=false;
};
TDJPP.folder=function(apply,adjust,align,ahead,about){
var i,poly,r,s;
switch(typeof apply){
case "object":
if(apply){
poly=this.foreign(apply,about);
switch(typeof poly){
case "object":
r="{ ";
s="";
for(i=0;i<poly.length;i++){
r=r+s+poly[i];
if(!s){
if(typeof align==="number"){
s=",\n"+this.fill(align);
}else{
s=align;}}}
r=r+" }";
break;
case "string":
r=poly;
break;}}
break;
case "string":
r=this.fair(apply,about);
break;}
if(!r){
r=false;}
if(!r){
if(r===""&&adjust){
r='""';
}else{
r='"'+apply+'"';}}
if(ahead){
r=this.fill(ahead)+r;}
return r;
};
TDJPP.foreign=function(assigned,about){
var max=0,r=[],re1=new RegExp(" +\n","g"),re2=new RegExp("  +","g"),entry,i,n,slang,story,start;
for(slang in assigned){
story=assigned[slang];
if(typeof slang==="string"){
slang=slang.replace(/^\s+/,"")
.replace(/\s+$/,"")
.toLowerCase();
start=slang;
if(!/^[a-z]{2,8}$/.test(slang)&&!/^[a-z]{2,3}-[a-z]{2,9}(?:-[a-z]+)$/.test(slang)){
this.failed("LanguageCode",slang);
}else if(/^[a-z]{4,8}$/.test(slang)){
if($.inArray(slang,this.otherLanguages)<0){
this.failed("LanguageCode",slang);}}
}else{
slang=""+slang;
this.failed("LanguageCode",slang);}
slang=this.fair(slang);
if(typeof story==="string"){
story=story.replace(/^\s+/,"")
.replace(/\s+$/,"")
.replace(/\t/g," ")
.replace(/\r\n/g,"\n")
.replace(re1,"\n").replace(re2," ");
}else{
story=""+story;
this.failed("DescInvalid",slang);}
n=slang.length;
if(n>max){
max=n;}
story=this.fair(story,about);
r.push([n,slang,story]);}
for(i=0;i<r.length;i++){
entry=r[i];
slang=entry[1]+": ";
for(n=entry[0];n<max;n++){
slang=slang+" ";}
r[i]=slang+entry[2];}
if(r.length===1&&start===""){
r=story;}
return r;
};
TDJPP.further=function(adjust){
return "{{TemplateData|JSON=\n"+adjust+"\n}}";
};
TDtxt.fire=function(){
var $div=TData.$fold(),s;
TDtxt.$textarea=$("<textarea>");
TDtxt.$textarea.attr({rows:10});
if(TData.learn){
s=TDtxt.fishing();
if(s){
TDtxt.$textarea.val(s);}}
$div.append(TDtxt.$textarea);
TDtxt.$button=$("<button />");
TDtxt.$button.attr({"id":Sign+"-submit"});
TDtxt.$button.click(TDtxt.finish);
TDtxt.$button.css({"margin-bottom":"2em","margin-top":"5px",
"text-align":"center"});
TDtxt.$button.text(I18N.fair("btn_Submit",true,"Submit"));
$div.append(TDtxt.$button);
};
TDtxt.finish=function(){
var s=TDtxt.$textarea.val(),o={params:{}},p=o.params,g,i,re;
TData.$throbber=$("<span>");
TData.$throbber.css({"margin-left":"1em","margin-right":"1em"});
TDtxt.$button.after(TData.$throbber);
Hilite.flow(TData.$throbber);
TDtxt.$button.attr({disabled:true});
TDtxt.$textarea.attr({disabled:true});
re="{{{[^}]*}}}";
re=new RegExp(re);
if(re.test(s)){
s=TDtxt.fishing();
}else{
re="\\{\\{[^}]*\\}\\}";
re=new RegExp(re,"g");
s=s.replace(re,"");}
s=s.replace(/\|/g,"\n");
g=s.split("\n");
for(i=0;i<g.length;i++){
s=g[i];
s=s.replace(/^\s+/,"")
.replace(/=.*$/,"")
.replace(/\s+$/,"");
if(s){
p[s]={};}}
Hilite.fair(TDJPP.facility(o,3),"javascript",TData.finish,false);
};
TDtxt.fishing=function(){
var $ta=TData.$field(),r=false,got,i,k,re,s,story;
if($ta){
story=$ta.val();
i=story.indexOf("{{{");
k=story.lastIndexOf("}}}");
if(i>=0&&k>i){
story=story.substr(0,k+3).substr(i);
do{
i=story.lastIndexOf("{{{");
if(i>=0){
k=story.indexOf("}}}",i);
if(k<0){
story=story.substr(0,i);
}else{
s=story.substring(i+3,k);
story=story.substr(0,i)+story.substr(k+3);
k=s.indexOf("|");
if(k>=0){
s=s.substr(0,k);}
s=s.replace(/^\s+/,"")
.replace(/\s+$/,"");
if(s){
if(!re){
re="\\{\\{[^}]*\\}\\}";
re=new RegExp(re,"g");}
s=s.replace(re,"");}
if(s){
if(got){
if($.inArray(s,got)<0){
got.push(s);}
}else{
got=[s];}}}}
}while(i>=0);
if(got){
got.sort();
r="";
for(i=0;i<got.length;i++){
r=r+"|"+got[i]+"=\n";}}}}
return r;
};
function fire(){
Env=mw.config.get(["wgAction","wgNamespaceNumber","wgTitle"]);
if(Env.wgNamespaceNumber===10){
Env.oldid=mw.util.getParamValue("oldid");
if(!Env.oldid){
if(Env.wgTitle.search(/\/XML$/)>0){
switch(Env.wgAction){
case "view":
Env.diff=mw.util.getParamValue("diff");
if(!Env.diff){
$(Hilite.fire);}
break;
case "edit":
case "submit":
Editor.fire();
break;}}
mw.loader.using(["mediawiki.api"],TData.fire);}}}
function first(){
var signature="user.PerfektesChaos."+Sign,rls;
if(mw.loader.getState(signature)!=="ready"){
rls={};
rls[signature]="ready";
mw.loader.state(rls);
mw.loader.using(["mediawiki.util","user"],fire);}}
first();
}(window.mediaWiki,window.jQuery));
/// EOF</nowiki>jsonXMLutils.js