UNPKG

jsoneditor4code

Version:

JSON Editor for UML Diagrams developed with Javascript Code Templates based on JSON Editor of Jeremy Dorn

1 lines 316 kB
function cloneJSON(pJSON){var vJSON={};return pJSON?vJSON=JSON.parse(JSON.stringify(pJSON)):console.log("ERROR: cloneJSON(pJSON) - pJSON undefined!"),vJSON}function concat_array(a,b){for(var c=[],i=0;i<a.length;i++)c.push(a[i]);for(i=0;i<b.length;i++)c.push(b[i]);return c}function value_in_array(pValue,pArray){var ret=-1;if(pArray)for(var i=0;i<pArray.length;i++)pValue==pArray[i]&&(ret=i);else console.log("value_in_array()-Call pArray undefined");return ret}function extendHash(a,b){for(var i in b)a[i]=b[i]}function isHash(pObject){return pObject&&"object"==typeof pObject}function isArray(pObj){return isHash(pObj)&&pObj instanceof Array}function makeMap(str){for(var obj={},items=str.split(","),i=0;i<items.length;i++)obj[items[i]]=!0;return obj}function lengthHash(pHash){var vLength=0;if(isHash(pHash))for(var key in pHash)pHash.hasOwnProperty(key)&&vLength++;return vLength}function getDeleteBoolean4Hash(pHash){for(var vDelHash={},vArrID_OLD=getArray4HashID(pHash),i=0;i<vArrID_OLD.length;i++)vDelHash[vArrID_OLD[i]]=!0;return vDelHash}function updateHash4NewIDs(pHash,pArrID_NEW,pDefaultValue){for(var vDelHash=getDeleteBoolean4Hash(pHash),vDefaultValue=pDefaultValue||"",vArrID_OLD=getArray4HashID(pHash),vID="",i=0;i<pArrID_NEW.length;i++)vID=pArrID_NEW[i],pHash.hasOwnProperty(vID)?vDelHash[vID]=!1:pHash[vID]=""!=vDefaultValue?vDefaultValue+" '"+vID+"'":"";for(i=0;i<vArrID_OLD.length;i++)!0===vDelHash[vID=vArrID_OLD[i]]&&delete pHash[vID]}function updateHashSourceDestination(pSource,pDest){}function renameHashKey(pHash,old_key,new_key){var vErrorMSG="";return isHash(pHash)&&(pHash.hasOwnProperty(new_key)?vErrorMSG="ERROR: Rename Hash Key - New Key already exists":(pHash[new_key]=pHash[old_key],delete pHash[old_key],console.log("Rename hash form '"+old_key+"' to '"+new_key+"'"))),vErrorMSG}function firstKey4Hash(pHash){var vLength=0,vKey="";if(isHash(pHash))for(var key in pHash)if(pHash.hasOwnProperty(key)&&1==++vLength){vKey=key;break}return vKey}function createHash4Array(pArr,pHash){var vHash=pHash||{};if(isArray(pArr))for(var i=0;i<pArr.length;i++)vHash[pArr[i]]=pArr[i];return vHash}function createArray4HashID(pHash){var vArr=[];for(var iID in pHash)pHash.hasOwnProperty(iID)&&vArr.push(iID);return vArr}function isValidJSON(str){try{JSON.parse(str)}catch(e){return!1}return!0}function existsPathJSON(pJSON,pPath){return definedPathJSON(pJSON,pPath)==pPath}function getLastID4PathJSON(pJSON,pPath){var vID=pPath.split(".").pop()||"";return""!=vID&&vID==vID.replace(/[^0-9]/g,"")&&(vID=parseInt(vID)),console.log("getLastID4PathJSON(pJSON,'"+pPath+"')='"+vID+"' Type='"+typeof vID+"'"),vID}function set4PathJSON(pJSON,pPath,pValue){getObject4PathJSON(pJSON,pPath)[getLastID4PathJSON(pJSON,pPath)]=pValue}function get4PathJSON(pJSON,pPath){return getObject4PathJSON(pJSON,pPath)[getLastID4PathJSON(pJSON,pPath)]}function getJSON4Path(pPath){var vPathArr=pPath.split("."),vJSON;if(eval("vJSON="+vPathArr[0]),vJSON)return vPathArr.shift(),pPath=vPathArr.join("."),getObject4PathJSON(pJSON,pPath);alert("getJSON4Path('"+pPath+"') root element of path undefined")}function getObject4PathJSON(pJSON,pPath){for(var vPathArr=pPath.split("."),x=pJSON,i=0;i<vPathArr.length-1;i++)vPathArr[i].replace(/[^0-9]/g,"")==vPathArr[i]?parseInt(vPathArr[i]):vPathArr[i],x=x[ID];return x}function definedPathJSON(pJSON,pPath){for(var vPathArr=pPath.split("."),vExists=!0,x=pJSON,vSep="",vID="",vDefinedPath="",k=0,i=0;i<vPathArr.length;i++)vExists?""!=(vID=vPathArr[i].replace(/[^0-9]/g,""))&&vID==vPathArr[i]?(k=parseInt(vPathArr[i]),isArray(x)&&k<x.length?0<=k?(vDefinedPath+=vSep+vPathArr[i],vSep="."):(vExists=!1,vPathArr[i]):isHash(x)&&x.hasOwnProperty(vPathArr[i])?(vDefinedPath+=vSep+vPathArr[i],vSep="."):(vExists=!1,vPathArr[i])):isHash(x)&&x.hasOwnProperty(vPathArr[i])?(vDefinedPath+=vSep+vPathArr[i],vSep="."):(vExists=!1,vPathArr[i]):(vSep+vPathArr[i],vSep=".");return vDefinedPath}function deleteClass(){vJSONEditor.delete_ask()}function update_editor(pJSON){var vJSON=pJSON||vJSONEditor.getValue();$("#display_filename").html(class2filename(vJSON.data.classname,".json")),vEditNode=null,vJSONEditor&&vJSONEditor.aEditor&&(vEditNode=vJSONEditor.aEditor.getEditor("root.data")),vEditNode?(vJSON.data.hasOwnProperty("reposinfo")&&(vJSON.data.reposinfo.modified=getDateTime()),vEditNode.setValue(vJSON.data)):console.log("Update 'root.data' undefined"),vJSONEditor.setValue(vJSON),update_editor_post(vJSON)}function update_editor_post(pJSON){console.log("CALL: update_editor_post(pJSON) jsoneditor4code.js")}function saver4JSON(pFile){vJSONEditor.saveJSON()}function exporter4Schema(pFilename){vJSONEditor.saveSchema()}function getClassName(pJSON){var vClassName="my_class";return pJSON?pJSON.data?pJSON.data.classname?vClassName=pJSON.data.classname:console.log("ERROR: getClassName(pJSON) pJSON.data.classname undefined"):console.log("ERROR: getClassName(pJSON) pJSON.data undefined"):console.log("ERROR: getClassName(pJSON) pJSON undefined"),vClassName}function exporter4JSON(pFile){var vJSON=vJSONEditor.getValue(),vFile=class2filename(getClassName(vJSON),".json");updateModified(vJSON);var vContent=JSON.stringify(vJSON,null,4);saveFile2HDD(vFile,vContent),console.log("JSON output '"+vFile+"':\n"+vContent)}function updateModified(pJSON){pJSON&&pJSON.reposinfo&&(pJSON.reposinfo.modified=getDateTime(),console.log("reposinfo.modified updated: '"+pJSON.reposinfo.modified+"'"))}function class2filename(pClassName,pExt){var vExt=pExt||"",vFilename=pClassName||"Undefined Class";return(vFilename=(vFilename=(vFilename=vFilename.toLowerCase()).replace(/[^a-z0-9]/g,"_")).replace(/_[_]+/g,"_"))+vExt}function loader4JSON(pFileID4DOM){var fileToLoad=document.getElementById(pFileID4DOM).files[0];if(fileToLoad){console.log("loader4JSON() - File '"+fileToLoad.name+"' exists."),$("#display_filename").html(fileToLoad.name);var fileReader=new FileReader;fileReader.onload=function(fileLoadedEvent){var vTextFromFileLoaded=fileLoadedEvent.target.result;try{vJSONEditor.setValue(JSON.parse(vTextFromFileLoaded)),alert("File JSON '"+fileToLoad.name+"' loaded successfully!"),validate_errors()}catch(e){vJSONEditor.setValue([]),alert(e)}},fileReader.readAsText(fileToLoad,"UTF-8")}else alert("File is missing");saveLS(fileToLoad.name)}function getDate(){var vNow=new Date,vMonth=vNow.getMonth()+1;return vNow.getDate()+"."+vMonth+"."+vNow.getFullYear()}function outTime(pNr){var vOut=pNr;return 0==pNr&&(vOut="00"),pNr<10&&(vOut="0"+pNr),vOut}function getDateTime(){var vNow=new Date,vSep="/",vOut=vNow.getFullYear()+vSep+outTime(vNow.getMonth()+1)+vSep+outTime(vNow.getDate());return vOut+=" ",vSep=":",vOut+=vNow.getHours()+vSep+outTime(vNow.getMinutes())+vSep+outTime(vNow.getSeconds())}function getTimeIndex(){return(new Date).getTime()}function saveFile2HDD(pFilename,pContent){var file=new Blob([pContent],{type:"text/plain;charset=utf-8"});saveAs(file,pFilename)}window=window||{document:{getElementById:function(id){console.error("getElementById() is not defined")}}},function(view){"use strict";if(view.URL=view.URL||view.webkitURL,view.Blob&&view.URL)try{return new Blob}catch(e){}var BlobBuilder=view.BlobBuilder||view.WebKitBlobBuilder||view.MozBlobBuilder||function(view){function get_class(object){return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1]}function FakeBlobBuilder(){this.data=[]}function FakeBlob(data,type,encoding){this.data=data,this.size=data.length,this.type=type,this.encoding=encoding}function FileException(type){this.code=this[this.name=type]}var FBB_proto=FakeBlobBuilder.prototype,FB_proto=FakeBlob.prototype,FileReaderSync=view.FileReaderSync,file_ex_codes="NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR".split(" "),file_ex_code=file_ex_codes.length,real_URL=view.URL||view.webkitURL||view,real_create_object_URL=real_URL.createObjectURL,real_revoke_object_URL=real_URL.revokeObjectURL,URL=real_URL,btoa=view.btoa,atob=view.atob,ArrayBuffer=view.ArrayBuffer,Uint8Array=view.Uint8Array,origin=/^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/;for(FakeBlob.fake=FB_proto.fake=!0;file_ex_code--;)FileException.prototype[file_ex_codes[file_ex_code]]=file_ex_code+1;return real_URL.createObjectURL||(URL=view.URL=function(uri){var uri_origin,uri_info=document.createElementNS("http://www.w3.org/1999/xhtml","a");return uri_info.href=uri,"origin"in uri_info||("data:"===uri_info.protocol.toLowerCase()?uri_info.origin=null:(uri_origin=uri.match(origin),uri_info.origin=uri_origin&&uri_origin[1])),uri_info}),URL.createObjectURL=function(blob){var data_URI_header,type=blob.type;return null===type&&(type="application/octet-stream"),blob instanceof FakeBlob?(data_URI_header="data:"+type,"base64"===blob.encoding?data_URI_header+";base64,"+blob.data:"URI"===blob.encoding?data_URI_header+","+decodeURIComponent(blob.data):btoa?data_URI_header+";base64,"+btoa(blob.data):data_URI_header+","+encodeURIComponent(blob.data)):real_create_object_URL?real_create_object_URL.call(real_URL,blob):void 0},URL.revokeObjectURL=function(object_URL){"data:"!==object_URL.substring(0,5)&&real_revoke_object_URL&&real_revoke_object_URL.call(real_URL,object_URL)},FBB_proto.append=function(data){var bb=this.data;if(Uint8Array&&(data instanceof ArrayBuffer||data instanceof Uint8Array)){for(var str="",buf=new Uint8Array(data),i=0,buf_len=buf.length;i<buf_len;i++)str+=String.fromCharCode(buf[i]);bb.push(str)}else if("Blob"===get_class(data)||"File"===get_class(data)){if(!FileReaderSync)throw new FileException("NOT_READABLE_ERR");var fr=new FileReaderSync;bb.push(fr.readAsBinaryString(data))}else data instanceof FakeBlob?"base64"===data.encoding&&atob?bb.push(atob(data.data)):"URI"===data.encoding?bb.push(decodeURIComponent(data.data)):"raw"===data.encoding&&bb.push(data.data):("string"!=typeof data&&(data+=""),bb.push(unescape(encodeURIComponent(data))))},FBB_proto.getBlob=function(type){return arguments.length||(type=null),new FakeBlob(this.data.join(""),type,"raw")},FBB_proto.toString=function(){return"[object BlobBuilder]"},FB_proto.slice=function(start,end,type){var args=arguments.length;return args<3&&(type=null),new FakeBlob(this.data.slice(start,1<args?end:this.data.length),type,this.encoding)},FB_proto.toString=function(){return"[object Blob]"},FB_proto.close=function(){this.size=0,delete this.data},FakeBlobBuilder}(view);view.Blob=function(blobParts,options){var type=options&&options.type||"",builder=new BlobBuilder;if(blobParts)for(var i=0,len=blobParts.length;i<len;i++)Uint8Array&&blobParts[i]instanceof Uint8Array?builder.append(blobParts[i].buffer):builder.append(blobParts[i]);var blob=builder.getBlob(type);return!blob.slice&&blob.webkitSlice&&(blob.slice=blob.webkitSlice),blob};var getPrototypeOf=Object.getPrototypeOf||function(object){return object.__proto__};view.Blob.prototype=getPrototypeOf(new view.Blob)}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content||this);var saveAs=saveAs||function(e){"use strict";if(!(void 0===e||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,i=/constructor/i.test(e.HTMLElement)||e.safari,f=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},c=function(e){setTimeout(function(){"string"==typeof e?n().revokeObjectURL(e):e.remove()},4e4)},l=function(e,t,n){for(var r=(t=[].concat(t)).length;r--;){var o=e["on"+t[r]];if("function"==typeof o)try{o.call(e,n||e)}catch(a){u(a)}}},p=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e},v=function(t,u,d){d||(t=p(t));function h(){l(v,"writestart progress write writeend".split(" "))}var y,v=this,m="application/octet-stream"===t.type;if(v.readyState=v.INIT,o)return y=n().createObjectURL(t),void setTimeout(function(){r.href=y,r.download=u,function(e){var t=new MouseEvent("click");e.dispatchEvent(t)}(r),h(),c(y),v.readyState=v.DONE});!function(){if((f||m&&i)&&e.FileReader){var r=new FileReader;return r.onloadend=function(){var t=f?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");e.open(t,"_blank")||(e.location.href=t),t=void 0,v.readyState=v.DONE,h()},r.readAsDataURL(t),v.readyState=v.INIT}(y=y||n().createObjectURL(t),m)?e.location.href=y:e.open(y,"_blank")||(e.location.href=y);v.readyState=v.DONE,h(),c(y)}()},w=v.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return t=t||e.name||"download",n||(e=p(e)),navigator.msSaveOrOpenBlob(e,t)}:(w.abort=function(){},w.readyState=w.INIT=0,w.WRITING=1,w.DONE=2,w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null,function(e,t,n){return new v(e,t||e.name||"download",n)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);"undefined"!=typeof module&&module.exports?module.exports.saveAs=saveAs:"undefined"!=typeof define&&null!==define&&null!==define.amd&&define("FileSaver.js",function(){return saveAs}),function(){var Class,initializing,fnTest;initializing=!1,fnTest=/xyz/.test(function(){window.postMessage("xyz")})?/\b_super\b/:/.*/,(Class=function(){}).extend=function extend(prop){var _super=this.prototype;initializing=!0;var prototype=new this;for(var name in initializing=!1,prop)prototype[name]="function"==typeof prop[name]&&"function"==typeof _super[name]&&fnTest.test(prop[name])?function(name,fn){return function(){var tmp=this._super;this._super=_super[name];var ret=fn.apply(this,arguments);return this._super=tmp,ret}}(name,prop[name]):prop[name];function Class(){!initializing&&this.init&&this.init.apply(this,arguments)}return((Class.prototype=prototype).constructor=Class).extend=extend,Class},function(){function CustomEvent(event,params){params=params||{bubbles:!1,cancelable:!1,detail:void 0};var evt=document.createEvent("CustomEvent");return evt.initCustomEvent(event,params.bubbles,params.cancelable,params.detail),evt}CustomEvent.prototype=window.Event.prototype,window.CustomEvent=CustomEvent}(),function(){for(var lastTime=0,vendors=["ms","moz","webkit","o"],x=0;x<vendors.length&&!window.requestAnimationFrame;++x)window.requestAnimationFrame=window[vendors[x]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[vendors[x]+"CancelAnimationFrame"]||window[vendors[x]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(callback,element){var currTime=(new Date).getTime(),timeToCall=Math.max(0,16-(currTime-lastTime)),id=window.setTimeout(function(){callback(currTime+timeToCall)},timeToCall);return lastTime=currTime+timeToCall,id}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(id){clearTimeout(id)})}(),Array.isArray||(Array.isArray=function(arg){return"[object Array]"===Object.prototype.toString.call(arg)});function $each(obj,callback){var i;if(obj&&"object"==typeof obj)if(Array.isArray(obj)||"number"==typeof obj.length&&0<obj.length&&obj.length-1 in obj){for(i=0;i<obj.length;i++)if(!1===callback(i,obj[i]))return}else if(Object.keys){var keys=Object.keys(obj);for(i=0;i<keys.length;i++)if(!1===callback(keys[i],obj[keys[i]]))return}else for(i in obj)if(obj.hasOwnProperty(i)&&!1===callback(i,obj[i]))return}function $trigger(el,event){var e=document.createEvent("HTMLEvents");e.initEvent(event,!0,!0),el.dispatchEvent(e)}var $extend=function(destination){var source,i,property,obj;for(i=1;i<arguments.length;i++)for(property in source=arguments[i])source.hasOwnProperty(property)&&(!source[property]||("object"!=typeof(obj=source[property])||obj.nodeType||null!==obj&&obj===obj.window||obj.constructor&&!Object.prototype.hasOwnProperty.call(obj.constructor.prototype,"isPrototypeOf"))?destination[property]=source[property]:(destination.hasOwnProperty(property)||(destination[property]={}),$extend(destination[property],source[property])));return destination},JSONEditor=function(element,options){if(!(element instanceof Element))throw new Error("element should be an instance of Element");options=$extend({},JSONEditor.defaults.options,options||{}),this.element=element,this.options=options,this.init()};JSONEditor.prototype={constructor:JSONEditor,init:function(){var self=this;this.ready=!1;var theme_class=JSONEditor.defaults.themes[this.options.theme||JSONEditor.defaults.theme];if(!theme_class)throw"Unknown theme "+(this.options.theme||JSONEditor.defaults.theme);this.schema=this.options.schema,this.theme=new theme_class,this.template=this.options.template,this.refs=this.options.refs||{},this.uuid=0,this.__data={};var icon_class=JSONEditor.defaults.iconlibs[this.options.iconlib||JSONEditor.defaults.iconlib];icon_class&&(this.iconlib=new icon_class),this.root_container=this.theme.getContainer(),this.element.appendChild(this.root_container),this.translate=this.options.translate||JSONEditor.defaults.translate,this._loadExternalRefs(this.schema,function(){self._getDefinitions(self.schema);var validator_options={};self.options.custom_validators&&(validator_options.custom_validators=self.options.custom_validators),self.validator=new JSONEditor.Validator(self,null,validator_options);var editor_class=self.getEditorClass(self.schema);self.root=self.createEditor(editor_class,{jsoneditor:self,schema:self.schema,required:!0,container:self.root_container}),self.root.preBuild(),self.root.build(),self.root.postBuild(),self.options.startval&&self.root.setValue(self.options.startval),self.validation_results=self.validator.validate(self.root.getValue()),self.root.showValidationErrors(self.validation_results),self.ready=!0,window.requestAnimationFrame(function(){self.ready&&(self.validation_results=self.validator.validate(self.root.getValue()),self.root.showValidationErrors(self.validation_results),self.trigger("ready"),self.trigger("change"))})})},getValue:function(){if(!this.ready)throw"JSON Editor not ready yet. Listen for 'ready' event before getting the value";return this.root.getValue()},setValue:function(value){if(!this.ready)throw"JSON Editor not ready yet. Listen for 'ready' event before setting the value";return this.root.setValue(value),this},validate:function(value){if(!this.ready)throw"JSON Editor not ready yet. Listen for 'ready' event before validating";return 1===arguments.length?this.validator.validate(value):this.validation_results},destroy:function(){this.destroyed||this.ready&&(this.schema=null,this.options=null,this.root.destroy(),this.root=null,this.root_container=null,this.validator=null,this.validation_results=null,this.theme=null,this.iconlib=null,this.template=null,this.__data=null,this.ready=!1,this.element.innerHTML="",this.destroyed=!0)},on:function(event,callback){return this.callbacks=this.callbacks||{},this.callbacks[event]=this.callbacks[event]||[],this.callbacks[event].push(callback),this},off:function(event,callback){if(event&&callback){this.callbacks=this.callbacks||{},this.callbacks[event]=this.callbacks[event]||[];for(var newcallbacks=[],i=0;i<this.callbacks[event].length;i++)this.callbacks[event][i]!==callback&&newcallbacks.push(this.callbacks[event][i]);this.callbacks[event]=newcallbacks}else event?(this.callbacks=this.callbacks||{},this.callbacks[event]=[]):this.callbacks={};return this},trigger:function(event){if(this.callbacks&&this.callbacks[event]&&this.callbacks[event].length)for(var i=0;i<this.callbacks[event].length;i++)this.callbacks[event][i]();return this},setOption:function(option,value){if("show_errors"!==option)throw"Option "+option+" must be set during instantiation and cannot be changed later";return this.options.show_errors=value,this.onChange(),this},getEditorClass:function(schema){var classname;if(schema=this.expandSchema(schema),$each(JSONEditor.defaults.resolvers,function(i,resolver){var tmp=resolver(schema);if(tmp&&JSONEditor.defaults.editors[tmp])return classname=tmp,!1}),!classname)throw"Unknown editor for schema "+JSON.stringify(schema);if(!JSONEditor.defaults.editors[classname])throw"Unknown editor "+classname;return JSONEditor.defaults.editors[classname]},createEditor:function(editor_class,options){return new editor_class(options=$extend({},editor_class.options||{},options))},onChange:function(){if(this.ready&&!this.firing_change){this.firing_change=!0;var self=this;return window.requestAnimationFrame(function(){self.firing_change=!1,self.ready&&(self.validation_results=self.validator.validate(self.root.getValue()),"never"!==self.options.show_errors?self.root.showValidationErrors(self.validation_results):self.root.showValidationErrors([]),self.trigger("change"))}),this}},compileTemplate:function(template,name){var engine;if("string"==typeof(name=name||JSONEditor.defaults.template)){if(!JSONEditor.defaults.templates[name])throw"Unknown template engine "+name;if(!(engine=JSONEditor.defaults.templates[name]()))throw"Template engine "+name+" missing required library."}else engine=name;if(!engine)throw"No template engine set";if(!engine.compile)throw"Invalid template engine set";return engine.compile(template)},_data:function(el,key,value){if(3!==arguments.length)return el.hasAttribute("data-jsoneditor-"+key)?this.__data[el.getAttribute("data-jsoneditor-"+key)]:null;var uuid;el.hasAttribute("data-jsoneditor-"+key)?uuid=el.getAttribute("data-jsoneditor-"+key):(uuid=this.uuid++,el.setAttribute("data-jsoneditor-"+key,uuid)),this.__data[uuid]=value},registerEditor:function(editor){return this.editors=this.editors||{},this.editors[editor.path]=editor,this},unregisterEditor:function(editor){return this.editors=this.editors||{},this.editors[editor.path]=null,this},getEditor:function(path){if(this.editors)return this.editors[path]},watch:function(path,callback){return this.watchlist=this.watchlist||{},this.watchlist[path]=this.watchlist[path]||[],this.watchlist[path].push(callback),this},unwatch:function(path,callback){if(!this.watchlist||!this.watchlist[path])return this;if(!callback)return this.watchlist[path]=null,this;for(var newlist=[],i=0;i<this.watchlist[path].length;i++)this.watchlist[path][i]!==callback&&newlist.push(this.watchlist[path][i]);return this.watchlist[path]=newlist.length?newlist:null,this},notifyWatchers:function(path){if(!this.watchlist||!this.watchlist[path])return this;for(var i=0;i<this.watchlist[path].length;i++)this.watchlist[path][i]()},isEnabled:function(){return!this.root||this.root.isEnabled()},enable:function(){this.root.enable()},disable:function(){this.root.disable()},_getDefinitions:function(schema,path){if(path=path||"#/definitions/",schema.definitions)for(var i in schema.definitions)schema.definitions.hasOwnProperty(i)&&(this.refs[path+i]=schema.definitions[i],schema.definitions[i].definitions&&this._getDefinitions(schema.definitions[i],path+i+"/definitions/"))},_getExternalRefs:function(schema){function merge_refs(newrefs){for(var i in newrefs)newrefs.hasOwnProperty(i)&&(refs[i]=!0)}var refs={};for(var i in schema.$ref&&"object"!=typeof schema.$ref&&"#"!==schema.$ref.substr(0,1)&&!this.refs[schema.$ref]&&(refs[schema.$ref]=!0),schema)if(schema.hasOwnProperty(i))if(schema[i]&&"object"==typeof schema[i]&&Array.isArray(schema[i]))for(var j=0;j<schema[i].length;j++)"object"==typeof schema[i][j]&&merge_refs(this._getExternalRefs(schema[i][j]));else schema[i]&&"object"==typeof schema[i]&&merge_refs(this._getExternalRefs(schema[i]));return refs},_loadExternalRefs:function(schema,callback){var self=this,refs=this._getExternalRefs(schema),done=0,waiting=0,callback_fired=!1;$each(refs,function(url){if(!self.refs[url]){if(!self.options.ajax)throw"Must set ajax option to true to load external ref "+url;self.refs[url]="loading",waiting++;var r=new XMLHttpRequest;r.open("GET",url,!0),r.onreadystatechange=function(){if(4==r.readyState){if(200!==r.status)throw window.console.log(r),"Failed to fetch ref via ajax- "+url;var response;try{response=JSON.parse(r.responseText)}catch(e){throw window.console.log(e),"Failed to parse external ref "+url}if(!response||"object"!=typeof response)throw"External ref does not contain a valid schema - "+url;self.refs[url]=response,self._loadExternalRefs(response,function(){waiting<=++done&&!callback_fired&&(callback_fired=!0,callback())})}},r.send()}}),waiting||callback()},expandRefs:function(schema){for(schema=$extend({},schema);schema.$ref;){var ref=schema.$ref;delete schema.$ref,this.refs[ref]||(ref=decodeURIComponent(ref)),schema=this.extendSchemas(schema,this.refs[ref])}return schema},expandSchema:function(schema){var i,self=this,extended=$extend({},schema);if("object"==typeof schema.type&&(Array.isArray(schema.type)?$each(schema.type,function(key,value){"object"==typeof value&&(schema.type[key]=self.expandSchema(value))}):schema.type=self.expandSchema(schema.type)),"object"==typeof schema.disallow&&(Array.isArray(schema.disallow)?$each(schema.disallow,function(key,value){"object"==typeof value&&(schema.disallow[key]=self.expandSchema(value))}):schema.disallow=self.expandSchema(schema.disallow)),schema.anyOf&&$each(schema.anyOf,function(key,value){schema.anyOf[key]=self.expandSchema(value)}),schema.dependencies&&$each(schema.dependencies,function(key,value){"object"!=typeof value||Array.isArray(value)||(schema.dependencies[key]=self.expandSchema(value))}),schema.not&&(schema.not=this.expandSchema(schema.not)),schema.allOf){for(i=0;i<schema.allOf.length;i++)extended=this.extendSchemas(extended,this.expandSchema(schema.allOf[i]));delete extended.allOf}if(schema.extends){if(Array.isArray(schema.extends))for(i=0;i<schema.extends.length;i++)extended=this.extendSchemas(extended,this.expandSchema(schema.extends[i]));else extended=this.extendSchemas(extended,this.expandSchema(schema.extends));delete extended.extends}if(schema.oneOf){var tmp=$extend({},extended);for(delete tmp.oneOf,i=0;i<schema.oneOf.length;i++)extended.oneOf[i]=this.extendSchemas(this.expandSchema(schema.oneOf[i]),tmp)}return this.expandRefs(extended)},extendSchemas:function(obj1,obj2){obj1=$extend({},obj1),obj2=$extend({},obj2);var self=this,extended={};return $each(obj1,function(prop,val){void 0!==obj2[prop]?"required"!==prop&&"defaultProperties"!==prop||"object"!=typeof val||!Array.isArray(val)?"type"!==prop||"string"!=typeof val&&!Array.isArray(val)?"object"==typeof val&&Array.isArray(val)?extended[prop]=val.filter(function(n){return-1!==obj2[prop].indexOf(n)}):extended[prop]="object"==typeof val&&null!==val?self.extendSchemas(val,obj2[prop]):val:("string"==typeof val&&(val=[val]),"string"==typeof obj2.type&&(obj2.type=[obj2.type]),obj2.type&&obj2.type.length?extended.type=val.filter(function(n){return-1!==obj2.type.indexOf(n)}):extended.type=val,1===extended.type.length&&"string"==typeof extended.type[0]?extended.type=extended.type[0]:0===extended.type.length&&delete extended.type):extended[prop]=val.concat(obj2[prop]).reduce(function(p,c){return p.indexOf(c)<0&&p.push(c),p},[]):extended[prop]=val}),$each(obj2,function(prop,val){void 0===obj1[prop]&&(extended[prop]=val)}),extended}},JSONEditor.defaults={themes:{},templates:{},iconlibs:{},editors:{},languages:{},resolvers:[],custom_validators:[]},JSONEditor.Validator=Class.extend({init:function(jsoneditor,schema,options){this.jsoneditor=jsoneditor,this.schema=schema||this.jsoneditor.schema,this.options=options||{},this.translate=this.jsoneditor.translate||JSONEditor.defaults.translate},validate:function(value){return this._validateSchema(this.schema,value)},_validateSchema:function(schema,value,path){var valid,i,j,self=this,errors=[],stringified=JSON.stringify(value);if(path=path||"root",(schema=$extend({},this.jsoneditor.expandRefs(schema))).required&&!0===schema.required){if(void 0===value)return errors.push({path:path,property:"required",message:this.translate("error_notset")}),errors}else if(void 0===value){if(!this.jsoneditor.options.required_by_default)return errors;errors.push({path:path,property:"required",message:this.translate("error_notset")})}if(schema.enum){for(valid=!1,i=0;i<schema.enum.length;i++)stringified===JSON.stringify(schema.enum[i])&&(valid=!0);valid||errors.push({path:path,property:"enum",message:this.translate("error_enum")})}if(schema.extends)for(i=0;i<schema.extends.length;i++)errors=errors.concat(this._validateSchema(schema.extends[i],value,path));if(schema.allOf)for(i=0;i<schema.allOf.length;i++)errors=errors.concat(this._validateSchema(schema.allOf[i],value,path));if(schema.anyOf){for(valid=!1,i=0;i<schema.anyOf.length;i++)if(!this._validateSchema(schema.anyOf[i],value,path).length){valid=!0;break}valid||errors.push({path:path,property:"anyOf",message:this.translate("error_anyOf")})}if(schema.oneOf){var oneof_errors=[];for(i=valid=0;i<schema.oneOf.length;i++){var tmp=this._validateSchema(schema.oneOf[i],value,path);for(tmp.length||valid++,j=0;j<tmp.length;j++)tmp[j].path=path+".oneOf["+i+"]"+tmp[j].path.substr(path.length);oneof_errors=oneof_errors.concat(tmp)}1!==valid&&(errors.push({path:path,property:"oneOf",message:this.translate("error_oneOf",[valid])}),errors=errors.concat(oneof_errors))}if(schema.not&&(this._validateSchema(schema.not,value,path).length||errors.push({path:path,property:"not",message:this.translate("error_not")})),schema.type)if(Array.isArray(schema.type)){for(valid=!1,i=0;i<schema.type.length;i++)if(this._checkType(schema.type[i],value)){valid=!0;break}valid||errors.push({path:path,property:"type",message:this.translate("error_type_union")})}else this._checkType(schema.type,value)||errors.push({path:path,property:"type",message:this.translate("error_type",[schema.type])});if(schema.disallow)if(Array.isArray(schema.disallow)){for(valid=!0,i=0;i<schema.disallow.length;i++)if(this._checkType(schema.disallow[i],value)){valid=!1;break}valid||errors.push({path:path,property:"disallow",message:this.translate("error_disallow_union")})}else this._checkType(schema.disallow,value)&&errors.push({path:path,property:"disallow",message:this.translate("error_disallow",[schema.disallow])});if("number"==typeof value){if(schema.multipleOf||schema.divisibleBy){var divisor=schema.multipleOf||schema.divisibleBy;valid=value/divisor===Math.floor(value/divisor),window.math?valid=window.math.mod(window.math.bignumber(value),window.math.bignumber(divisor)).equals(0):window.Decimal&&(valid=new window.Decimal(value).mod(new window.Decimal(divisor)).equals(0)),valid||errors.push({path:path,property:schema.multipleOf?"multipleOf":"divisibleBy",message:this.translate("error_multipleOf",[divisor])})}schema.hasOwnProperty("maximum")&&(valid=schema.exclusiveMaximum?value<schema.maximum:value<=schema.maximum,window.math?valid=window.math[schema.exclusiveMaximum?"smaller":"smallerEq"](window.math.bignumber(value),window.math.bignumber(schema.maximum)):window.Decimal&&(valid=new window.Decimal(value)[schema.exclusiveMaximum?"lt":"lte"](new window.Decimal(schema.maximum))),valid||errors.push({path:path,property:"maximum",message:this.translate(schema.exclusiveMaximum?"error_maximum_excl":"error_maximum_incl",[schema.maximum])})),schema.hasOwnProperty("minimum")&&(valid=schema.exclusiveMinimum?value>schema.minimum:value>=schema.minimum,window.math?valid=window.math[schema.exclusiveMinimum?"larger":"largerEq"](window.math.bignumber(value),window.math.bignumber(schema.minimum)):window.Decimal&&(valid=new window.Decimal(value)[schema.exclusiveMinimum?"gt":"gte"](new window.Decimal(schema.minimum))),valid||errors.push({path:path,property:"minimum",message:this.translate(schema.exclusiveMinimum?"error_minimum_excl":"error_minimum_incl",[schema.minimum])}))}else if("string"==typeof value)schema.maxLength&&(value+"").length>schema.maxLength&&errors.push({path:path,property:"maxLength",message:this.translate("error_maxLength",[schema.maxLength])}),schema.minLength&&(value+"").length<schema.minLength&&errors.push({path:path,property:"minLength",message:this.translate(1===schema.minLength?"error_notempty":"error_minLength",[schema.minLength])}),schema.pattern&&(new RegExp(schema.pattern).test(value)||errors.push({path:path,property:"pattern",message:this.translate("error_pattern",[schema.pattern])}));else if("object"==typeof value&&null!==value&&Array.isArray(value)){if(schema.items)if(Array.isArray(schema.items))for(i=0;i<value.length;i++)if(schema.items[i])errors=errors.concat(this._validateSchema(schema.items[i],value[i],path+"."+i));else{if(!0===schema.additionalItems)break;if(!schema.additionalItems){if(!1!==schema.additionalItems)break;errors.push({path:path,property:"additionalItems",message:this.translate("error_additionalItems")});break}errors=errors.concat(this._validateSchema(schema.additionalItems,value[i],path+"."+i))}else for(i=0;i<value.length;i++)errors=errors.concat(this._validateSchema(schema.items,value[i],path+"."+i));if(schema.maxItems&&value.length>schema.maxItems&&errors.push({path:path,property:"maxItems",message:this.translate("error_maxItems",[schema.maxItems])}),schema.minItems&&value.length<schema.minItems&&errors.push({path:path,property:"minItems",message:this.translate("error_minItems",[schema.minItems])}),schema.uniqueItems){var seen={};for(i=0;i<value.length;i++){if(seen[valid=JSON.stringify(value[i])]){errors.push({path:path,property:"uniqueItems",message:this.translate("error_uniqueItems")});break}seen[valid]=!0}}}else if("object"==typeof value&&null!==value){if(schema.maxProperties){for(i in valid=0,value)value.hasOwnProperty(i)&&valid++;valid>schema.maxProperties&&errors.push({path:path,property:"maxProperties",message:this.translate("error_maxProperties",[schema.maxProperties])})}if(schema.minProperties){for(i in valid=0,value)value.hasOwnProperty(i)&&valid++;valid<schema.minProperties&&errors.push({path:path,property:"minProperties",message:this.translate("error_minProperties",[schema.minProperties])})}if(schema.required&&Array.isArray(schema.required))for(i=0;i<schema.required.length;i++)void 0===value[schema.required[i]]&&errors.push({path:path,property:"required",message:this.translate("error_required",[schema.required[i]])});var validated_properties={};if(schema.properties)for(i in schema.properties)schema.properties.hasOwnProperty(i)&&(validated_properties[i]=!0,errors=errors.concat(this._validateSchema(schema.properties[i],value[i],path+"."+i)));if(schema.patternProperties)for(i in schema.patternProperties)if(schema.patternProperties.hasOwnProperty(i)){var regex=new RegExp(i);for(j in value)value.hasOwnProperty(j)&&regex.test(j)&&(validated_properties[j]=!0,errors=errors.concat(this._validateSchema(schema.patternProperties[i],value[j],path+"."+j)))}if(void 0!==schema.additionalProperties||!this.jsoneditor.options.no_additional_properties||schema.oneOf||schema.anyOf||(schema.additionalProperties=!1),void 0!==schema.additionalProperties)for(i in value)if(value.hasOwnProperty(i)&&!validated_properties[i]){if(!schema.additionalProperties){errors.push({path:path,property:"additionalProperties",message:this.translate("error_additional_properties",[i])});break}if(!0===schema.additionalProperties)break;errors=errors.concat(this._validateSchema(schema.additionalProperties,value[i],path+"."+i))}if(schema.dependencies)for(i in schema.dependencies)if(schema.dependencies.hasOwnProperty(i)&&void 0!==value[i])if(Array.isArray(schema.dependencies[i]))for(j=0;j<schema.dependencies[i].length;j++)void 0===value[schema.dependencies[i][j]]&&errors.push({path:path,property:"dependencies",message:this.translate("error_dependency",[schema.dependencies[i][j]])});else errors=errors.concat(this._validateSchema(schema.dependencies[i],value,path))}return $each(JSONEditor.defaults.custom_validators,function(i,validator){errors=errors.concat(validator.call(self,schema,value,path))}),this.options.custom_validators&&$each(this.options.custom_validators,function(i,validator){errors=errors.concat(validator.call(self,schema,value,path))}),errors},_checkType:function(type,value){return"string"==typeof type?"string"===type?"string"==typeof value:"number"===type?"number"==typeof value:"integer"===type?"number"==typeof value&&value===Math.floor(value):"boolean"===type?"boolean"==typeof value:"array"===type?Array.isArray(value):"object"===type?null!==value&&!Array.isArray(value)&&"object"==typeof value:"null"!==type||null===value:!this._validateSchema(type,value).length}}),JSONEditor.AbstractEditor=Class.extend({onChildEditorChange:function(editor){this.onChange(!0)},notify:function(){this.jsoneditor.notifyWatchers(this.path)},change:function(){this.parent?this.parent.onChildEditorChange(this):this.jsoneditor.onChange()},onChange:function(bubble){this.notify(),this.watch_listener&&this.watch_listener(),bubble&&this.change()},register:function(){this.jsoneditor.registerEditor(this),this.onChange()},unregister:function(){this.jsoneditor&&this.jsoneditor.unregisterEditor(this)},getNumColumns:function(){return 12},init:function(options){this.jsoneditor=options.jsoneditor,this.theme=this.jsoneditor.theme,this.template_engine=this.jsoneditor.template,this.iconlib=this.jsoneditor.iconlib,this.translate=this.jsoneditor.translate||JSONEditor.defaults.translate,this.original_schema=options.schema,this.schema=this.jsoneditor.expandSchema(this.original_schema),this.options=$extend({},this.options||{},options.schema.options||{},options),options.path||this.schema.id||(this.schema.id="root"),this.path=options.path||"root",this.formname=options.formname||this.path.replace(/\.([^.]+)/g,"[$1]"),this.jsoneditor.options.form_name_root&&(this.formname=this.formname.replace(/^root\[/,this.jsoneditor.options.form_name_root+"[")),this.key=this.path.split(".").pop(),this.parent=options.parent,this.link_watchers=[],options.container&&this.setContainer(options.container)},setContainer:function(container){this.container=container,this.schema.id&&this.container.setAttribute("data-schemaid",this.schema.id),this.schema.type&&"string"==typeof this.schema.type&&this.container.setAttribute("data-schematype",this.schema.type),this.container.setAttribute("data-schemapath",this.path)},preBuild:function(){},build:function(){},postBuild:function(){this.setupWatchListeners(),this.addLinks(),this.setValue(this.getDefault(),!0),this.updateHeaderText(),this.register(),this.onWatchedFieldChange()},setupWatchListeners:function(){var path,path_parts,first,root,adjusted_path,self=this;if(this.watched={},this.schema.vars&&(this.schema.watch=this.schema.vars),this.watched_values={},this.watch_listener=function(){self.refreshWatchedFieldValues()&&self.onWatchedFieldChange()},this.register(),this.schema.hasOwnProperty("watch"))for(var name in this.schema.watch)if(this.schema.watch.hasOwnProperty(name)){if(path=this.schema.watch[name],Array.isArray(path)){if(path.length<2)continue;path_parts=[path[0]].concat(path[1].split("."))}else path_parts=path.split("."),self.theme.closest(self.container,'[data-schemaid="'+path_parts[0]+'"]')||path_parts.unshift("#");if("#"===(first=path_parts.shift())&&(first=self.jsoneditor.schema.id||"root"),!(root=self.theme.closest(self.container,'[data-schemaid="'+first+'"]')))throw"Could not find ancestor node with id "+first;adjusted_path=root.getAttribute("data-schemapath")+"."+path_parts.join("."),self.jsoneditor.watch(adjusted_path,self.watch_listener),self.watched[name]=adjusted_path}this.schema.headerTemplate&&(this.header_template=this.jsoneditor.compileTemplate(this.schema.headerTemplate,this.template_engine))},addLinks:function(){if(!this.no_link_holder&&(this.link_holder=this.theme.getLinksHolder(),this.container.appendChild(this.link_holder),this.schema.links))for(var i=0;i<this.schema.links.length;i++)this.addLink(this.getLink(this.schema.links[i]))},getButton:function(text,icon,title){var btnClass="json-editor-btn-"+icon;!(icon=this.iconlib?this.iconlib.getIcon(icon):null)&&title&&(text=title,title=null);var btn=this.theme.getButton(text,icon,title);return btn.className+=" "+btnClass+" ",btn},setButtonText:function(button,text,icon,title){return!(icon=this.iconlib?this.iconlib.getIcon(icon):null)&&title&&(text=title,title=null),this.theme.setButtonText(button,text,icon,title)},addLink:function(link){this.link_holder&&this.link_holder.appendChild(link)},getLink:function(data){var holder,link,type=(data.mediaType||"application/javascript").split("/")[0],href=this.jsoneditor.compileTemplate(data.href,this.template_engine),download=null;if(data.download&&(download=data.download),download&&!0!==download&&(download=this.jsoneditor.compileTemplate(download,this.template_engine)),"image"===type){holder=this.theme.getBlockLinkHolder(),(link=document.createElement("a")).setAttribute("target","_blank");var image=document.createElement("img");this.theme.createImageLink(holder,link,image),this.link_watchers.push(function(vars){var url=href(vars);link.setAttribute("href",url),link.setAttribute("title",data.rel||url),image.setAttribute("src",url)})}else if(0<=["audio","video"].indexOf(type)){holder=this.theme.getBlockLinkHolder(),(link=this.theme.getBlockLink()).setAttribute("target","_blank");var media=document.createElement(type);media.setAttribute("controls","controls"),this.theme.createMediaLink(holder,link,media),this.link_watchers.push(function(vars){var url=href(vars);link.setAttribute("href",url),link.textContent=data.rel||url,media.setAttribute("src",url)})}else link=holder=this.theme.getBlockLink(),holder.setAttribute("target","_blank"),holder.textContent=data.rel,this.link_watchers.push(function(vars){var url=href(vars);holder.setAttribute("href",url),holder.textContent=data.rel||url});return download&&link&&(!0===download?link.setAttribute("download",""):this.link_watchers.push(function(vars){link.setAttribute("download",download(vars))})),data.class&&(link.className=link.className+" "+data.class),holder},refreshWatchedFieldValues:function(){if(this.watched_values){var val,editor,watched={},changed=!1;if(this.watched)for(var name in this.watched)this.watched.hasOwnProperty(name)&&(val=(editor=this.jsoneditor.getEditor(this.watched[name]))?editor.getValue():null,this.watched_values[name]!==val&&(changed=!0),watched[name]=val);return watched.self=this.getValue(),this.watched_values.self!==watched.self&&(changed=!0),this.watched_values=watched,changed}},getWatchedFieldValues:function(){return this.watched_values},updateHeaderText:function(){if(this.header)if(this.header.children.length){for(var i=0;i<this.header.childNodes.length;i++)if(3===this.header.childNodes[i].nodeType){this.header.childNodes[i].nodeValue=this.getHeaderText();break}}else this.header.textContent=this.getHeaderText()},getHeaderText:function(title_only){return this.header_text?this.header_text:title_only?this.schema.title:this.getTitle()},onWatchedFieldChange:function(){var vars;if(this.header_template){vars=$extend(this.getWatchedFieldValues(),{key:this.key,i:this.key,i0:1*this.key,i1:1*this.key+1,title:this.getTitle()});var header_text=this.header_template(vars);header_text!==this.header_text&&(this.header_text=header_text,this.updateHeaderText(),this.notify())}if(this.link_watchers.length){vars=this.getWatchedFieldValues();for(var i=0;i<this.link_watchers.length;i++)this.link_watchers[i](vars)}},setValue:function(value){this.value=value},getValue:function(){return this.value},refreshValue:function(){},getChildEditors:function(){return!1},destroy:function(){var self=this;this.unregister(this),$each(this.watched,function(name,adjusted_path){self.jsoneditor.unwatch(adjusted_path,self.watch_listener)}),this.watched=null,this.watched_values=null,this.watch_listener=null,this.header_text=null,this.header_template=null,this.value=null,this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=null,this.jsoneditor=null,this.schema=null,this.path=null,this.key=null,this.parent=null},getDefault:function(){if(this.schema.default)return this.schema.default;if(this.schema.enum)return this.schema.enum[0];var type=this.schema.type||this.schema.oneOf;if(type&&Array.isArray(type)&&(type=type[0]),type&&"object"==typeof type&&(type=type.type),type&&Array.isArray(type)&&(type=type[0]),"string"==typeof type){if("number"===type)return 0;if("boolean"===type)return!1;if("integer"===type)return 0;if("string"===type)return"";if("object"===type)return{};if("array"===type)return[]}return null},getTitle:function(){return this.schema.title||this.key},enable:function(){this.disabled=!1},disable:function(){this.disabled=!0},isEnabled:function(){return!this.disabled},isRequired:function(){return"boolean"==typeof this.schema.required?this.schema.required:this.parent&&this.parent.schema&&Array.isArray(this.parent.schema.required)?-1<this.parent.schema.required.indexOf(this.key):!!this.jsoneditor.options.required_by_default},getDisplayText:function(arr){var disp=[],used={};$each(arr,function(i,el){el.title&&(used[el.title]=used[el.title]||0,used[el.title]++),el.description&&(used[el.description]=used[el.description]||0,used[el.description]++),el.format&&(used[el.format]=used[el.format]||0,used[el.format]++),el.type&&(used[el.type]=used[el.type]||0,used[el.type]++)}),$each(arr,function(i,el){var name;name="string"==typeof el?el:el.title&&used[el.title]<=1?el.title:el.format&&used[el.format]<=1?el.format:el.type&&used[el.type]<=1?el.type:el.description&&used[el.description]<=1?el.descripton:el.title?el.title:el.format?el.format:el.type?el.type:el.description?el.description:JSON.stringify(el).length<50?JSON.stringify(el):"type",disp.push(name)});var inc={};return $each(disp,function(i,name){inc[name]=inc[name]||0,inc[name]++,1<used[name]&&(disp[i]=name+" "+inc[name])}),disp},getOption:function(key){try{throw"getOption is deprecated"}catch(e){window.console.error(e)}return this.options[key]},showValidationErrors:function(errors){}}),JSONEditor.defaults.editors.null=JSONEditor.AbstractEditor.extend({getValue:function(){return null},setValue:function(){this.onChange()},getNumColumns:function(){return 2}}),JSONEditor.defaults.editors.string=JSONEditor.AbstractEditor.extend({register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},setValue:function(value,initial,from_template){if((!this.template||from_template)&&(null==value?value="":"object"==typeof value?value=JSON.stringify(value):"string"!=typeof value&&(value=""+value),value!==this.serialized)){var sanitized=this.sanitize(value);if(this.input.value!==sanitized){this.input.value=sanitized,this.sceditor_instance?this.sceditor_instance.val(sanitized):this.epiceditor?this.epiceditor.importFile(null,sanitized):this.ace_editor&&this.ace_editor.setValue(sanitized);var changed=from_template||this.getValue()!==value;this.refreshValue(),initial?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.adjust_height&&this.adjust_height(this.input),this.onChange(changed)}}},getNumColumns:function(){var num,min=Math.ceil(Math.max(this.getTitle().length,this.schema.maxLength||0,this.schema.minLength||0)/5);return num="textarea"===this.input_type?6:0<=["text","email"].indexOf(this.input_type)?4:2,Math.min(12,Math.max(min,num))},build:function(){var self=this;if(this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.format=this.schema.format,!this.format&&this.schema.media&&this.schema.media.type&&(this.format=this.schema.media.type.replace(/(^(application|text)\/(x-)?(script\.)?)|(-source$)/g,"")),!this.format&&this.options.default_format&&(this.format=this.options.default_format),this.options.format&&(this.format=this.options.format),this.format)if("textarea"===this.format)this.input_type="textarea",this.input=this.theme.getTextareaInput();else if("range"===this.format){this.input_type="range";var min=this.schema.minimum||0,max=this.schema.maximum||Math.max(100,min+1),step=1;this.schema.multipleOf&&(min%this.schema.multipleOf&&(min=Math.ceil(min/this.schema.multipleOf)*this.schema.multipleOf),max%this.schema.multipleOf&&(max=Math.floor(max/this.schema.multipleOf)*this.schema.multipleOf),step=this.schema.multipleOf),this.input=this.theme.getRangeInput(min,max,step)}else 0<=["actionscript","batchfile","bbcode","c","c++","cpp","coffee","csharp","css","dart","django","ejs","erlang","golang","groovy","handlebars","haskell","haxe","html","ini","jade","java","javascript","json","less","lisp","lua","makefile","markdown","matlab","mysql","objectivec","pascal","perl","pgsql","php","python","r","ruby","sass","scala","scss","smarty","sql","stylus","svg","twig","vbscript","xml","yaml"].indexOf(this.format)?(this.input_type=this.format,this.source_code=!0,this.input=this.theme.getTextareaInput()):(this.input_type=this.format,this.input=this.theme.getFormInputField(this.input_type));else this.input_type="text",this.input=this.theme.getFormInputField(this.input_type);void 0!==this.schema.maxLength&&this.input.setAttribute("maxlength",this.schema.maxLength),void 0!==this.schema.pattern?this.input.setAttribute("pattern",this.schema.pattern):void 0!==this.schema.minLength&&this.input.setAttribute("pattern",".{"+this.schema.minLength+",}"),this.options.compact?this.container.className+=" compact":this.options.input_width&&(this.input.style.width=this.options.input_width),(this.schema.readOnly||this.schema.readonly||this.schema.template)&&(this.always_disabled=!0,this.input.disabled=!0),this.input.addEventListener("change",function(e){if(e.preventDefault(),e.stopPropagation(),self.schema.template)this.value=self.value;else{var val=this.value,sanitized=self.sanitize(val);val!==sanitized&&(this.value=sanitized),self.is_dirty=!0,self.refreshValue(),self.onChange(!0)}}),this.options.input_height&&(this.input.style.height=this.options.input_height),this.options.expand_height&&(this.adjust_height=function(el){if(el){var i,ch=el.offsetHeight;if(el.offsetHeight<el.scrollHeight)for(i=0;el.offsetHeight<el.scrollHeight+3&&!(100<i);)i++,ch++,el.style.heigh