Restructured the files

This commit is contained in:
Jos de Jong 2012-08-16 21:18:37 +02:00
parent df6b65c7b0
commit e290ff15da
17 changed files with 127 additions and 125 deletions

View File

@ -44,14 +44,14 @@
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="interface.css">
<link rel="stylesheet" type="text/css" href="jsoneditor.css">
<link rel="stylesheet" type="text/css" href="interface/interface.css">
<link rel="stylesheet" type="text/css" href="jsoneditor/jsoneditor.css">
<!-- TODO: droid font
<link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
-->
<script type="text/javascript" src="jsoneditor-min.js"></script>
<script type="text/javascript" src="interface.js"></script>
<script type="text/javascript" src="jsoneditor/jsoneditor-min.js"></script>
<script type="text/javascript" src="interface/interface.js"></script>
</head>
<body spellcheck="false" >

View File

@ -142,9 +142,9 @@ div.convert-right, div.convert-left {
}
div.convert-right {
background: url('img/jsoneditor-icons.png') -168px 0;
background: url('../jsoneditor/img/jsoneditor-icons.png') -168px 0;
}
div.convert-left {
background: url('img/jsoneditor-icons.png') -192px 0;
background: url('../jsoneditor/img/jsoneditor-icons.png') -192px 0;
}

107
jsoneditor-min.js vendored
View File

@ -1,107 +0,0 @@
/*
This json editor is open sourced with the intention to use the editor as
a component in your own application. Not to just copy and monetize the editor
as it is.
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
Copyright (c) 2011-2012 Jos de Jong, http://jsoneditoronline.org
@author Jos de Jong, <wjosdejong@gmail.com>
@date 2012-08-16
*/
if(!Array.prototype.indexOf)Array.prototype.indexOf=function(a){for(var b=0;b<this.length;b++)if(this[b]==a)return b;return-1};var JSON;JSONEditor=function(a,b,c){if(!JSON)throw Error("Your browser does not support JSON. \n\nPlease install the newest version of your browser.\n(all modern browsers support JSON).");if(!a)throw Error("No container element provided.");this.container=a;this.dom={};this._setOptions(b);this._createFrame();this._createTable();this.set(c||{})};
JSONEditor.prototype._setOptions=function(a){this.options={enableSearch:!0};if(a)for(var b in a)a.hasOwnProperty(b)&&(this.options[b]=a[b])};JSONEditor.focusNode=void 0;JSONEditor.prototype.set=function(a){a instanceof Function||a===void 0?this.clear():(this.content.removeChild(this.table),this._setRoot(new JSONEditor.Node({value:a})),this.node.expand(!1),this.content.appendChild(this.table))};JSONEditor.prototype.get=function(){JSONEditor.focusNode&&JSONEditor.focusNode.blur();if(this.node)return this.node.getValue()};
JSONEditor.prototype.clear=function(){this.node&&(this.node.collapse(),this.tbody.removeChild(this.node.getDom()),delete this.node)};JSONEditor.prototype._setRoot=function(a){this.clear();this.node=a;var b=this;a.getEditor=function(){return b};this.tbody.appendChild(a.getDom())};JSONEditor.prototype.search=function(a){this.node?(this.content.removeChild(this.table),a=this.node.search(a),this.content.appendChild(this.table)):a=[];return a};
JSONEditor.prototype.expandAll=function(){this.node&&(this.content.removeChild(this.table),this.node.expand(),this.content.appendChild(this.table))};JSONEditor.prototype.collapseAll=function(){this.node&&(this.content.removeChild(this.table),this.node.collapse(),this.content.appendChild(this.table))};JSONEditor.prototype.focus=function(){};
JSONEditor.prototype.scrollTo=function(a){var b=this.content;if(b){var c=this;c.animateTimeout&&(clearTimeout(c.animateTimeout),delete c.animateTimeout);var d=b.clientHeight,f=Math.min(Math.max(a-d/4,0),b.scrollHeight-d),e=function(){var a=f-b.scrollTop;if(Math.abs(a)>3)b.scrollTop+=a/3,c.animateTimeout=setTimeout(e,50)};e()}};JSONEditor.Node=function(a){this.dom={};this.expanded=!1;a&&a instanceof Object?(this.setField(a.field,a.fieldEditable),this.setValue(a.value)):(this.setField(),this.setValue())};
JSONEditor.Node.prototype.setParent=function(a){this.parent=a};JSONEditor.Node.prototype.getParent=function(){return this.parent};JSONEditor.Node.prototype.getEditor=function(){return this.parent?this.parent.getEditor():void 0};JSONEditor.Node.prototype.setField=function(a,b){this.field=a;this.fieldEditable=b==!0};JSONEditor.Node.prototype.getField=function(){if(this.field===void 0)this.field=this._getDomField();return this.field};
JSONEditor.Node.prototype.setValue=function(a){var b=this.childs;if(b)for(;b.length;)this.removeChild(b[0]);this.type=this._getType(a);if(this.type=="array"){this.childs=[];for(var c=0,b=a.length;c<b;c++){var d=a[c];d!==void 0&&!(d instanceof Function)&&(d=new JSONEditor.Node({value:d}),this.appendChild(d))}this.value=""}else if(this.type=="object"){this.childs=[];for(c in a)a.hasOwnProperty(c)&&(d=a[c],d!==void 0&&!(d instanceof Function)&&(d=new JSONEditor.Node({field:c,value:d}),this.appendChild(d)));
this.value=""}else this.childs=void 0,this.value=a};JSONEditor.Node.prototype.getValue=function(){if(this.type=="array"){for(var a=[],b=this.childs,c=0,d=b.length;c<d;c++)a.push(b[c].getValue());return a}else if(this.type=="object"){a={};b=this.childs;c=0;for(d=b.length;c<d;c++){var f=b[c];a[f.getField()]=f.getValue()}return a}else{if(this.value===void 0)this.value=this._getDomValue();return this.value}};JSONEditor.Node.prototype.getLevel=function(){return this.parent?this.parent.getLevel()+1:0};
JSONEditor.Node.prototype.clone=function(){var a=new JSONEditor.Node;a.type=this.type;a.field=this.field;a.fieldHTML=this.fieldHTML;a.fieldEditable=this.fieldEditable;a.value=this.value;a.valueHTML=this.valueHTML;a.expanded=this.expanded;if(this.childs){for(var b=this.childs,c=[],d=0,f=b.length;d<f;d++){var e=b[d].clone();e.setParent(a);c.push(e)}a.childs=c}else a.childs=void 0;return a};
JSONEditor.Node.prototype.expand=function(a){if(this.childs){this.expanded=!0;if(this.dom.expand)this.dom.expand.className="jsoneditor-expanded";this.showChilds();var b=this.childs;if(a!=!1)for(var c=0,d=b.length;c<d;c++)b[c].expand(a)}};JSONEditor.Node.prototype.collapse=function(a){if(this.childs){this.hideChilds();var b=this.childs;if(a!=!1)for(var c=0,d=b.length;c<d;c++)b[c].collapse(a);if(this.dom.expand)this.dom.expand.className="jsoneditor-collapsed";this.expanded=!1}};
JSONEditor.Node.prototype.showChilds=function(){var a=this.childs;if(a&&this.expanded){var b=this.dom.tr,c=b?b.parentNode:void 0;if(c){var d=this.getAppend();(b=b.nextSibling)?c.insertBefore(d,b):c.appendChild(d);for(var b=0,f=a.length;b<f;b++){var e=a[b];c.insertBefore(e.getDom(),d);e.showChilds()}}}};JSONEditor.Node.prototype.hide=function(){var a=this.dom.tr,b=a?a.parentNode:void 0;b&&b.removeChild(a);this.hideChilds()};
JSONEditor.Node.prototype.hideChilds=function(){var a=this.childs;if(a&&this.expanded){var b=this.getAppend();b.parentNode&&b.parentNode.removeChild(b);for(var b=0,c=a.length;b<c;b++)a[b].hide()}};
JSONEditor.Node.prototype.appendChild=function(a){if(this.type=="array"||this.type=="object"){a.setParent(this);a.fieldEditable=this.type=="object";if(this.type=="array")a.index=this.childs.length;this.childs.push(a);if(this.expanded){var b=a.getDom(),c=this.getAppend(),d=c?c.parentNode:void 0;c&&d&&d.insertBefore(b,c);this._updateStatus(a.index);a.showChilds()}a.updateDom()}};
JSONEditor.Node.prototype.moveBefore=function(a,b){if(this.type=="array"||this.type=="object"){var c=this.dom.tr?this.dom.tr.parentNode:void 0;if(c){var d=document.createElement("tr");d.style.height=c.clientHeight+"px";c.appendChild(d)}var f=a.getParent();f&&f.removeChild(a);b instanceof JSONEditor.AppendNode?this.appendChild(a):this.insertBefore(a,b);c&&c.removeChild(d)}};
JSONEditor.Node.prototype.insertBefore=function(a,b){if(this.type=="array"||this.type=="object"){if(b==this.append)a.setParent(this),a.fieldEditable=this.type=="object",this.childs.push(a);else{var c=this.childs.indexOf(b);if(c==-1)throw Error("Node not found");a.setParent(this);a.fieldEditable=this.type=="object";this.childs.splice(c,0,a)}if(this.expanded){var d=a.getDom(),f=b.getDom(),e=f?f.parentNode:void 0;f&&e&&e.insertBefore(d,f);a.showChilds()}a.updateDom();this._updateStatus(c)}};
JSONEditor.Node.prototype.search=function(a){var b=[],c,d=a?a.toLowerCase():void 0;delete this.searchField;delete this.searchValue;if(this.field!=void 0){c=String(this.field).toLowerCase().indexOf(d);if(c!=-1)this.searchField=!0,b.push({node:this,elem:"field"});this._updateDomField()}if(this.type=="array"||this.type=="object"){if(c=this.childs){for(var f=[],e=0,g=c.length;e<g;e++)f=f.concat(c[e].search(a));b=b.concat(f)}d!=void 0&&(f.length==0?this.collapse(!1):this.expand(!1))}else{if(this.value!=
void 0&&(c=String(this.value).toLowerCase().indexOf(d),c!=-1))this.searchValue=!0,b.push({node:this,elem:"value"});this._updateDomValue()}return b};JSONEditor.Node.prototype.scrollTo=function(){if(!this.dom.tr||!this.dom.tr.parentNode)for(var a=this.parent;a;)a.expand(!1),a=a.parent;this.dom.tr&&this.dom.tr.parentNode&&(a=this.getEditor())&&a.scrollTo(this.dom.tr.offsetTop)};
JSONEditor.Node.prototype.focus=function(a){this.dom.tr&&this.dom.tr.parentNode&&(a=a!="value"&&this.fieldEditable?this.dom.field:this.dom.value)&&a.focus()};JSONEditor.Node.prototype.blur=function(){this._getDomValue(!0);this._getDomField(!0)};JSONEditor.Node.prototype._duplicate=function(a){this.insertBefore(a.clone(),a)};JSONEditor.Node.prototype.containsNode=function(a){if(this==a)return!0;var b=this.childs;if(b)for(var c=0,d=b.length;c<d;c++)if(b[c].containsNode(a))return!0;return!1};
JSONEditor.Node.prototype._move=function(a,b){if(a!=b){if(a.containsNode(this))throw Error("Cannot move a field into a child of itself");a.parent&&a.parent.removeChild(a);var c=a.clone();a.clearDom();b?this.insertBefore(c,b):this.appendChild(c)}};JSONEditor.Node.prototype.removeChild=function(a){if(this.childs){var b=this.childs.indexOf(a);if(b!=-1)return a.hide(),a=this.childs.splice(b,1)[0],this._updateStatus(b),a}};
JSONEditor.Node.prototype._changeType=function(a){var b=this.type;if((a=="string"||a=="auto")&&(b=="string"||b=="auto"))this.type=a;else{var c=this.dom.tr?this.dom.tr.parentNode:void 0,d;d=(d=this.expanded?this.getAppend():this.getDom())&&d.parentNode?d.nextSibling:void 0;this.hide();this.clearDom();this.type=a;if(a=="object"){if(!this.childs)this.childs=[];for(var f=this.childs,e=0,g=f.length;e<g;e++){var h=f[e];h.clearDom();delete h.index;h.fieldEditable=!0;if(h.field==void 0)h.field=e}if(b=="string"||
b=="auto")this.expanded=!0}else if(a=="array"){if(!this.childs)this.childs=[];f=this.childs;e=0;for(g=f.length;e<g;e++)h=f[e],h.clearDom(),h.fieldEditable=!1,h.index=e;this._updateStatus();if(b=="string"||b=="auto")this.expanded=!0}else this.expanded=!1;c&&(d?c.insertBefore(this.getDom(),d):c.appendChild(this.getDom()));this.showChilds()}if(a=="auto"||a=="string")this.value=a=="string"?String(this.value):this._stringCast(String(this.value)),this.focus();this.updateDom()};
JSONEditor.Node.prototype._getDomValue=function(a){if(this.dom.value&&this.type!="array"&&this.type!="object")this.valueHTML=this.dom.value.innerHTML;if(this.valueHTML!=void 0)try{this.value=this.type=="string"?this._unescape(this._stripHTML(this.valueHTML)):this._stringCast(this._unescape(this._stripHTML(this.valueHTML)))}catch(b){if(this.value=void 0,a!=!0)throw b;}};
JSONEditor.Node.prototype._updateDomValue=function(){var a=this.dom.value;if(a){var b=this.value,c=this.type=="auto"?typeof b:this.type,d="";c=="string"?d="green":c=="number"?d="red":c=="boolean"?d="blue":this.type=="object"||this.type=="array"?d="":b===null?d="purple":b===void 0&&(d="green");a.style.color=d;String(this.value)==""&&this.type!="array"&&this.type!="object"?JSONEditor.addClassName(a,"jsoneditor-empty"):JSONEditor.removeClassName(a,"jsoneditor-empty");this.searchValueActive?JSONEditor.addClassName(a,
"jsoneditor-search-highlight-active"):JSONEditor.removeClassName(a,"jsoneditor-search-highlight-active");this.searchValue?JSONEditor.addClassName(a,"jsoneditor-search-highlight"):JSONEditor.removeClassName(a,"jsoneditor-search-highlight");JSONEditor.stripFormatting(a)}};
JSONEditor.Node.prototype._updateDomField=function(){var a=this.dom.field;a&&(String(this.field)==""?JSONEditor.addClassName(a,"jsoneditor-empty"):JSONEditor.removeClassName(a,"jsoneditor-empty"),this.searchFieldActive?JSONEditor.addClassName(a,"jsoneditor-search-highlight-active"):JSONEditor.removeClassName(a,"jsoneditor-search-highlight-active"),this.searchField?JSONEditor.addClassName(a,"jsoneditor-search-highlight"):JSONEditor.removeClassName(a,"jsoneditor-search-highlight"),JSONEditor.stripFormatting(a))};
JSONEditor.Node.prototype._getDomField=function(a){if(this.dom.field&&this.fieldEditable)this.fieldHTML=this.dom.field.innerHTML;if(this.fieldHTML!=void 0)try{this.field=this._unescape(this._stripHTML(this.fieldHTML))}catch(b){if(this.field=void 0,a!=!0)throw b;}};JSONEditor.Node.prototype.clearDom=function(){this.dom={}};
JSONEditor.Node.prototype.getDom=function(){var a=this.dom;if(a.tr)return a.tr;a.tr=document.createElement("tr");a.tr.className="jsoneditor-tr";a.tr.node=this;var b=document.createElement("td");b.className="jsoneditor-td";a.drag=this._createDomDragArea();a.drag&&b.appendChild(a.drag);a.tr.appendChild(b);b=document.createElement("td");b.className="jsoneditor-td";a.tr.appendChild(b);a.expand=this._createDomExpandButton();a.field=this._createDomField();a.value=this._createDomValue();a.tree=this._createDomTree(a.expand,
a.field,a.value);b.appendChild(a.tree);b=document.createElement("td");b.className="jsoneditor-td jsoneditor-td-edit";a.tr.appendChild(b);a.type=this._createDomTypeButton();b.appendChild(a.type);b=document.createElement("td");b.className="jsoneditor-td jsoneditor-td-edit";a.tr.appendChild(b);a.duplicate=this._createDomDuplicateButton();a.duplicate&&b.appendChild(a.duplicate);b=document.createElement("td");b.className="jsoneditor-td jsoneditor-td-edit";a.tr.appendChild(b);a.remove=this._createDomRemoveButton();
a.remove&&b.appendChild(a.remove);this._updateStatus();this.updateDom();return a.tr};
JSONEditor.Node.prototype._onDragStart=function(a){a=a||window.event;JSONEditor.focusNode&&JSONEditor.focusNode.blur();var b=this;if(!this.mousemove)this.mousemove=JSONEditor.Events.addEventListener(document,"mousemove",function(a){b._onDrag(a)});if(!this.mouseup)this.mouseup=JSONEditor.Events.addEventListener(document,"mouseup",function(a){b._onDragEnd(a)});JSONEditor.freezeHighlight=!0;this.oldCursor=document.body.style.cursor;document.body.style.cursor="move";JSONEditor.Events.preventDefault(a)};
JSONEditor.Node.prototype._onDrag=function(a){var a=a||window.event,b=this.dom.tr,c=JSONEditor.getAbsoluteTop(b),d=b.offsetHeight,f=a.pageY||a.clientY+document.body.scrollTop;if(f<c){for(var c=b.previousSibling,b=JSONEditor.getAbsoluteTop(c),e=JSONEditor.getNodeFromTarget(c);c&&f<b;)e=JSONEditor.getNodeFromTarget(c),c=c.previousSibling,b=JSONEditor.getAbsoluteTop(c);if(e)c=e.dom.tr,b=JSONEditor.getAbsoluteTop(c),f>b+d&&(e=void 0);e&&e.parent&&e.parent.moveBefore(this,e)}else if(e=(d=this.expanded&&
this.append?this.append.getDom():this.dom.tr)?d.nextSibling:void 0){for(var d=JSONEditor.getAbsoluteTop(e),b=void 0,e=e.nextSibling,g=JSONEditor.getAbsoluteTop(e),g=e?g-d:0;e&&f>c+g;)b=JSONEditor.getNodeFromTarget(e),e=e.nextSibling,g=JSONEditor.getAbsoluteTop(e),g=e?g-d:0;b&&b.parent&&b.parent.moveBefore(this,b)}JSONEditor.Events.preventDefault(a)};
JSONEditor.Node.prototype._onDragEnd=function(a){a=a||window.event;document.body.style.cursor=this.oldCursor;delete JSONEditor.freezeHighlight;delete this.oldCursor;this.setHighlight(!1);this.mousemove&&(JSONEditor.Events.removeEventListener(document,"mousemove",this.mousemove),delete this.mousemove);this.mouseup&&(JSONEditor.Events.removeEventListener(document,"mouseup",this.mouseup),delete this.mouseup);JSONEditor.Events.preventDefault(a)};
JSONEditor.Node.prototype._createDomDragArea=function(){if(this.parent){var a=document.createElement("button");a.className="jsoneditor-dragarea";a.title="Move field (drag and drop)";return a}};JSONEditor.Node.prototype._createDomField=function(){return document.createElement("div")};
JSONEditor.Node.prototype.setHighlight=function(a){if(!JSONEditor.freezeHighlight&&this.dom.tr){this.dom.tr.className="jsoneditor-tr"+(a?" jsoneditor-tr-highlight":"");this.append&&this.append.setHighlight(a);var b=this.childs;if(b)for(var c=0,d=b.length;c<d;c++)b[c].setHighlight(a)}};
JSONEditor.Node.prototype.updateDom=function(){var a=this.dom.tree;if(a)a.style.marginLeft=this.getLevel()*24+"px";if(a=this.dom.field)this.fieldEditable==!0?(a.contentEditable="true",a.spellcheck=!1,a.className="jsoneditor-field"):a.className="jsoneditor-readonly",a.innerHTML=this._escape(this.index!=void 0?this.index:this.field!=void 0?this.field:this.type=="array"||this.type=="object"?this.type:"field");this._updateDomField();this._updateDomValue();if(this.childs)for(var a=this.childs,b=0,c=a.length;b<
c;b++)a[b].updateDom();this.append&&this.append.updateDom()};
JSONEditor.Node.prototype._updateStatus=function(a){var b=this.dom.value,c=this.childs;if(b&&c){var d=c.length;if(this.type=="array"){b.innerHTML="["+d+"]";for(var a=a>0?a:0,f=c.length;a<f;a++){var e=c[a];e.index=a;if(e=e.dom.field)e.innerHTML=a}}else if(this.type=="object"){b.innerHTML="{"+d+"}";a=a>0?a:0;for(f=c.length;a<f;a++)if(e=c[a],e.index!=void 0){delete e.index;if(e.field==void 0)e.field="field";e.updateDom()}}b.title=this.type+" containing "+d+" items"}};
JSONEditor.Node.prototype._createDomValue=function(){var a;this.type=="array"?(a=document.createElement("div"),a.className="jsoneditor-readonly",a.innerHTML="[...]"):this.type=="object"?(a=document.createElement("div"),a.className="jsoneditor-readonly",a.innerHTML="{...}"):(a=document.createElement("div"),a.contentEditable="true",a.spellcheck=!1,a.className="jsoneditor-value",a.innerHTML=this._escape(this.value));return a};
JSONEditor.Node.prototype._createDomExpandButton=function(){var a=document.createElement("button");this.type=="array"||this.type=="object"?(a.className=this.expanded?"jsoneditor-expanded":"jsoneditor-collapsed",a.title="Click to expand/collapse this field. \nCtrl+Click to expand/collapse including all childs."):(a.className="jsoneditor-invisible",a.title="");return a};
JSONEditor.Node.prototype._createDomTree=function(a,b,c){var d=this.dom,f=document.createElement("table"),e=document.createElement("tbody");f.style.borderCollapse="collapse";f.appendChild(e);var g=document.createElement("tr");e.appendChild(g);e=document.createElement("td");e.className="jsoneditor-td-tree";g.appendChild(e);e.appendChild(a);d.tdExpand=e;a=document.createElement("td");a.className="jsoneditor-td-tree";g.appendChild(a);a.appendChild(b);d.tdField=a;b=document.createElement("td");b.className=
"jsoneditor-td-tree";g.appendChild(b);if(this.type!="object"&&this.type!="array")b.appendChild(document.createTextNode(":")),b.className="jsoneditor-separator";d.tdSeparator=b;b=document.createElement("td");b.className="jsoneditor-td-tree";g.appendChild(b);b.appendChild(c);d.tdValue=b;return f};
JSONEditor.Node.prototype.onEvent=function(a){var b=a.type,c=a.target||a.srcElement,d=this.dom,f=this,e=this.type=="array"||this.type=="object",g=d.value;if(c==g)switch(b){case "focus":JSONEditor.focusNode=this;break;case "change":case "blur":case "keyup":this._getDomValue(!0);this._updateDomValue();break;case "cut":case "paste":setTimeout(function(){f._getDomValue(!0);f._updateDomValue()},1)}var h=d.field;if(c==h)switch(b){case "focus":JSONEditor.focusNode=this;break;case "change":case "blur":case "keyup":this._getDomField(!0);
this._updateDomField();break;case "cut":case "paste":setTimeout(function(){f._getDomField(!0);f._updateDomField()},1)}if(c==d.drag)switch(b){case "mousedown":this._onDragStart(a);break;case "mouseover":this.setHighlight(!0);break;case "mouseout":this.setHighlight(!1)}c==d.expand&&b=="click"&&e&&this._onExpand(a);if(c==d.duplicate)switch(b){case "click":this.parent._duplicate(this);break;case "mouseover":this.setHighlight(!0);break;case "mouseout":this.setHighlight(!1)}if(c==d.remove)switch(b){case "click":this.parent.removeChild(this);
break;case "mouseover":this.setHighlight(!0);break;case "mouseout":this.setHighlight(!1)}if(c==d.type)switch(b){case "click":this._onTypeButton(a);break;case "mouseover":this.setHighlight(!0);break;case "mouseout":this.setHighlight(!1)}if(c==d.tree.parentNode)switch(b){case "click":(a.offsetX!=void 0?a.offsetX<(this.getLevel()+1)*24:a.clientX<JSONEditor.getAbsoluteLeft(d.tdSeparator))||e?h&&(JSONEditor.setEndOfContentEditable(h),h.focus()):g&&(JSONEditor.setEndOfContentEditable(g),g.focus())}if(c==
d.tdExpand&&!e||c==d.tdField||c==d.tdSeparator)switch(b){case "click":h&&(JSONEditor.setEndOfContentEditable(h),h.focus())}};JSONEditor.Node.prototype._onExpand=function(a){a=a||window.event;if(a=a.ctrlKey){var b=this.dom.tr.parentNode,c=b.parentNode,d=c.scrollTop;c.removeChild(b)}this.expanded?this.collapse(a):this.expand(a);if(a)c.appendChild(b),c.scrollTop=d};
JSONEditor.Node.types=[{value:"array",className:"jsoneditor-option-array",title:'Field type "array". An array contains an ordered collection of values.'},{value:"auto",className:"jsoneditor-option-auto",title:'Field type "auto". The field type is automatically determined from the value and can be a string, number, boolean, or null.'},{value:"object",className:"jsoneditor-option-object",title:'Field type "object". An object contains an unordered set of key/value pairs.'},{value:"string",className:"jsoneditor-option-string",
title:'Field type "string". Field type is not determined from the value, but always returned as string.'}];JSONEditor.Node.prototype._createDomTypeButton=function(){var a=document.createElement("button");a.className="jsoneditor-type-"+this.type;a.title="Change field type";return a};
JSONEditor.Node.prototype._onTypeButton=function(a){JSONEditor.Events.stopPropagation(a);var b=this.dom.type,c=this,a=JSONEditor.getAbsoluteLeft(b),d=JSONEditor.getAbsoluteTop(b)+b.clientHeight;JSONEditor.showDropDownList({x:a,y:d,node:c,value:c.type,values:JSONEditor.Node.types,className:"jsoneditor-select",optionSelectedClassName:"jsoneditor-option-selected",optionClassName:"jsoneditor-option",callback:function(a){c._changeType(a);b.className="jsoneditor-type-"+c.type}})};
JSONEditor.showDropDownList=function(a){var b=document.createElement("div");b.className=a.className||"";b.style.position="absolute";b.style.left=(a.x||0)+"px";b.style.top=(a.y||0)+"px";for(var c=0;c<a.values.length;c++){var d=a.values[c],f=d.value||String(d),e="jsoneditor-option";f==a.value&&(e+=" "+a.optionSelectedClassName);var g=document.createElement("div");g.className=e;if(d.title)g.title=d.title;e=document.createElement("div");e.className=d.className||"";g.appendChild(e);e=document.createElement("div");
e.className="jsoneditor-option-text";e.innerHTML="<div>"+f+"</div>";g.appendChild(e);g.onmousedown=function(b){return function(){a.callback(b)}}(d.value);b.appendChild(g)}document.body.appendChild(b);a.node.setHighlight(!0);JSONEditor.freezeHighlight=!0;var h=JSONEditor.Events.addEventListener(document,"mousedown",function(){JSONEditor.freezeHighlight=!1;a.node.setHighlight(!1);document.body.removeChild(b);JSONEditor.Events.removeEventListener(document,"mousedown",h)}),i=JSONEditor.Events.addEventListener(document,
"mousewheel",function(){JSONEditor.freezeHighlight=!1;a.node.setHighlight(!1);document.body.removeChild(b);JSONEditor.Events.removeEventListener(document,"mousewheel",i)})};JSONEditor.Node.prototype.getAppend=function(){if(!this.append)this.append=new JSONEditor.AppendNode,this.append.setParent(this);return this.append.getDom()};
JSONEditor.Node.prototype._createDomRemoveButton=function(){if(this.parent&&(this.parent.type=="array"||this.parent.type=="object")){var a=document.createElement("button");a.className="jsoneditor-remove";a.title="Remove field (including all its childs)";return a}};
JSONEditor.Node.prototype._createDomDuplicateButton=function(){if(this.parent&&(this.parent.type=="array"||this.parent.type=="object")){var a=document.createElement("button");a.className="jsoneditor-duplicate";a.title="Duplicate field (including all childs)";return a}};JSONEditor.Node.prototype._getType=function(a){return a instanceof Array?"array":a instanceof Object?"object":typeof a=="string"&&typeof this._stringCast(a)!="string"?"string":"auto"};
JSONEditor.Node.prototype._stringCast=function(a){var b=a.toLowerCase(),c=Number(a),d=parseFloat(a);return a==""?"":b=="null"?null:b=="true"?!0:b=="false"?!1:!isNaN(c)&&!isNaN(d)?c:a};JSONEditor.Node.prototype._escape=function(a){a=String(a).replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g," &nbsp;").replace(/^ /,"&nbsp;").replace(/ $/,"&nbsp;");a=JSON.stringify(a);return a.substring(1,a.length-1)};
JSONEditor.Node.prototype._unescape=function(a){return JSON.parse('"'+a+'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ")};JSONEditor.Node.prototype._stripHTML=function(a){return a.replace(/<(?:.|\n)*?>/gm,"")};JSONEditor.AppendNode=function(){this.dom={}};JSONEditor.AppendNode.prototype=new JSONEditor.Node;
JSONEditor.AppendNode.prototype.getDom=function(){function a(a){var b=document.createElement("td");b.className=a||"";return b}if(this.dom.tr)return this.dom.tr;var b=document.createElement("tr");b.appendChild(a("jsoneditor-td"));b.node=this;var c=document.createElement("td");b.appendChild(c);c.className="jsoneditor-td";var d=document.createElement("button");d.className="jsoneditor-append";d.title="Append a field";this.dom.append=d;c.appendChild(d);b.appendChild(a("jsoneditor-td jsoneditor-td-edit"));
b.appendChild(a("jsoneditor-td jsoneditor-td-edit"));b.appendChild(a("jsoneditor-td jsoneditor-td-edit"));this.dom.tr=b;this.dom.td=c;this.updateDom();return b};JSONEditor.AppendNode.prototype.updateDom=function(){var a=this.dom.td;if(a)a.style.paddingLeft=this.getLevel()*24+26+"px"};
JSONEditor.AppendNode.prototype.onEvent=function(a){var b=a.type;if((a.target||a.srcElement)==this.dom.append)switch(b){case "click":a=new JSONEditor.Node({field:"field",value:"value"});this.parent.appendChild(a);this.parent.setHighlight(!1);a.focus();break;case "mouseover":this.parent.setHighlight(!0);break;case "mouseout":this.parent.setHighlight(!1)}};
JSONEditor.prototype._createFrame=function(){this.container.innerHTML="";this.frame=document.createElement("div");this.frame.className="jsoneditor-frame";this.container.appendChild(this.frame);var a=this,b=function(a){var a=a||window.event,b=JSONEditor.getNodeFromTarget(a.target||a.srcElement);if(b)b.onEvent(a)};this.frame.onclick=function(a){b(a);JSONEditor.Events.preventDefault(a)};this.frame.onchange=b;this.frame.onkeydown=b;this.frame.onkeyup=b;this.frame.oncut=b;this.frame.onpaste=b;this.frame.onmousedown=
b;this.frame.onmouseup=b;this.frame.onmouseover=b;this.frame.onmouseout=b;JSONEditor.Events.addEventListener(this.frame,"focus",b,!0);JSONEditor.Events.addEventListener(this.frame,"blur",b,!0);this.frame.onfocusin=b;this.frame.onfocusout=b;this.head=document.createElement("table");this.head.className="jsoneditor-menu";var c=document.createElement("tbody");this.head.appendChild(c);var d=document.createElement("tr");c.appendChild(d);this.tdMenu=c=document.createElement("td");c.className="jsoneditor-menu";
d.appendChild(c);d=document.createElement("button");d.innerHTML="Expand All";d.title="Expand all fields";d.onclick=function(){a.expandAll()};c.appendChild(d);d=document.createElement("button");d.innerHTML="Collapse All";d.title="Collapse all fields";d.onclick=function(){a.collapseAll()};c.appendChild(d);if(this.options.enableSearch)this.searchBox=new JSONEditor.SearchBox(this,c);this.frame.appendChild(this.head)};
JSONEditor.prototype._createTable=function(){var a=document.createElement("div");a.className="jsoneditor-content-outer";this.contentOuter=a;this.content=document.createElement("div");this.content.className="jsoneditor-content";a.appendChild(this.content);this.table=document.createElement("table");this.table.className="jsoneditor-table";this.content.appendChild(this.table);if(JSONEditor.getInternetExplorerVersion()==8)this.content.style.overflow="scroll";var b;this.colgroupContent=document.createElement("colgroup");
b=document.createElement("col");b.width="24px";this.colgroupContent.appendChild(b);b=document.createElement("col");this.colgroupContent.appendChild(b);b=document.createElement("col");b.width="24px";this.colgroupContent.appendChild(b);b=document.createElement("col");b.width="24px";this.colgroupContent.appendChild(b);b=document.createElement("col");b.width="24px";this.colgroupContent.appendChild(b);this.table.appendChild(this.colgroupContent);this.tbody=document.createElement("tbody");this.table.appendChild(this.tbody);
this.frame.appendChild(a)};JSONEditor.getNodeFromTarget=function(a){for(;a;){if(a.node)return a.node;a=a.parentNode}};
JSONFormatter=function(a){if(!JSON)throw Error("Your browser does not support JSON. \n\nPlease install the newest version of your browser.\n(all modern browsers support JSON).");this.container=a;this.width=a.clientWidth;this.height=a.clientHeight;this.frame=document.createElement("div");this.frame.className="jsoneditor-frame";this.frame.onclick=function(a){JSONEditor.Events.preventDefault(a)};this.head=document.createElement("table");this.head.className="jsoneditor-menu";a=document.createElement("tbody");
this.head.appendChild(a);var b=document.createElement("tr");a.appendChild(b);a=document.createElement("td");a.className="jsoneditor-menu";b.appendChild(a);b=document.createElement("button");b.innerHTML="Format";b.title="Format JSON data, with proper indentation and line feeds";b.className="jsoneditor-button";a.appendChild(b);var c=document.createElement("button");c.innerHTML="Compact";c.title="Compact JSON data, remove all whitespaces";c.className="jsoneditor-button";a.appendChild(c);this.frame.appendChild(this.head);
this.content=document.createElement("div");this.content.className="jsonformatter-content";this.frame.appendChild(this.content);this.textarea=document.createElement("textarea");this.textarea.className="jsonformatter-textarea";this.textarea.spellcheck=!1;this.content.appendChild(this.textarea);var d=this.textarea,f=this;b.onclick=function(){try{d.value=JSON.stringify(JSON.parse(d.value),null," ")}catch(a){f.onError(a)}};c.onclick=function(){try{d.value=JSON.stringify(JSON.parse(d.value))}catch(a){f.onError(a)}};
this.container.appendChild(this.frame)};JSONFormatter.prototype.onError=function(){};JSONFormatter.prototype._checkChange=function(){var a=this.textarea.value;if(a!=this.lastContent&&(this.lastContent=a,this.onChangeCallback))this.onChangeCallback()};JSONFormatter.prototype.set=function(a){this.textarea.value=JSON.stringify(a,null," ")};JSONFormatter.prototype.get=function(){return JSON.parse(this.textarea.value)};
JSONEditor.SearchBox=function(a,b){var c=this;this.editor=a;this.timeout=void 0;this.delay=200;this.lastText=void 0;this.dom={};this.dom.container=b;var d=document.createElement("table");this.dom.table=d;d.className="jsoneditor-search";b.appendChild(d);var f=document.createElement("tbody");this.dom.tbody=f;d.appendChild(f);d=document.createElement("tr");f.appendChild(d);f=document.createElement("td");f.className="jsoneditor-search";d.appendChild(f);var e=document.createElement("div");this.dom.results=
e;e.className="jsoneditor-search-results";f.appendChild(e);f=document.createElement("td");f.className="jsoneditor-search";d.appendChild(f);d=document.createElement("div");this.dom.input=d;d.className="jsoneditor-search";d.title="Search fields and values";f.appendChild(d);f=document.createElement("table");f.className="jsoneditor-search-input";d.appendChild(f);e=document.createElement("tbody");f.appendChild(e);d=document.createElement("tr");e.appendChild(d);e=document.createElement("button");e.className=
"jsoneditor-search-refresh";f=document.createElement("td");f.appendChild(e);d.appendChild(f);e=document.createElement("input");this.dom.search=e;e.className="jsoneditor-search";e.oninput=function(a){c.onDelayedSearch(a)};e.onchange=function(a){c.onSearch(a)};e.onkeydown=function(a){c.onKeyDown(a)};e.onkeyup=function(a){c.onKeyUp(a)};f=document.createElement("td");f.appendChild(e);d.appendChild(f);e=document.createElement("button");e.title="Next result (Enter)";e.className="jsoneditor-search-next";
e.onclick=function(){c.next()};f=document.createElement("td");f.appendChild(e);d.appendChild(f);e=document.createElement("button");e.title="Previous result (Shift+Enter)";e.className="jsoneditor-search-previous";e.onclick=function(){c.previous()};f=document.createElement("td");f.appendChild(e);d.appendChild(f)};JSONEditor.SearchBox.prototype.next=function(){if(this.results!=void 0){var a=this.resultIndex!=void 0?this.resultIndex+1:0;a>this.results.length-1&&(a=0);this.setActiveResult(a)}};
JSONEditor.SearchBox.prototype.previous=function(){if(this.results!=void 0){var a=this.results.length-1,b=this.resultIndex!=void 0?this.resultIndex-1:a;b<0&&(b=a);this.setActiveResult(b)}};
JSONEditor.SearchBox.prototype.setActiveResult=function(a){if(this.activeResult){var b=this.activeResult.node;this.activeResult.elem=="field"?delete b.searchFieldActive:delete b.searchValueActive;b.updateDom()}!this.results||!this.results[a]?this.activeResult=this.resultIndex=void 0:(this.resultIndex=a,a=this.results[this.resultIndex].node,this.results[this.resultIndex].elem=="field"?a.searchFieldActive=!0:a.searchValueActive=!0,this.activeResult=this.results[this.resultIndex],a.updateDom(),a.scrollTo())};
JSONEditor.SearchBox.prototype.focusActiveResult=function(){this.activeResult||this.next();this.activeResult&&this.activeResult.node.focus(this.activeResult.elem)};JSONEditor.SearchBox.prototype.clearDelay=function(){this.timeout!=void 0&&(clearTimeout(this.timeout),delete this.timeout)};JSONEditor.SearchBox.prototype.onDelayedSearch=function(){this.clearDelay();var a=this;this.timeout=setTimeout(function(b){a.onSearch(b)},this.delay)};
JSONEditor.SearchBox.prototype.onSearch=function(a,b){this.clearDelay();var c=this.dom.search.value,c=c.length>0?c:void 0;if(c!=this.lastText||b)if(this.lastText=c,this.results=editor.search(c),this.setActiveResult(void 0),c!=void 0)switch(c=this.results.length,c){case 0:this.dom.results.innerHTML="no&nbsp;results";break;case 1:this.dom.results.innerHTML="1&nbsp;result";break;default:this.dom.results.innerHTML=c+"&nbsp;results"}else this.dom.results.innerHTML=""};
JSONEditor.SearchBox.prototype.onKeyDown=function(a){var a=a||window.event,b=a.which||a.keyCode;if(b==27)this.dom.search.value="",this.onSearch(a),JSONEditor.Events.preventDefault(a),JSONEditor.Events.stopPropagation(a);else if(b==13){if(a.ctrlKey)this.onSearch(a,!0);else a.shiftKey?this.previous():this.next();JSONEditor.Events.preventDefault(a);JSONEditor.Events.stopPropagation(a)}};JSONEditor.SearchBox.prototype.onKeyUp=function(a){var a=a||window.event,b=a.which||a.keyCode;if(b!=27&&b!=13)this.onDelayedSearch(a)};
JSONEditor.Events={};JSONEditor.Events.addEventListener=function(a,b,c,d){return a.addEventListener?(d===void 0&&(d=!1),b==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(b="DOMMouseScroll"),a.addEventListener(b,c,d),c):(d=function(){return c.call(a,window.event)},a.attachEvent("on"+b,d),d)};
JSONEditor.Events.removeEventListener=function(a,b,c,d){a.removeEventListener?(d===void 0&&(d=!1),b==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(b="DOMMouseScroll"),a.removeEventListener(b,c,d)):a.detachEvent("on"+b,c)};JSONEditor.Events.stopPropagation=function(a){if(!a)a=window.event;a.stopPropagation?a.stopPropagation():a.cancelBubble=!0};JSONEditor.Events.preventDefault=function(a){if(!a)a=window.event;a.preventDefault?a.preventDefault():a.returnValue=!1};
JSONEditor.getAbsoluteLeft=function(a){for(var b=0,c=document.body;a!=null&&a!=c;)b+=a.offsetLeft,b-=a.scrollLeft,a=a.offsetParent;return b};JSONEditor.getAbsoluteTop=function(a){for(var b=0,c=document.body;a!=null&&a!=c;)b+=a.offsetTop,b-=a.scrollTop,a=a.offsetParent;return b};JSONEditor.addClassName=function(a,b){var c=a.className;if(c.indexOf(b)==-1)c+=" "+b,a.className=c};
JSONEditor.removeClassName=function(a,b){var c=a.className;if(c.indexOf(b)!=-1)c=c.replace(b,""),c=c.replace(/ /g,""),a.className=c};JSONEditor.stripFormatting=function(a){for(var a=a.childNodes,b=0,c=a.length;b<c;b++){var d=a[b];d.style&&d.removeAttribute("style");var f=d.attributes;if(f)for(var e=f.length-1;e>=0;e--){var g=f[e];g.specified==!0&&d.removeAttribute(g.name)}JSONEditor.stripFormatting(d)}};
JSONEditor.setEndOfContentEditable=function(a){var b;document.createRange?(b=document.createRange(),b.selectNodeContents(a),b.collapse(!1),a=window.getSelection(),a.removeAllRanges(),a.addRange(b)):document.selection&&(b=document.body.createTextRange(),b.moveToElementText(a),b.collapse(!1),b.select())};JSONEditor.getInternetExplorerVersion=function(){var a=-1;navigator.appName=="Microsoft Internet Explorer"&&/MSIE ([0-9]{1,}[.0-9]{0,})/.exec(navigator.userAgent)!=null&&(a=parseFloat(RegExp.$1));return a};
JSONEditor.ieVersion=JSONEditor.getInternetExplorerVersion();

View File

@ -1,8 +1,8 @@
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="jsoneditor.css">
<script type="text/javascript" src="jsoneditor-min.js"></script>
<link rel="stylesheet" type="text/css" href="../jsoneditor.css">
<script type="text/javascript" src="../jsoneditor.js"></script>
</head>
<body>
<p>

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

109
jsoneditor/jsoneditor-min.js vendored Normal file
View File

@ -0,0 +1,109 @@
/*
This json editor is open sourced with the intention to use the editor as
a component in your own application. Not to just copy and monetize the editor
as it is.
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
Copyright (c) 2011-2012 Jos de Jong, http://jsoneditoronline.org
@author Jos de Jong, <wjosdejong@gmail.com>
@date 2012-08-16
*/
Array.prototype.indexOf||(Array.prototype.indexOf=function(a){for(var b=0;b<this.length;b++)if(this[b]==a)return b;return-1});var JSON;JSONEditor=function(a,b,c){if(!JSON)throw Error("Your browser does not support JSON. \n\nPlease install the newest version of your browser.\n(all modern browsers support JSON).");if(!a)throw Error("No container element provided.");this.container=a;this.dom={};this._setOptions(b);this._createFrame();this._createTable();this.set(c||{})};
JSONEditor.prototype._setOptions=function(a){this.options={enableSearch:true};if(a)for(var b in a)a.hasOwnProperty(b)&&(this.options[b]=a[b])};JSONEditor.focusNode=void 0;JSONEditor.prototype.set=function(a){if(a instanceof Function||a===void 0)this.clear();else{this.content.removeChild(this.table);a=new JSONEditor.Node({value:a});this._setRoot(a);this.node.expand(false);this.content.appendChild(this.table)}};JSONEditor.prototype.get=function(){JSONEditor.focusNode&&JSONEditor.focusNode.blur();if(this.node)return this.node.getValue()};
JSONEditor.prototype.clear=function(){if(this.node){this.node.collapse();this.tbody.removeChild(this.node.getDom());delete this.node}};JSONEditor.prototype._setRoot=function(a){this.clear();this.node=a;var b=this;a.getEditor=function(){return b};this.tbody.appendChild(a.getDom())};JSONEditor.prototype.search=function(a){if(this.node){this.content.removeChild(this.table);a=this.node.search(a);this.content.appendChild(this.table)}else a=[];return a};
JSONEditor.prototype.expandAll=function(){if(this.node){this.content.removeChild(this.table);this.node.expand();this.content.appendChild(this.table)}};JSONEditor.prototype.collapseAll=function(){if(this.node){this.content.removeChild(this.table);this.node.collapse();this.content.appendChild(this.table)}};JSONEditor.prototype.focus=function(){};
JSONEditor.prototype.scrollTo=function(a){var b=this.content;if(b){var c=this;if(c.animateTimeout){clearTimeout(c.animateTimeout);delete c.animateTimeout}var d=b.clientHeight,f=b.scrollHeight-d,e=Math.min(Math.max(a-d/4,0),f),g=function(){var a=e-b.scrollTop;if(Math.abs(a)>3){b.scrollTop=b.scrollTop+a/3;c.animateTimeout=setTimeout(g,50)}};g()}};
JSONEditor.Node=function(a){this.dom={};this.expanded=false;if(a&&a instanceof Object){this.setField(a.field,a.fieldEditable);this.setValue(a.value)}else{this.setField();this.setValue()}};JSONEditor.Node.prototype.setParent=function(a){this.parent=a};JSONEditor.Node.prototype.getParent=function(){return this.parent};JSONEditor.Node.prototype.getEditor=function(){return this.parent?this.parent.getEditor():void 0};JSONEditor.Node.prototype.setField=function(a,b){this.field=a;this.fieldEditable=b==true};
JSONEditor.Node.prototype.getField=function(){if(this.field===void 0)this.field=this._getDomField();return this.field};
JSONEditor.Node.prototype.setValue=function(a){var b=this.childs;if(b)for(;b.length;)this.removeChild(b[0]);this.type=this._getType(a);if(this.type=="array"){this.childs=[];for(var c=0,b=a.length;c<b;c++){var d=a[c];if(d!==void 0&&!(d instanceof Function)){d=new JSONEditor.Node({value:d});this.appendChild(d)}}this.value=""}else if(this.type=="object"){this.childs=[];for(c in a)if(a.hasOwnProperty(c)){d=a[c];if(d!==void 0&&!(d instanceof Function)){d=new JSONEditor.Node({field:c,value:d});this.appendChild(d)}}this.value=
""}else{this.childs=void 0;this.value=a}};JSONEditor.Node.prototype.getValue=function(){if(this.type=="array"){for(var a=[],b=this.childs,c=0,d=b.length;c<d;c++)a.push(b[c].getValue());return a}if(this.type=="object"){a={};b=this.childs;c=0;for(d=b.length;c<d;c++){var f=b[c];a[f.getField()]=f.getValue()}return a}if(this.value===void 0)this.value=this._getDomValue();return this.value};JSONEditor.Node.prototype.getLevel=function(){return this.parent?this.parent.getLevel()+1:0};
JSONEditor.Node.prototype.clone=function(){var a=new JSONEditor.Node;a.type=this.type;a.field=this.field;a.fieldHTML=this.fieldHTML;a.fieldEditable=this.fieldEditable;a.value=this.value;a.valueHTML=this.valueHTML;a.expanded=this.expanded;if(this.childs){for(var b=this.childs,c=[],d=0,f=b.length;d<f;d++){var e=b[d].clone();e.setParent(a);c.push(e)}a.childs=c}else a.childs=void 0;return a};
JSONEditor.Node.prototype.expand=function(a){if(this.childs){this.expanded=true;if(this.dom.expand)this.dom.expand.className="jsoneditor-expanded";this.showChilds();var b=this.childs;if(a!=false)for(var c=0,d=b.length;c<d;c++)b[c].expand(a)}};JSONEditor.Node.prototype.collapse=function(a){if(this.childs){this.hideChilds();var b=this.childs;if(a!=false)for(var c=0,d=b.length;c<d;c++)b[c].collapse(a);if(this.dom.expand)this.dom.expand.className="jsoneditor-collapsed";this.expanded=false}};
JSONEditor.Node.prototype.showChilds=function(){var a=this.childs;if(a&&this.expanded){var b=this.dom.tr,c=b?b.parentNode:void 0;if(c){var d=this.getAppend();(b=b.nextSibling)?c.insertBefore(d,b):c.appendChild(d);for(var b=0,f=a.length;b<f;b++){var e=a[b];c.insertBefore(e.getDom(),d);e.showChilds()}}}};JSONEditor.Node.prototype.hide=function(){var a=this.dom.tr,b=a?a.parentNode:void 0;b&&b.removeChild(a);this.hideChilds()};
JSONEditor.Node.prototype.hideChilds=function(){var a=this.childs;if(a&&this.expanded){var b=this.getAppend();b.parentNode&&b.parentNode.removeChild(b);for(var b=0,c=a.length;b<c;b++)a[b].hide()}};
JSONEditor.Node.prototype.appendChild=function(a){if(this.type=="array"||this.type=="object"){a.setParent(this);a.fieldEditable=this.type=="object";if(this.type=="array")a.index=this.childs.length;this.childs.push(a);if(this.expanded){var b=a.getDom(),c=this.getAppend(),d=c?c.parentNode:void 0;c&&d&&d.insertBefore(b,c);this._updateStatus(a.index);a.showChilds()}a.updateDom()}};
JSONEditor.Node.prototype.moveBefore=function(a,b){if(this.type=="array"||this.type=="object"){var c=this.dom.tr?this.dom.tr.parentNode:void 0;if(c){var d=document.createElement("tr");d.style.height=c.clientHeight+"px";c.appendChild(d)}var f=a.getParent();f&&f.removeChild(a);b instanceof JSONEditor.AppendNode?this.appendChild(a):this.insertBefore(a,b);c&&c.removeChild(d)}};
JSONEditor.Node.prototype.insertBefore=function(a,b){if(this.type=="array"||this.type=="object"){if(b==this.append){a.setParent(this);a.fieldEditable=this.type=="object";this.childs.push(a)}else{var c=this.childs.indexOf(b);if(c==-1)throw Error("Node not found");a.setParent(this);a.fieldEditable=this.type=="object";this.childs.splice(c,0,a)}if(this.expanded){var d=a.getDom(),f=b.getDom(),e=f?f.parentNode:void 0;f&&e&&e.insertBefore(d,f);a.showChilds()}a.updateDom();this._updateStatus(c)}};
JSONEditor.Node.prototype.search=function(a){var b=[],c,d=a?a.toLowerCase():void 0;delete this.searchField;delete this.searchValue;if(this.field!=void 0){c=String(this.field).toLowerCase().indexOf(d);if(c!=-1){this.searchField=true;b.push({node:this,elem:"field"})}this._updateDomField()}if(this.type=="array"||this.type=="object"){if(c=this.childs){for(var f=[],e=0,g=c.length;e<g;e++)f=f.concat(c[e].search(a));b=b.concat(f)}d!=void 0&&(f.length==0?this.collapse(false):this.expand(false))}else{if(this.value!=
void 0){c=String(this.value).toLowerCase().indexOf(d);if(c!=-1){this.searchValue=true;b.push({node:this,elem:"value"})}}this._updateDomValue()}return b};JSONEditor.Node.prototype.scrollTo=function(){if(!this.dom.tr||!this.dom.tr.parentNode)for(var a=this.parent;a;){a.expand(false);a=a.parent}if(this.dom.tr&&this.dom.tr.parentNode)(a=this.getEditor())&&a.scrollTo(this.dom.tr.offsetTop)};
JSONEditor.Node.prototype.focus=function(a){if(this.dom.tr&&this.dom.tr.parentNode)(a=a!="value"&&this.fieldEditable?this.dom.field:this.dom.value)&&a.focus()};JSONEditor.Node.prototype.blur=function(){this._getDomValue(true);this._getDomField(true)};JSONEditor.Node.prototype._duplicate=function(a){var b=a.clone();this.insertBefore(b,a)};
JSONEditor.Node.prototype.containsNode=function(a){if(this==a)return true;var b=this.childs;if(b)for(var c=0,d=b.length;c<d;c++)if(b[c].containsNode(a))return true;return false};JSONEditor.Node.prototype._move=function(a,b){if(a!=b){if(a.containsNode(this))throw Error("Cannot move a field into a child of itself");a.parent&&a.parent.removeChild(a);var c=a.clone();a.clearDom();b?this.insertBefore(c,b):this.appendChild(c)}};
JSONEditor.Node.prototype.removeChild=function(a){if(this.childs){var b=this.childs.indexOf(a);if(b!=-1){a.hide();a=this.childs.splice(b,1)[0];this._updateStatus(b);return a}}};
JSONEditor.Node.prototype._changeType=function(a){var b=this.type;if((a=="string"||a=="auto")&&(b=="string"||b=="auto"))this.type=a;else{var c=this.dom.tr?this.dom.tr.parentNode:void 0,d;d=(d=this.expanded?this.getAppend():this.getDom())&&d.parentNode?d.nextSibling:void 0;this.hide();this.clearDom();this.type=a;if(a=="object"){if(!this.childs)this.childs=[];for(var f=this.childs,e=0,g=f.length;e<g;e++){var h=f[e];h.clearDom();delete h.index;h.fieldEditable=true;if(h.field==void 0)h.field=e}if(b==
"string"||b=="auto")this.expanded=true}else if(a=="array"){if(!this.childs)this.childs=[];f=this.childs;e=0;for(g=f.length;e<g;e++){h=f[e];h.clearDom();h.fieldEditable=false;h.index=e}this._updateStatus();if(b=="string"||b=="auto")this.expanded=true}else this.expanded=false;c&&(d?c.insertBefore(this.getDom(),d):c.appendChild(this.getDom()));this.showChilds()}if(a=="auto"||a=="string"){this.value=a=="string"?String(this.value):this._stringCast(String(this.value));this.focus()}this.updateDom()};
JSONEditor.Node.prototype._getDomValue=function(a){if(this.dom.value&&this.type!="array"&&this.type!="object")this.valueHTML=this.dom.value.innerHTML;if(this.valueHTML!=void 0)try{if(this.type=="string")this.value=this._unescape(this._stripHTML(this.valueHTML));else{var b=this._unescape(this._stripHTML(this.valueHTML));this.value=this._stringCast(b)}}catch(c){this.value=void 0;if(a!=true)throw c;}};
JSONEditor.Node.prototype._updateDomValue=function(){var a=this.dom.value;if(a){var b=this.value,c=this.type=="auto"?typeof b:this.type,d="";c=="string"?d="green":c=="number"?d="red":c=="boolean"?d="blue":this.type=="object"||this.type=="array"?d="":b===null?d="purple":b===void 0&&(d="green");a.style.color=d;String(this.value)==""&&this.type!="array"&&this.type!="object"?JSONEditor.addClassName(a,"jsoneditor-empty"):JSONEditor.removeClassName(a,"jsoneditor-empty");this.searchValueActive?JSONEditor.addClassName(a,
"jsoneditor-search-highlight-active"):JSONEditor.removeClassName(a,"jsoneditor-search-highlight-active");this.searchValue?JSONEditor.addClassName(a,"jsoneditor-search-highlight"):JSONEditor.removeClassName(a,"jsoneditor-search-highlight");JSONEditor.stripFormatting(a)}};
JSONEditor.Node.prototype._updateDomField=function(){var a=this.dom.field;if(a){String(this.field)==""?JSONEditor.addClassName(a,"jsoneditor-empty"):JSONEditor.removeClassName(a,"jsoneditor-empty");this.searchFieldActive?JSONEditor.addClassName(a,"jsoneditor-search-highlight-active"):JSONEditor.removeClassName(a,"jsoneditor-search-highlight-active");this.searchField?JSONEditor.addClassName(a,"jsoneditor-search-highlight"):JSONEditor.removeClassName(a,"jsoneditor-search-highlight");JSONEditor.stripFormatting(a)}};
JSONEditor.Node.prototype._getDomField=function(a){if(this.dom.field&&this.fieldEditable)this.fieldHTML=this.dom.field.innerHTML;if(this.fieldHTML!=void 0)try{this.field=this._unescape(this._stripHTML(this.fieldHTML))}catch(b){this.field=void 0;if(a!=true)throw b;}};JSONEditor.Node.prototype.clearDom=function(){this.dom={}};
JSONEditor.Node.prototype.getDom=function(){var a=this.dom;if(a.tr)return a.tr;a.tr=document.createElement("tr");a.tr.className="jsoneditor-tr";a.tr.node=this;var b=document.createElement("td");b.className="jsoneditor-td";a.drag=this._createDomDragArea();a.drag&&b.appendChild(a.drag);a.tr.appendChild(b);b=document.createElement("td");b.className="jsoneditor-td";a.tr.appendChild(b);a.expand=this._createDomExpandButton();a.field=this._createDomField();a.value=this._createDomValue();a.tree=this._createDomTree(a.expand,
a.field,a.value);b.appendChild(a.tree);b=document.createElement("td");b.className="jsoneditor-td jsoneditor-td-edit";a.tr.appendChild(b);a.type=this._createDomTypeButton();b.appendChild(a.type);b=document.createElement("td");b.className="jsoneditor-td jsoneditor-td-edit";a.tr.appendChild(b);a.duplicate=this._createDomDuplicateButton();a.duplicate&&b.appendChild(a.duplicate);b=document.createElement("td");b.className="jsoneditor-td jsoneditor-td-edit";a.tr.appendChild(b);a.remove=this._createDomRemoveButton();
a.remove&&b.appendChild(a.remove);this._updateStatus();this.updateDom();return a.tr};
JSONEditor.Node.prototype._onDragStart=function(a){a=a||window.event;JSONEditor.focusNode&&JSONEditor.focusNode.blur();var b=this;if(!this.mousemove)this.mousemove=JSONEditor.Events.addEventListener(document,"mousemove",function(a){b._onDrag(a)});if(!this.mouseup)this.mouseup=JSONEditor.Events.addEventListener(document,"mouseup",function(a){b._onDragEnd(a)});JSONEditor.freezeHighlight=true;this.oldCursor=document.body.style.cursor;document.body.style.cursor="move";JSONEditor.Events.preventDefault(a)};
JSONEditor.Node.prototype._onDrag=function(a){var a=a||window.event,b=this.dom.tr,c=JSONEditor.getAbsoluteTop(b),d=b.offsetHeight,f=a.pageY||a.clientY+document.body.scrollTop;if(f<c){for(var c=b.previousSibling,b=JSONEditor.getAbsoluteTop(c),e=JSONEditor.getNodeFromTarget(c);c&&f<b;){e=JSONEditor.getNodeFromTarget(c);c=c.previousSibling;b=JSONEditor.getAbsoluteTop(c)}if(e){c=e.dom.tr;b=JSONEditor.getAbsoluteTop(c);f>b+d&&(e=void 0)}e&&e.parent&&e.parent.moveBefore(this,e)}else if(e=(d=this.expanded&&
this.append?this.append.getDom():this.dom.tr)?d.nextSibling:void 0){for(var d=JSONEditor.getAbsoluteTop(e),b=void 0,e=e.nextSibling,g=JSONEditor.getAbsoluteTop(e),g=e?g-d:0;e&&f>c+g;){b=JSONEditor.getNodeFromTarget(e);e=e.nextSibling;g=JSONEditor.getAbsoluteTop(e);g=e?g-d:0}b&&b.parent&&b.parent.moveBefore(this,b)}JSONEditor.Events.preventDefault(a)};
JSONEditor.Node.prototype._onDragEnd=function(a){a=a||window.event;document.body.style.cursor=this.oldCursor;delete JSONEditor.freezeHighlight;delete this.oldCursor;this.setHighlight(false);if(this.mousemove){JSONEditor.Events.removeEventListener(document,"mousemove",this.mousemove);delete this.mousemove}if(this.mouseup){JSONEditor.Events.removeEventListener(document,"mouseup",this.mouseup);delete this.mouseup}JSONEditor.Events.preventDefault(a)};
JSONEditor.Node.prototype._createDomDragArea=function(){if(this.parent){var a=document.createElement("button");a.className="jsoneditor-dragarea";a.title="Move field (drag and drop)";return a}};JSONEditor.Node.prototype._createDomField=function(){return document.createElement("div")};
JSONEditor.Node.prototype.setHighlight=function(a){if(!JSONEditor.freezeHighlight&&this.dom.tr){this.dom.tr.className="jsoneditor-tr"+(a?" jsoneditor-tr-highlight":"");this.append&&this.append.setHighlight(a);var b=this.childs;if(b)for(var c=0,d=b.length;c<d;c++)b[c].setHighlight(a)}};
JSONEditor.Node.prototype.updateDom=function(){var a=this.dom.tree;if(a)a.style.marginLeft=this.getLevel()*24+"px";if(a=this.dom.field){if(this.fieldEditable==true){a.contentEditable="true";a.spellcheck=false;a.className="jsoneditor-field"}else a.className="jsoneditor-readonly";a.innerHTML=this._escape(this.index!=void 0?this.index:this.field!=void 0?this.field:this.type=="array"||this.type=="object"?this.type:"field")}this._updateDomField();this._updateDomValue();if(this.childs)for(var a=this.childs,
b=0,c=a.length;b<c;b++)a[b].updateDom();this.append&&this.append.updateDom()};
JSONEditor.Node.prototype._updateStatus=function(a){var b=this.dom.value,c=this.childs;if(b&&c){var d=c.length;if(this.type=="array"){b.innerHTML="["+d+"]";for(var a=a>0?a:0,f=c.length;a<f;a++){var e=c[a];e.index=a;if(e=e.dom.field)e.innerHTML=a}}else if(this.type=="object"){b.innerHTML="{"+d+"}";a=a>0?a:0;for(f=c.length;a<f;a++){e=c[a];if(e.index!=void 0){delete e.index;if(e.field==void 0)e.field="field";e.updateDom()}}}b.title=this.type+" containing "+d+" items"}};
JSONEditor.Node.prototype._createDomValue=function(){var a;if(this.type=="array"){a=document.createElement("div");a.className="jsoneditor-readonly";a.innerHTML="[...]"}else if(this.type=="object"){a=document.createElement("div");a.className="jsoneditor-readonly";a.innerHTML="{...}"}else{a=document.createElement("div");a.contentEditable="true";a.spellcheck=false;a.className="jsoneditor-value";a.innerHTML=this._escape(this.value)}return a};
JSONEditor.Node.prototype._createDomExpandButton=function(){var a=document.createElement("button");if(this.type=="array"||this.type=="object"){a.className=this.expanded?"jsoneditor-expanded":"jsoneditor-collapsed";a.title="Click to expand/collapse this field. \nCtrl+Click to expand/collapse including all childs."}else{a.className="jsoneditor-invisible";a.title=""}return a};
JSONEditor.Node.prototype._createDomTree=function(a,b,c){var d=this.dom,f=document.createElement("table"),e=document.createElement("tbody");f.style.borderCollapse="collapse";f.appendChild(e);var g=document.createElement("tr");e.appendChild(g);e=document.createElement("td");e.className="jsoneditor-td-tree";g.appendChild(e);e.appendChild(a);d.tdExpand=e;a=document.createElement("td");a.className="jsoneditor-td-tree";g.appendChild(a);a.appendChild(b);d.tdField=a;b=document.createElement("td");b.className=
"jsoneditor-td-tree";g.appendChild(b);if(this.type!="object"&&this.type!="array"){b.appendChild(document.createTextNode(":"));b.className="jsoneditor-separator"}d.tdSeparator=b;b=document.createElement("td");b.className="jsoneditor-td-tree";g.appendChild(b);b.appendChild(c);d.tdValue=b;return f};
JSONEditor.Node.prototype.onEvent=function(a){var b=a.type,c=a.target||a.srcElement,d=this.dom,f=this,e=this.type=="array"||this.type=="object",g=d.value;if(c==g)switch(b){case "focus":JSONEditor.focusNode=this;break;case "change":case "blur":case "keyup":this._getDomValue(true);this._updateDomValue();break;case "cut":case "paste":setTimeout(function(){f._getDomValue(true);f._updateDomValue()},1)}var h=d.field;if(c==h)switch(b){case "focus":JSONEditor.focusNode=this;break;case "change":case "blur":case "keyup":this._getDomField(true);
this._updateDomField();break;case "cut":case "paste":setTimeout(function(){f._getDomField(true);f._updateDomField()},1)}if(c==d.drag)switch(b){case "mousedown":this._onDragStart(a);break;case "mouseover":this.setHighlight(true);break;case "mouseout":this.setHighlight(false)}c==d.expand&&b=="click"&&e&&this._onExpand(a);if(c==d.duplicate)switch(b){case "click":this.parent._duplicate(this);break;case "mouseover":this.setHighlight(true);break;case "mouseout":this.setHighlight(false)}if(c==d.remove)switch(b){case "click":this.parent.removeChild(this);
break;case "mouseover":this.setHighlight(true);break;case "mouseout":this.setHighlight(false)}if(c==d.type)switch(b){case "click":this._onTypeButton(a);break;case "mouseover":this.setHighlight(true);break;case "mouseout":this.setHighlight(false)}if(c==d.tree.parentNode)switch(b){case "click":if((a.offsetX!=void 0?a.offsetX<(this.getLevel()+1)*24:a.clientX<JSONEditor.getAbsoluteLeft(d.tdSeparator))||e){if(h){JSONEditor.setEndOfContentEditable(h);h.focus()}}else if(g){JSONEditor.setEndOfContentEditable(g);
g.focus()}}if(c==d.tdExpand&&!e||c==d.tdField||c==d.tdSeparator)switch(b){case "click":if(h){JSONEditor.setEndOfContentEditable(h);h.focus()}}};JSONEditor.Node.prototype._onExpand=function(a){a=a||window.event;if(a=a.ctrlKey){var b=this.dom.tr.parentNode,c=b.parentNode,d=c.scrollTop;c.removeChild(b)}this.expanded?this.collapse(a):this.expand(a);if(a){c.appendChild(b);c.scrollTop=d}};
JSONEditor.Node.types=[{value:"array",className:"jsoneditor-option-array",title:'Field type "array". An array contains an ordered collection of values.'},{value:"auto",className:"jsoneditor-option-auto",title:'Field type "auto". The field type is automatically determined from the value and can be a string, number, boolean, or null.'},{value:"object",className:"jsoneditor-option-object",title:'Field type "object". An object contains an unordered set of key/value pairs.'},{value:"string",className:"jsoneditor-option-string",
title:'Field type "string". Field type is not determined from the value, but always returned as string.'}];JSONEditor.Node.prototype._createDomTypeButton=function(){var a=document.createElement("button");a.className="jsoneditor-type-"+this.type;a.title="Change field type";return a};
JSONEditor.Node.prototype._onTypeButton=function(a){JSONEditor.Events.stopPropagation(a);var b=this.dom.type,c=this,a=JSONEditor.getAbsoluteLeft(b),d=JSONEditor.getAbsoluteTop(b)+b.clientHeight;JSONEditor.showDropDownList({x:a,y:d,node:c,value:c.type,values:JSONEditor.Node.types,className:"jsoneditor-select",optionSelectedClassName:"jsoneditor-option-selected",optionClassName:"jsoneditor-option",callback:function(a){c._changeType(a);b.className="jsoneditor-type-"+c.type}})};
JSONEditor.showDropDownList=function(a){var b=document.createElement("div");b.className=a.className||"";b.style.position="absolute";b.style.left=(a.x||0)+"px";b.style.top=(a.y||0)+"px";for(var c=0;c<a.values.length;c++){var d=a.values[c],f=d.value||String(d),e="jsoneditor-option";f==a.value&&(e=e+(" "+a.optionSelectedClassName));var g=document.createElement("div");g.className=e;if(d.title)g.title=d.title;e=document.createElement("div");e.className=d.className||"";g.appendChild(e);e=document.createElement("div");
e.className="jsoneditor-option-text";e.innerHTML="<div>"+f+"</div>";g.appendChild(e);g.onmousedown=function(b){return function(){a.callback(b)}}(d.value);b.appendChild(g)}document.body.appendChild(b);a.node.setHighlight(true);JSONEditor.freezeHighlight=true;var h=JSONEditor.Events.addEventListener(document,"mousedown",function(){JSONEditor.freezeHighlight=false;a.node.setHighlight(false);document.body.removeChild(b);JSONEditor.Events.removeEventListener(document,"mousedown",h)}),i=JSONEditor.Events.addEventListener(document,
"mousewheel",function(){JSONEditor.freezeHighlight=false;a.node.setHighlight(false);document.body.removeChild(b);JSONEditor.Events.removeEventListener(document,"mousewheel",i)})};JSONEditor.Node.prototype.getAppend=function(){if(!this.append){this.append=new JSONEditor.AppendNode;this.append.setParent(this)}return this.append.getDom()};
JSONEditor.Node.prototype._createDomRemoveButton=function(){if(this.parent&&(this.parent.type=="array"||this.parent.type=="object")){var a=document.createElement("button");a.className="jsoneditor-remove";a.title="Remove field (including all its childs)";return a}};
JSONEditor.Node.prototype._createDomDuplicateButton=function(){if(this.parent&&(this.parent.type=="array"||this.parent.type=="object")){var a=document.createElement("button");a.className="jsoneditor-duplicate";a.title="Duplicate field (including all childs)";return a}};JSONEditor.Node.prototype._getType=function(a){return a instanceof Array?"array":a instanceof Object?"object":typeof a=="string"&&typeof this._stringCast(a)!="string"?"string":"auto"};
JSONEditor.Node.prototype._stringCast=function(a){var b=a.toLowerCase(),c=Number(a),d=parseFloat(a);return a==""?"":b=="null"?null:b=="true"?true:b=="false"?false:!isNaN(c)&&!isNaN(d)?c:a};JSONEditor.Node.prototype._escape=function(a){a=String(a).replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g," &nbsp;").replace(/^ /,"&nbsp;").replace(/ $/,"&nbsp;");a=JSON.stringify(a);return a.substring(1,a.length-1)};
JSONEditor.Node.prototype._unescape=function(a){return JSON.parse('"'+a+'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ")};JSONEditor.Node.prototype._stripHTML=function(a){return a.replace(/<(?:.|\n)*?>/gm,"")};JSONEditor.AppendNode=function(){this.dom={}};JSONEditor.AppendNode.prototype=new JSONEditor.Node;
JSONEditor.AppendNode.prototype.getDom=function(){function a(a){var b=document.createElement("td");b.className=a||"";return b}if(this.dom.tr)return this.dom.tr;var b=document.createElement("tr");b.appendChild(a("jsoneditor-td"));b.node=this;var c=document.createElement("td");b.appendChild(c);c.className="jsoneditor-td";var d=document.createElement("button");d.className="jsoneditor-append";d.title="Append a field";this.dom.append=d;c.appendChild(d);b.appendChild(a("jsoneditor-td jsoneditor-td-edit"));
b.appendChild(a("jsoneditor-td jsoneditor-td-edit"));b.appendChild(a("jsoneditor-td jsoneditor-td-edit"));this.dom.tr=b;this.dom.td=c;this.updateDom();return b};JSONEditor.AppendNode.prototype.updateDom=function(){var a=this.dom.td;if(a)a.style.paddingLeft=this.getLevel()*24+26+"px"};
JSONEditor.AppendNode.prototype.onEvent=function(a){var b=a.type;if((a.target||a.srcElement)==this.dom.append)switch(b){case "click":a=new JSONEditor.Node({field:"field",value:"value"});this.parent.appendChild(a);this.parent.setHighlight(false);a.focus();break;case "mouseover":this.parent.setHighlight(true);break;case "mouseout":this.parent.setHighlight(false)}};
JSONEditor.prototype._createFrame=function(){this.container.innerHTML="";this.frame=document.createElement("div");this.frame.className="jsoneditor-frame";this.container.appendChild(this.frame);var a=this,b=function(a){var a=a||window.event,b=JSONEditor.getNodeFromTarget(a.target||a.srcElement);if(b)b.onEvent(a)};this.frame.onclick=function(a){b(a);JSONEditor.Events.preventDefault(a)};this.frame.onchange=b;this.frame.onkeydown=b;this.frame.onkeyup=b;this.frame.oncut=b;this.frame.onpaste=b;this.frame.onmousedown=
b;this.frame.onmouseup=b;this.frame.onmouseover=b;this.frame.onmouseout=b;JSONEditor.Events.addEventListener(this.frame,"focus",b,true);JSONEditor.Events.addEventListener(this.frame,"blur",b,true);this.frame.onfocusin=b;this.frame.onfocusout=b;this.head=document.createElement("table");this.head.className="jsoneditor-menu";var c=document.createElement("tbody");this.head.appendChild(c);var d=document.createElement("tr");c.appendChild(d);this.tdMenu=c=document.createElement("td");c.className="jsoneditor-menu";
d.appendChild(c);d=document.createElement("button");d.innerHTML="Expand All";d.title="Expand all fields";d.onclick=function(){a.expandAll()};c.appendChild(d);d=document.createElement("button");d.innerHTML="Collapse All";d.title="Collapse all fields";d.onclick=function(){a.collapseAll()};c.appendChild(d);if(this.options.enableSearch)this.searchBox=new JSONEditor.SearchBox(this,c);this.frame.appendChild(this.head)};
JSONEditor.prototype._createTable=function(){var a=document.createElement("div");a.className="jsoneditor-content-outer";this.contentOuter=a;this.content=document.createElement("div");this.content.className="jsoneditor-content";a.appendChild(this.content);this.table=document.createElement("table");this.table.className="jsoneditor-table";this.content.appendChild(this.table);if(JSONEditor.getInternetExplorerVersion()==8)this.content.style.overflow="scroll";var b;this.colgroupContent=document.createElement("colgroup");
b=document.createElement("col");b.width="24px";this.colgroupContent.appendChild(b);b=document.createElement("col");this.colgroupContent.appendChild(b);b=document.createElement("col");b.width="24px";this.colgroupContent.appendChild(b);b=document.createElement("col");b.width="24px";this.colgroupContent.appendChild(b);b=document.createElement("col");b.width="24px";this.colgroupContent.appendChild(b);this.table.appendChild(this.colgroupContent);this.tbody=document.createElement("tbody");this.table.appendChild(this.tbody);
this.frame.appendChild(a)};JSONEditor.getNodeFromTarget=function(a){for(;a;){if(a.node)return a.node;a=a.parentNode}};
JSONFormatter=function(a){if(!JSON)throw Error("Your browser does not support JSON. \n\nPlease install the newest version of your browser.\n(all modern browsers support JSON).");this.container=a;this.width=a.clientWidth;this.height=a.clientHeight;this.frame=document.createElement("div");this.frame.className="jsoneditor-frame";this.frame.onclick=function(a){JSONEditor.Events.preventDefault(a)};this.head=document.createElement("table");this.head.className="jsoneditor-menu";a=document.createElement("tbody");
this.head.appendChild(a);var b=document.createElement("tr");a.appendChild(b);a=document.createElement("td");a.className="jsoneditor-menu";b.appendChild(a);b=document.createElement("button");b.innerHTML="Format";b.title="Format JSON data, with proper indentation and line feeds";b.className="jsoneditor-button";a.appendChild(b);var c=document.createElement("button");c.innerHTML="Compact";c.title="Compact JSON data, remove all whitespaces";c.className="jsoneditor-button";a.appendChild(c);this.frame.appendChild(this.head);
this.content=document.createElement("div");this.content.className="jsonformatter-content";this.frame.appendChild(this.content);this.textarea=document.createElement("textarea");this.textarea.className="jsonformatter-textarea";this.textarea.spellcheck=false;this.content.appendChild(this.textarea);var d=this.textarea,f=this;b.onclick=function(){try{d.value=JSON.stringify(JSON.parse(d.value),null," ")}catch(a){f.onError(a)}};c.onclick=function(){try{d.value=JSON.stringify(JSON.parse(d.value))}catch(a){f.onError(a)}};
this.container.appendChild(this.frame)};JSONFormatter.prototype.onError=function(){};JSONFormatter.prototype._checkChange=function(){var a=this.textarea.value;if(a!=this.lastContent){this.lastContent=a;if(this.onChangeCallback)this.onChangeCallback()}};JSONFormatter.prototype.set=function(a){this.textarea.value=JSON.stringify(a,null," ")};JSONFormatter.prototype.get=function(){return JSON.parse(this.textarea.value)};
JSONEditor.SearchBox=function(a,b){var c=this;this.editor=a;this.timeout=void 0;this.delay=200;this.lastText=void 0;this.dom={};this.dom.container=b;var d=document.createElement("table");this.dom.table=d;d.className="jsoneditor-search";b.appendChild(d);var f=document.createElement("tbody");this.dom.tbody=f;d.appendChild(f);d=document.createElement("tr");f.appendChild(d);f=document.createElement("td");f.className="jsoneditor-search";d.appendChild(f);var e=document.createElement("div");this.dom.results=
e;e.className="jsoneditor-search-results";f.appendChild(e);f=document.createElement("td");f.className="jsoneditor-search";d.appendChild(f);d=document.createElement("div");this.dom.input=d;d.className="jsoneditor-search";d.title="Search fields and values";f.appendChild(d);f=document.createElement("table");f.className="jsoneditor-search-input";d.appendChild(f);e=document.createElement("tbody");f.appendChild(e);d=document.createElement("tr");e.appendChild(d);e=document.createElement("button");e.className=
"jsoneditor-search-refresh";f=document.createElement("td");f.appendChild(e);d.appendChild(f);var g=document.createElement("input");this.dom.search=g;g.className="jsoneditor-search";g.oninput=function(a){c.onDelayedSearch(a)};g.onchange=function(a){c.onSearch(a)};g.onkeydown=function(a){c.onKeyDown(a)};g.onkeyup=function(a){c.onKeyUp(a)};e.onclick=function(){g.select()};f=document.createElement("td");f.appendChild(g);d.appendChild(f);e=document.createElement("button");e.title="Next result (Enter)";
e.className="jsoneditor-search-next";e.onclick=function(){c.next()};f=document.createElement("td");f.appendChild(e);d.appendChild(f);e=document.createElement("button");e.title="Previous result (Shift+Enter)";e.className="jsoneditor-search-previous";e.onclick=function(){c.previous()};f=document.createElement("td");f.appendChild(e);d.appendChild(f)};
JSONEditor.SearchBox.prototype.next=function(){if(this.results!=void 0){var a=this.resultIndex!=void 0?this.resultIndex+1:0;a>this.results.length-1&&(a=0);this.setActiveResult(a)}};JSONEditor.SearchBox.prototype.previous=function(){if(this.results!=void 0){var a=this.results.length-1,b=this.resultIndex!=void 0?this.resultIndex-1:a;b<0&&(b=a);this.setActiveResult(b)}};
JSONEditor.SearchBox.prototype.setActiveResult=function(a){if(this.activeResult){var b=this.activeResult.node;this.activeResult.elem=="field"?delete b.searchFieldActive:delete b.searchValueActive;b.updateDom()}if(!this.results||!this.results[a])this.activeResult=this.resultIndex=void 0;else{this.resultIndex=a;a=this.results[this.resultIndex].node;this.results[this.resultIndex].elem=="field"?a.searchFieldActive=true:a.searchValueActive=true;this.activeResult=this.results[this.resultIndex];a.updateDom();
a.scrollTo()}};JSONEditor.SearchBox.prototype.focusActiveResult=function(){this.activeResult||this.next();this.activeResult&&this.activeResult.node.focus(this.activeResult.elem)};JSONEditor.SearchBox.prototype.clearDelay=function(){if(this.timeout!=void 0){clearTimeout(this.timeout);delete this.timeout}};JSONEditor.SearchBox.prototype.onDelayedSearch=function(){this.clearDelay();var a=this;this.timeout=setTimeout(function(b){a.onSearch(b)},this.delay)};
JSONEditor.SearchBox.prototype.onSearch=function(a,b){this.clearDelay();var c=this.dom.search.value,c=c.length>0?c:void 0;if(c!=this.lastText||b){this.lastText=c;this.results=editor.search(c);this.setActiveResult(void 0);if(c!=void 0){c=this.results.length;switch(c){case 0:this.dom.results.innerHTML="no&nbsp;results";break;case 1:this.dom.results.innerHTML="1&nbsp;result";break;default:this.dom.results.innerHTML=c+"&nbsp;results"}}else this.dom.results.innerHTML=""}};
JSONEditor.SearchBox.prototype.onKeyDown=function(a){var a=a||window.event,b=a.which||a.keyCode;if(b==27){this.dom.search.value="";this.onSearch(a);alert(1);JSONEditor.Events.preventDefault(a);JSONEditor.Events.stopPropagation(a)}else if(b==13){if(a.ctrlKey)this.onSearch(a,true);else a.shiftKey?this.previous():this.next();JSONEditor.Events.preventDefault(a);JSONEditor.Events.stopPropagation(a)}};
JSONEditor.SearchBox.prototype.onKeyUp=function(a){var a=a||window.event,b=a.which||a.keyCode;if(b!=27&&b!=13)this.onDelayedSearch(a)};JSONEditor.Events={};JSONEditor.Events.addEventListener=function(a,b,c,d){if(a.addEventListener){d===void 0&&(d=false);b==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(b="DOMMouseScroll");a.addEventListener(b,c,d);return c}d=function(){return c.call(a,window.event)};a.attachEvent("on"+b,d);return d};
JSONEditor.Events.removeEventListener=function(a,b,c,d){if(a.removeEventListener){d===void 0&&(d=false);b==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(b="DOMMouseScroll");a.removeEventListener(b,c,d)}else a.detachEvent("on"+b,c)};JSONEditor.Events.stopPropagation=function(a){if(!a)a=window.event;a.stopPropagation?a.stopPropagation():a.cancelBubble=true};JSONEditor.Events.preventDefault=function(a){if(!a)a=window.event;a.preventDefault?a.preventDefault():a.returnValue=false};
JSONEditor.getAbsoluteLeft=function(a){for(var b=0,c=document.body;a!=null&&a!=c;){b=b+a.offsetLeft;b=b-a.scrollLeft;a=a.offsetParent}return b};JSONEditor.getAbsoluteTop=function(a){for(var b=0,c=document.body;a!=null&&a!=c;){b=b+a.offsetTop;b=b-a.scrollTop;a=a.offsetParent}return b};JSONEditor.addClassName=function(a,b){var c=a.className;if(c.indexOf(b)==-1)a.className=c+(" "+b)};
JSONEditor.removeClassName=function(a,b){var c=a.className;if(c.indexOf(b)!=-1){c=c.replace(b,"");c=c.replace(/ /g,"");a.className=c}};JSONEditor.stripFormatting=function(a){for(var a=a.childNodes,b=0,c=a.length;b<c;b++){var d=a[b];d.style&&d.removeAttribute("style");var f=d.attributes;if(f)for(var e=f.length-1;e>=0;e--){var g=f[e];g.specified==true&&d.removeAttribute(g.name)}JSONEditor.stripFormatting(d)}};
JSONEditor.setEndOfContentEditable=function(a){var b;if(document.createRange){b=document.createRange();b.selectNodeContents(a);b.collapse(false);a=window.getSelection();a.removeAllRanges();a.addRange(b)}else if(document.selection){b=document.body.createTextRange();b.moveToElementText(a);b.collapse(false);b.select()}};
JSONEditor.getInternetExplorerVersion=function(){var a=-1;navigator.appName=="Microsoft Internet Explorer"&&/MSIE ([0-9]{1,}[.0-9]{0,})/.exec(navigator.userAgent)!=null&&(a=parseFloat(RegExp.$1));return a};JSONEditor.ieVersion=JSONEditor.getInternetExplorerVersion();

View File

@ -43,14 +43,14 @@
<link rel="shortcut icon" href="favicon.ico">
<link href="interface.css" rel="stylesheet" type="text/css">
<link href="jsoneditor.css" rel="stylesheet" type="text/css">
<link href="interface/interface.css" rel="stylesheet" type="text/css">
<link href="jsoneditor/jsoneditor.css" rel="stylesheet" type="text/css">
<!-- TODO: droid font
<link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
-->
<script type="text/javascript" src="jsoneditor.js"></script>
<script type="text/javascript" src="interface.js"></script>
<script type="text/javascript" src="jsoneditor/jsoneditor.js"></script>
<script type="text/javascript" src="interface/interface.js"></script>
</head>

View File

@ -7,11 +7,11 @@
<meta name="keywords" content="json, editor, couchdb, online, javascript, javascript object notation, treeview, open source, free">
<meta name="author" content="Jos de Jong">
<link rel="shortcut icon" href="favicon.ico">
<link rel="shortcut icon" href="../favicon.ico">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" src="jsoneditor.js"></script>
<link rel="stylesheet" type="text/css" href="jsoneditor.css">
<script type="text/javascript" src="../jsoneditor/jsoneditor.js"></script>
<link rel="stylesheet" type="text/css" href="../jsoneditor/jsoneditor.css">
<style type="text/css">
body, html {

View File

@ -5,7 +5,7 @@ sh minify.sh
cd ..
package="jsoneditoronline.zip"
files="index.html jsoneditor.js jsoneditor-min.js jsoneditor.css favicon.ico changelog.txt img LICENSE ../NOTICE"
files="index.html jsoneditor/jsoneditor.js jsoneditor/jsoneditor-min.js jsoneditor/jsoneditor.css favicon.ico changelog.txt jsoneditor/img LICENSE NOTICE README"
rm $package

View File

@ -1,8 +1,8 @@
#!/bin/sh
compiler="compiler.jar"
file="../jsoneditor.js"
minifiedFile="../jsoneditor-min.js"
file="../jsoneditor/jsoneditor.js"
minifiedFile="../jsoneditor/jsoneditor-min.js"
echo "Minifying file $file..."