diff --git a/README.md b/README.md index 7685895a8..726744c03 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,12 @@ TODO! In the examples below, `sensesp` is used as the device name. -SensESP implements a RESTful configuration API. A list of +You can configure your device with any web browser by going to + + http://sensesp.local + + +SensESP also implements a RESTful configuration API. A list of possible configuration keys can be retrieved from: http://sensesp.local/config @@ -78,7 +83,7 @@ Configuration can be updated with HTTP PUT requests: - [x] Improved device configuration system - [x] Authentication token support - [x] Make the project a library -- [ ] Web configuration UI +- [x] Web configuration UI - [ ] Control device support. For now, all devices are read-only, and control devices such as leds, relays, or PWM output are not supported. diff --git a/extra_script.py b/extra_script.py new file mode 100644 index 000000000..9e636c2dd --- /dev/null +++ b/extra_script.py @@ -0,0 +1,31 @@ +Import("env") + +def make_c_header(inName, outName): + + print 'Writing ',inName,' to src/net/web/',outName,'.h' + + infile = open('web/docroot/' + inName, "r") + outfile = open("src/net/web/" + outName + ".h","w") + + outfile.write("#include \n") + outfile.write("const char PAGE_") + outfile.write(outName) + outfile.write("[] PROGMEM = R\"=====(\n") + + for line in infile: + outfile.write(line) + + outfile.write("\n)=====\";\n") + + infile.close() + outfile.close() + + +def build_webUI(*args, **kwargs): + env.Execute("terser --compress --output web/docroot/js/sensesp.min.js -- web/docroot/js/sensesp.js") + make_c_header("js/sensesp.min.js", "js_sensesp") + make_c_header("js/jsoneditor.min.js", "js_jsoneditor") + make_c_header("index.html", "index") + make_c_header("setup/index.html", "setup") + +env.AlwaysBuild(env.Alias("webUI", None, build_webUI)) diff --git a/platformio.ini b/platformio.ini index 57371dc28..6f53f27a3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -36,3 +36,7 @@ lib_deps = DallasTemperature ESP8266TrueRandom https://github.com/JoaoLopesF/RemoteDebug.git#0b5a9c1a49fd2ade0e3cadc3a3707781e819359a + + +extra_scripts = extra_script.py + diff --git a/src/devices/onewire_temperature.cpp b/src/devices/onewire_temperature.cpp index f107d46f3..ffc32909a 100644 --- a/src/devices/onewire_temperature.cpp +++ b/src/devices/onewire_temperature.cpp @@ -139,6 +139,19 @@ JsonObject& OneWireTemperature::get_configuration(JsonBuffer& buf) { return root; } + +String OneWireTemperature::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "address": { "title": "OneWire address", "type": "string" }, + "value": { "title": "Last value", "type" : "number", "readOnly": true } + } + })"; +} + + + bool OneWireTemperature::set_configuration(const JsonObject& config) { if (!config.containsKey("address")) { return false; diff --git a/src/devices/onewire_temperature.h b/src/devices/onewire_temperature.h index f05a989ec..05ce172e8 100644 --- a/src/devices/onewire_temperature.h +++ b/src/devices/onewire_temperature.h @@ -31,7 +31,8 @@ class OneWireTemperature : public NumericDevice { void enable() override final; virtual JsonObject& get_configuration(JsonBuffer& buf) override final; virtual bool set_configuration(const JsonObject& config) override final; - + virtual String get_config_schema() override; + private: OneWire* onewire; DallasTemperatureSensors* dts; diff --git a/src/net/http.cpp b/src/net/http.cpp index 10e1d9aeb..fc7011b20 100644 --- a/src/net/http.cpp +++ b/src/net/http.cpp @@ -15,6 +15,12 @@ #include "sensesp_app.h" #include "system/configurable.h" +// Include the web UI stored in PROGMEM space +#include "web/index.h" +#include "web/setup.h" +#include "web/js_jsoneditor.h" +#include "web/js_sensesp.h" + // HTTP port for the configuration interface #ifndef HTTP_SERVER_PORT #define HTTP_SERVER_PORT 80 @@ -24,11 +30,10 @@ HTTPServer::HTTPServer(std::function reset_device) { this->reset_device = reset_device; server = new AsyncWebServer(HTTP_SERVER_PORT); using std::placeholders::_1; + server->onNotFound(std::bind(&HTTPServer::handle_not_found, this, _1)); - server->on("/",[](AsyncWebServerRequest *request ) { - request->send_P(200, "text/html", "SensESP"); - }); + // Handle setting configuration values of a Configurable via a Json PUT to /config AsyncCallbackJsonWebHandler* config_put_handler = new AsyncCallbackJsonWebHandler( "/config", @@ -68,6 +73,10 @@ HTTPServer::HTTPServer(std::function reset_device) { }); config_put_handler->setMethod(HTTP_PUT); server->addHandler(config_put_handler); + + + // Handle requests to retrieve the current Json configuration of a Configurable + // via HTTP GET on /config server->on("/config", HTTP_GET, [this] (AsyncWebServerRequest *request) { // omit the "/config" part of the url String url_tail = request->url().substring(7); @@ -95,13 +104,37 @@ HTTPServer::HTTPServer(std::function reset_device) { request->send(response); }); + + server->on("/", HTTP_GET, [](AsyncWebServerRequest *request) { + debugD("Serving index.html"); + request->send_P(200, "text/html", PAGE_index); + }); + + server->on("/setup", HTTP_GET, [](AsyncWebServerRequest *request) { + debugD("Serving setup.html"); + request->send_P(200, "text/html", PAGE_setup); + }); + + server->on("/js/jsoneditor.min.js", HTTP_GET, [](AsyncWebServerRequest *request) { + debugD("Serving jsoneditor.min.js"); + request->send_P(200, "text/javascript", PAGE_js_jsoneditor); + }); + + + server->on("/js/sensesp.js", HTTP_GET, [](AsyncWebServerRequest *request) { + debugD("Serving sensesp.js"); + request->send_P(200, "text/javascript", PAGE_js_sensesp); + }); + + server->on("/device/reset", HTTP_GET, std::bind(&HTTPServer::handle_device_reset, this, _1)); server->on("/device/restart", HTTP_GET, std::bind(&HTTPServer::handle_device_restart, this, _1)); server->on("/info", HTTP_GET, std::bind(&HTTPServer::handle_info, this, _1)); - } +} + void HTTPServer::handle_not_found(AsyncWebServerRequest* request) { debugD("NOT_FOUND: "); @@ -178,6 +211,8 @@ void HTTPServer::handle_device_restart(AsyncWebServerRequest* request) { app.onDelay(50, [](){ ESP.restart(); }); } + void HTTPServer::handle_info(AsyncWebServerRequest* request) { request->send(200, "text/plain", "/info"); } + diff --git a/src/net/networking.cpp b/src/net/networking.cpp index 81fee2340..3a4635b3c 100644 --- a/src/net/networking.cpp +++ b/src/net/networking.cpp @@ -77,6 +77,17 @@ void Networking::set_hostname(String hostname) { this->hostname->set(hostname); } + +String Networking::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "hostname": { "title": "Network SSID", "type": "string" } + } + })"; +} + + JsonObject& Networking::get_configuration(JsonBuffer& buf) { JsonObject& root = buf.createObject(); root["hostname"] = this->hostname->get(); diff --git a/src/net/networking.h b/src/net/networking.h index 8f07a0439..87c2180fb 100644 --- a/src/net/networking.h +++ b/src/net/networking.h @@ -17,7 +17,8 @@ class Networking : public Configurable { ObservableValue* get_hostname(); virtual JsonObject& get_configuration(JsonBuffer& buf) override final; virtual bool set_configuration(const JsonObject& config) override final; - + virtual String get_config_schema() override; + void set_hostname(String hostname); void reset_settings(); diff --git a/src/net/web/index.h b/src/net/web/index.h new file mode 100644 index 000000000..181af5ff1 --- /dev/null +++ b/src/net/web/index.h @@ -0,0 +1,19 @@ +#include +const char PAGE_index[] PROGMEM = R"=====( + + +SensESP SignalK Sensor + + +

SensESP SignalK Sensor

+Your options: + + + + +)====="; diff --git a/src/net/web/js_jsoneditor.h b/src/net/web/js_jsoneditor.h new file mode 100644 index 000000000..2882fc8be --- /dev/null +++ b/src/net/web/js_jsoneditor.h @@ -0,0 +1,22 @@ +#include +const char PAGE_js_jsoneditor[] PROGMEM = R"=====( +/** + * @name JSON Editor + * @description JSON Schema Based Editor + * This library is the continuation of jdorn's great work (see also https://github.com/jdorn/json-editor/issues/800) + * @version 1.3.5 + * @author Jeremy Dorn + * @see https://github.com/jdorn/json-editor/ + * @see https://github.com/json-editor/json-editor + * @license MIT + * @example see README.md and docs/ for requirements, examples and usage info + */ +!function(a,b){"use strict";var c=b(a);"object"==typeof module&&null!=module&&module.exports?module.exports=c:"function"==typeof define&&define.amd?define(function(){return c}):a.JSONEditor=c}("undefined"!=typeof window?window:this,function(a,b){var c;!function(){var a=!1,b=/xyz/.test(function(){window.postMessage("xyz")})?/\b_super\b/:/.*/;return c=function(){},c.extend=function d(c){function e(){!a&&this.init&&this.init.apply(this,arguments)}var f=this.prototype;a=!0;var g=new this;a=!1;for(var h in c)g[h]="function"==typeof c[h]&&"function"==typeof f[h]&&b.test(c[h])?function(a,b){return function(){var c=this._super;this._super=f[a];var d=b.apply(this,arguments);return this._super=c,d}}(h,c[h]):c[h];return e.prototype=g,e.prototype.constructor=e,e.extend=d,e},c}(),function(){function a(a,c){c=c||{bubbles:!1,cancelable:!1,detail:b};var d=document.createEvent("CustomEvent");return d.initCustomEvent(a,c.bubbles,c.cancelable,c.detail),d}a.prototype=window.Event.prototype,window.CustomEvent=a}(),function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c0&&a.length-1 in a){for(c=0;c=i&&!j&&(j=!0,b())},c,k)}},f.send()}}),i||b()},expandRefs:function(a){for(a=e({},a);a.$ref;){var b=this.refs_with_info[a.$ref];delete a.$ref;var c="";b.$ref.startsWith("#")&&(c=b.fetchUrl);var d=c+b.$ref;this.refs[d]||(d=c+decodeURIComponent(b.$ref)),a=this.extendSchemas(a,e({},this.refs[d]))}return a},expandSchema:function(a,b){var c,d=this,g=e({},a);if("object"==typeof a.type&&(Array.isArray(a.type)?f(a.type,function(b,c){"object"==typeof c&&(a.type[b]=d.expandSchema(c))}):a.type=d.expandSchema(a.type)),"object"==typeof a.disallow&&(Array.isArray(a.disallow)?f(a.disallow,function(b,c){"object"==typeof c&&(a.disallow[b]=d.expandSchema(c))}):a.disallow=d.expandSchema(a.disallow)),a.anyOf&&f(a.anyOf,function(b,c){a.anyOf[b]=d.expandSchema(c)}),a.dependencies&&f(a.dependencies,function(b,c){"object"!=typeof c||Array.isArray(c)||(a.dependencies[b]=d.expandSchema(c))}),a.not&&(a.not=this.expandSchema(a.not)),a.allOf){for(c=0;ca.minimum:c>=a.minimum,window.math?g=window.math[a.exclusiveMinimum?"larger":"largerEq"](window.math.bignumber(c),window.math.bignumber(a.minimum)):window.Decimal&&(g=new window.Decimal(c)[a.exclusiveMinimum?"gt":"gte"](new window.Decimal(a.minimum))),g||l.push({path:d,property:"minimum",message:this.translate(a.exclusiveMinimum?"error_minimum_excl":"error_minimum_incl",[a.minimum])}))}else if("string"==typeof c)a.maxLength&&(c+"").length>a.maxLength&&l.push({path:d,property:"maxLength",message:this.translate("error_maxLength",[a.maxLength])}),a.minLength&&(c+"").lengtha.maxItems&&l.push({path:d,property:"maxItems",message:this.translate("error_maxItems",[a.maxItems])}),a.minItems&&c.lengtha.maxProperties&&l.push({path:d,property:"maxProperties",message:this.translate("error_maxProperties",[a.maxProperties])})}if(a.minProperties){g=0;for(i in c)c.hasOwnProperty(i)&&g++;g0:this.dependenciesFulfilled=!g||0===g.length):this.dependenciesFulfilled=!1,this.dependenciesFulfilled!==h&&this.notify(),this.dependenciesFulfilled?d.style.display="block":d.style.display="none"}},setContainer:function(a){this.container=a,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 a=this;if(this.watched={},this.schema.vars&&(this.schema.watch=this.schema.vars),this.watched_values={},this.watch_listener=function(){a.refreshWatchedFieldValues()&&a.onWatchedFieldChange()},this.schema.hasOwnProperty("watch")){var b,c,d,e,f;for(var g in this.schema.watch)if(this.schema.watch.hasOwnProperty(g)){if(b=this.schema.watch[g],Array.isArray(b)){if(b.length<2)continue;c=[b[0]].concat(b[1].split("."))}else c=b.split("."),a.theme.closest(a.container,'[data-schemaid="'+c[0]+'"]')||c.unshift("#");if(d=c.shift(),"#"===d&&(d=a.jsoneditor.schema.id||"root"),e=a.theme.closest(a.container,'[data-schemaid="'+d+'"]'),!e)throw"Could not find ancestor node with id "+d;f=e.getAttribute("data-schemapath")+"."+c.join("."),a.jsoneditor.watch(f,a.watch_listener),a.watched[g]=f}}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 a=0;a=0){b=this.theme.getBlockLinkHolder(),c=this.theme.getBlockLink(),c.setAttribute("target","_blank");var j=document.createElement(e);j.setAttribute("controls","controls"),this.theme.createMediaLink(b,c,j),this.link_watchers.push(function(a){var b=f(a),d=g(a);c.setAttribute("href",b),c.textContent=d||b,j.setAttribute("src",b)})}else c=b=this.theme.getBlockLink(),b.setAttribute("target","_blank"),b.textContent=a.rel,this.link_watchers.push(function(a){var c=f(a),d=g(a);b.setAttribute("href",c),b.textContent=d||c});return h&&c&&(h===!0?c.setAttribute("download",""):this.link_watchers.push(function(a){c.setAttribute("download",h(a))})),a["class"]&&c.classList.add(a["class"]),b},refreshWatchedFieldValues:function(){if(this.watched_values){var a={},b=!1,c=this;if(this.watched){var d,e;for(var f in this.watched)this.watched.hasOwnProperty(f)&&(e=c.jsoneditor.getEditor(this.watched[f]),d=e?e.getValue():null,c.watched_values[f]!==d&&(b=!0),a[f]=d)}return a.self=this.getValue(),this.watched_values.self!==a.self&&(b=!0),this.watched_values=a,b}},getWatchedFieldValues:function(){return this.watched_values},updateHeaderText:function(){if(this.header)if(this.header.children.length){for(var a=0;a-1:!!this.jsoneditor.options.required_by_default},getDisplayText:function(a){var b=[],c={};f(a,function(a,b){b.title&&(c[b.title]=c[b.title]||0,c[b.title]++),b.description&&(c[b.description]=c[b.description]||0,c[b.description]++),b.format&&(c[b.format]=c[b.format]||0,c[b.format]++),b.type&&(c[b.type]=c[b.type]||0,c[b.type]++)}),f(a,function(a,d){var e;e="string"==typeof d?d:d.title&&c[d.title]<=1?d.title:d.format&&c[d.format]<=1?d.format:d.type&&c[d.type]<=1?d.type:d.description&&c[d.description]<=1?d.descripton:d.title?d.title:d.format?d.format:d.type?d.type:d.description?d.description:JSON.stringify(d).length<500?JSON.stringify(d):"type",b.push(e)});var d={};return f(b,function(a,e){d[e]=d[e]||0,d[e]++,c[e]>1&&(b[a]=e+" "+d[e])}),b},getValidId:function(a){return a=a===b?"":a.toString(),a.replace(/\s+/g,"-")},setInputAttributes:function(a){if(this.schema.options&&this.schema.options.inputAttributes){var b=this.schema.options.inputAttributes,c=["name","type"].concat(a);for(var d in b)b.hasOwnProperty(d)&&c.indexOf(d.toLowerCase())==-1&&this.input.setAttribute(d,b[d])}},getOption:function(a){try{throw"getOption is deprecated"}catch(b){window.console.error(b)}return this.options[a]},showValidationErrors:function(a){}}),h.defaults.editors["null"]=h.AbstractEditor.extend({getValue:function(){return this.dependenciesFulfilled?null:b},setValue:function(){this.onChange()},getNumColumns:function(){return 2}}),h.defaults.editors.string=h.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(a,b,c){if((!this.template||c)&&(null===a||"undefined"==typeof a?a="":"object"==typeof a?a=JSON.stringify(a):"string"!=typeof a&&(a=""+a), +a!==this.serialized)){var d=this.sanitize(a);if(this.input.value!==d){this.input.value=d,this.sceditor_instance?this.sceditor_instance.val(d):this.SimpleMDE?this.SimpleMDE.value(d):this.ace_editor&&(this.ace_editor.setValue(d),this.ace_editor.session.getSelection().clearSelection(),this.ace_editor.resize());var e=c||this.getValue()!==a;this.refreshValue(),b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.adjust_height&&this.adjust_height(this.input),this.onChange(e)}}},getNumColumns:function(){var a,b=Math.ceil(Math.max(this.getTitle().length,this.schema.maxLength||0,this.schema.minLength||0)/5);return a="textarea"===this.input_type?6:["text","email"].indexOf(this.input_type)>=0?4:2,Math.min(12,Math.max(b,a))},build:function(){var a=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.options.infoText&&(this.infoButton=this.theme.getInfoButton(this.options.infoText)),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 b=this.schema.minimum||0,c=this.schema.maximum||Math.max(100,b+1),d=1;this.schema.multipleOf&&(b%this.schema.multipleOf&&(b=Math.ceil(b/this.schema.multipleOf)*this.schema.multipleOf),c%this.schema.multipleOf&&(c=Math.floor(c/this.schema.multipleOf)*this.schema.multipleOf),d=this.schema.multipleOf),this.input=this.theme.getRangeInput(b,c,d)}else["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","sqlserver","stylus","svg","twig","vbscript","xml","yaml"].indexOf(this.format)>=0?(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);if("undefined"!=typeof this.schema.maxLength&&this.input.setAttribute("maxlength",this.schema.maxLength),"undefined"!=typeof this.schema.pattern?this.input.setAttribute("pattern",this.schema.pattern):"undefined"!=typeof this.schema.minLength&&this.input.setAttribute("pattern",".{"+this.schema.minLength+",}"),this.options.compact?this.container.classList.add("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.setAttribute("readonly","true")),this.setInputAttributes(["maxlength","pattern","readonly","min","max","step"]),this.input.addEventListener("change",function(b){if(b.preventDefault(),b.stopPropagation(),a.schema.template)return void(this.value=a.value);var c=this.value,d=a.sanitize(c);c!==d&&(this.value=d),a.is_dirty=!0,a.refreshValue(),a.onChange(!0)}),this.options.input_height&&(this.input.style.height=this.options.input_height),this.options.expand_height&&(this.adjust_height=function(a){if(a){var b,c=a.offsetHeight;if(a.offsetHeight100);)b++,c++,a.style.height=c+"px";else{for(b=0;a.offsetHeight>=a.scrollHeight+3&&!(b>100);)b++,c--,a.style.height=c+"px";a.style.height=c+1+"px"}}},this.input.addEventListener("keyup",function(b){a.adjust_height(this)}),this.input.addEventListener("change",function(b){a.adjust_height(this)}),this.adjust_height()),this.format&&this.input.setAttribute("data-schemaformat",this.format),this.control=this.theme.getFormControl(this.label,this.input,this.description,this.infoButton),"range"===this.format){var e=document.createElement("output");e.setAttribute("class","range-output"),this.control.appendChild(e),e.value=this.schema["default"],this.input.addEventListener("change",function(){e.value=a.input.value}),this.input.addEventListener("input",function(){e.value=a.input.value})}this.container.appendChild(this.control),window.requestAnimationFrame(function(){a.input.parentNode&&a.afterInputReady(),a.adjust_height&&a.adjust_height(a.input)}),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue()):this.refreshValue()},postBuild:function(){this._super(),window.Cleave&&this.schema.options&&"object"==typeof this.schema.options.cleave&&(this.cleave=new window.Cleave(this.input,this.schema.options.cleave))},enable:function(){this.always_disabled||(this.input.disabled=!1,this._super())},disable:function(a){a&&(this.always_disabled=!0),this.input.disabled=!0,this._super()},afterInputReady:function(){var a,b=this;if(this.source_code)if(this.options.wysiwyg&&["html","bbcode"].indexOf(this.input_type)>=0&&window.jQuery&&window.jQuery.fn&&window.jQuery.fn.sceditor)a=e({},{plugins:"html"===b.input_type?"xhtml":"bbcode",emoticonsEnabled:!1,width:"100%",height:300},h.plugins.sceditor,b.options.sceditor_options||{}),window.jQuery(b.input).sceditor(a),b.sceditor_instance=window.jQuery(b.input).sceditor("instance"),b.sceditor_instance.blur(function(){var a=window.jQuery("
"+b.sceditor_instance.val()+"
");window.jQuery("#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf",a).remove(),b.input.value=a.html(),b.value=b.input.value,b.is_dirty=!0,b.onChange(!0)});else if("markdown"===this.input_type&&window.SimpleMDE)a=e({},h.plugins.SimpleMDE,{element:this.input}),this.SimpleMDE=new window.SimpleMDE(a),this.SimpleMDE.codemirror.on("change",function(){b.value=b.SimpleMDE.value(),b.is_dirty=!0,b.onChange(!0)});else if(window.ace){var c=this.input_type;"cpp"!==c&&"c++"!==c&&"c"!==c||(c="c_cpp"),this.ace_container=document.createElement("div"),this.ace_container.style.width="100%",this.ace_container.style.position="relative",this.ace_container.style.height="400px",this.input.parentNode.insertBefore(this.ace_container,this.input),this.input.style.display="none",this.ace_editor=window.ace.edit(this.ace_container);var d=this.schema.options&&this.schema.options.ace;d&&this.ace_editor.setOptions(d),this.ace_editor.setValue(this.getValue()),this.ace_editor.session.getSelection().clearSelection(),this.ace_editor.resize(),h.plugins.ace.theme&&this.ace_editor.setTheme("ace/theme/"+h.plugins.ace.theme),this.ace_editor.getSession().setMode("ace/mode/"+this.schema.format),this.ace_editor.on("change",function(){var a=b.ace_editor.getValue();b.input.value=a,b.refreshValue(),b.is_dirty=!0,b.onChange(!0)})}b.theme.afterInputReady(b.input)},refreshValue:function(){this.value=this.input.value,"string"!=typeof this.value&&(this.value=""),this.serialized=this.value},destroy:function(){this.sceditor_instance?this.sceditor_instance.destroy():this.SimpleMDE?(this.SimpleMDE.toTextArea(),this.SimpleMDE=null):this.ace_editor&&this.ace_editor.destroy(),this.cleave&&this.cleave.destroy(),this.template=null,this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this._super()},sanitize:function(a){return a},onWatchedFieldChange:function(){var a;this.template&&(a=this.getWatchedFieldValues(),this.setValue(this.template(a),!1,!0)),this._super()},showValidationErrors:function(a){var b=this;if("always"===this.jsoneditor.options.show_errors);else if(!this.is_dirty&&this.previous_error_setting===this.jsoneditor.options.show_errors)return;this.previous_error_setting=this.jsoneditor.options.show_errors;var c=[];f(a,function(a,d){d.path===b.path&&c.push(d.message)}),c.length?this.theme.addInputError(this.input,c.join(". ")+"."):this.theme.removeInputError(this.input)}}),h.defaults.editors.hidden=h.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(a,b,c){if((!this.template||c)&&(null===a||"undefined"==typeof a?a="":"object"==typeof a?a=JSON.stringify(a):"string"!=typeof a&&(a=""+a),a!==this.serialized)){var d=this.sanitize(a);if(this.input.value!==d){this.input.value=d;var e=c||this.getValue()!==a;this.refreshValue(),b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.adjust_height&&this.adjust_height(this.input),this.onChange(e)}}},getNumColumns:function(){return 2},enable:function(){this._super()},disable:function(){this._super()},refreshValue:function(){this.value=this.input.value,"string"!=typeof this.value&&(this.value=""),this.serialized=this.value},destroy:function(){this.template=null,this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this._super()},sanitize:function(a){return a},onWatchedFieldChange:function(){var a;this.template&&(a=this.getWatchedFieldValues(),this.setValue(this.template(a),!1,!0)),this._super()},build:function(){this.format=this.schema.format,!this.format&&this.options.default_format&&(this.format=this.options.default_format),this.options.format&&(this.format=this.options.format),this.input_type="hidden",this.input=this.theme.getFormInputField(this.input_type),this.format&&this.input.setAttribute("data-schemaformat",this.format),this.container.appendChild(this.input),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue()):this.refreshValue()}}),h.defaults.editors.number=h.defaults.editors.string.extend({build:function(){if(this._super(),"undefined"!=typeof this.schema.minimum){var a=this.schema.minimum;"undefined"!=typeof this.schema.exclusiveMinimum&&(a+=1),this.input.setAttribute("min",a)}if("undefined"!=typeof this.schema.maximum){var b=this.schema.maximum;"undefined"!=typeof this.schema.exclusiveMaximum&&(b-=1),this.input.setAttribute("max",b)}if("undefined"!=typeof this.schema.step){var c=this.schema.step||1;this.input.setAttribute("step",c)}this.setInputAttributes(["maxlength","pattern","readonly","min","max","step"])},sanitize:function(a){return(a+"").replace(/[^0-9\.\-eE]/g,"")},getNumColumns:function(){return 2},getValue:function(){return this.dependenciesFulfilled?""===this.value?b:1*this.value:b}}),h.defaults.editors.integer=h.defaults.editors.number.extend({sanitize:function(a){return a+="",a.replace(/[^0-9\-]/g,"")},getNumColumns:function(){return 2}}),h.defaults.editors.rating=h.defaults.editors.integer.extend({build:function(){var a,b=this;this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description));var c="json-editor-style-rating",d=document.getElementById(c);if(!d){var e=document.createElement("style");e.id=c,e.type="text/css",e.innerHTML=" .rating-container { display: inline-block; clear: both; } .rating { float:left; } /* :not(:checked) is a filter, so that browsers that don’t support :checked don’t follow these rules. Every browser that supports :checked also supports :not(), so it doesn’t make the test unnecessarily selective */ .rating:not(:checked) > input { position:absolute; top:-9999px; clip:rect(0,0,0,0); } .rating:not(:checked) > label { float:right; width:1em; padding:0 .1em; overflow:hidden; white-space:nowrap; cursor:pointer; color:#ddd; } .rating:not(:checked) > label:before { content: '★ '; } .rating > input:checked ~ label { color: #FFB200; } .rating:not([readOnly]):not(:checked) > label:hover, .rating:not([readOnly]):not(:checked) > label:hover ~ label { color: #FFDA00; } .rating:not([readOnly]) > input:checked + label:hover, .rating:not([readOnly]) > input:checked + label:hover ~ label, .rating:not([readOnly]) > input:checked ~ label:hover, .rating:not([readOnly]) > input:checked ~ label:hover ~ label, .rating:not([readOnly]) > label:hover ~ input:checked ~ label { color: #FF8C0D; } .rating:not([readOnly]) > label:active { position:relative; top:2px; left:2px; }",document.getElementsByTagName("head")[0].appendChild(e)}this.input=this.theme.getFormInputField("hidden"),this.container.appendChild(this.input);var g=document.createElement("div");g.classList.add("rating-container");var h=document.createElement("div");h.setAttribute("name",this.formname),h.classList.add("rating"),g.appendChild(h),this.options.compact&&this.container.setAttribute("class",this.container.getAttribute("class")+" compact");var i=this.schema.maximum?this.schema.maximum:5;for(this.schema.exclusiveMaximum&&i--,this.inputs=[],a=i;a>0;a--){var j=this.formname+a,k=this.theme.getFormInputField("radio");k.setAttribute("id",j),k.setAttribute("value",a),k.setAttribute("name",this.formname),h.appendChild(k),this.inputs.push(k);var l=document.createElement("label");l.setAttribute("for",j),l.appendChild(document.createTextNode(a+(1==a?" star":" stars"))),h.appendChild(l)}(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,f(this.inputs,function(a,b){h.setAttribute("readOnly","readOnly"),b.disabled=!0})),g.addEventListener("change",function(a){a.preventDefault(),a.stopPropagation(),b.input.value=a.srcElement.value,b.is_dirty=!0,b.refreshValue(),b.watch_listener(),b.jsoneditor.notifyWatchers(b.path),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),this.control=this.theme.getFormControl(this.label,g,this.description),this.container.appendChild(this.control),this.refreshValue()},setValue:function(a){var b=this.sanitize(a);if(this.value!==b){var c=this;f(this.inputs,function(a,d){if(d.value===b)return d.checked=!0,c.value=b,c.input.value=c.value,c.watch_listener(),c.jsoneditor.notifyWatchers(c.path),!1})}}}),h.defaults.editors.object=h.AbstractEditor.extend({getDefault:function(){return e({},this.schema["default"]||{})},getChildEditors:function(){return this.editors},register:function(){if(this._super(),this.editors)for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].register()},unregister:function(){if(this._super(),this.editors)for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].unregister()},getNumColumns:function(){return Math.max(Math.min(12,this.maxwidth),3)},enable:function(){if(!this.always_disabled&&(this.editjson_button&&(this.editjson_button.disabled=!1),this.addproperty_button&&(this.addproperty_button.disabled=!1),this._super(),this.editors))for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].enable()},disable:function(a){if(a&&(this.always_disabled=!0),this.editjson_button&&(this.editjson_button.disabled=!0),this.addproperty_button&&(this.addproperty_button.disabled=!0),this.hideEditJSON(),this._super(),this.editors)for(var b in this.editors)this.editors.hasOwnProperty(b)&&this.editors[b].disable(a)},layoutEditors:function(){var a,b,c=this;if(this.row_container){this.property_order=Object.keys(this.editors),this.property_order=this.property_order.sort(function(a,b){var d=c.editors[a].schema.propertyOrder,e=c.editors[b].schema.propertyOrder;return"number"!=typeof d&&(d=1e3),"number"!=typeof e&&(e=1e3),d-e});var d,e="categories"===this.format;if("grid"===this.format){var h=[];for(f(this.property_order,function(a,b){var d=c.editors[b];if(!d.property_removed){for(var e=!1,f=d.options.hidden?0:d.options.grid_columns||d.getNumColumns(),g=d.options.hidden?0:d.container.offsetHeight,i=0;ig)&&(e=i);e===!1&&(h.push({width:0,minh:999999,maxh:0,editors:[]}),e=h.length-1),h[e].editors.push({key:b,width:f,height:g}),h[e].width+=f,h[e].minh=Math.min(h[e].minh,g),h[e].maxh=Math.max(h[e].maxh,g)}}),a=0;ah[a].editors[i].width&&(i=b),h[a].editors[b].width*=12/h[a].width,h[a].editors[b].width=Math.floor(h[a].editors[b].width),j+=h[a].editors[b].width;j<12&&(h[a].editors[i].width+=12-j),h[a].width=12}if(this.layout===JSON.stringify(h))return!1;for(this.layout=JSON.stringify(h),d=document.createElement("div"),a=0;a0?p.firstChild.isObjOrArray&&(e.appendChild(n),p.insertBefore(e,p.firstChild),c.theme.insertBasicTopTab(d.tab,o),d.basicPane=e):(e.appendChild(n),p.appendChild(e),c.theme.addTopTab(o,d.tab),d.basicPane=e)),d.options.hidden?d.container.style.display="none":c.theme.setGridColumnSize(d.container,12),g.appendChild(d.container),d.rowPane=e}});this.tabPanesContainer.firstChild;)this.tabPanesContainer.removeChild(this.tabPanesContainer.firstChild);var q=this.tabs_holder.parentNode;q.removeChild(q.firstChild),q.appendChild(o),this.tabPanesContainer=p,this.tabs_holder=o;var r=this.theme.getFirstTab(this.tabs_holder);return void(r&&g(r,"click"))}f(this.property_order,function(a,b){var e=c.editors[b];if(!e.property_removed){var f=c.theme.getGridRow();d.appendChild(f),e.options.hidden?e.container.style.display="none":c.theme.setGridColumnSize(e.container,12),f.appendChild(e.container)}})}for(;this.row_container.firstChild;)this.row_container.removeChild(this.row_container.firstChild);this.row_container.appendChild(d)}},getPropertySchema:function(a){var b=this.schema.properties[a]||{};b=e({},b);var c=!!this.schema.properties[a];if(this.schema.patternProperties)for(var d in this.schema.patternProperties)if(this.schema.patternProperties.hasOwnProperty(d)){var f=new RegExp(d);f.test(a)&&(b.allOf=b.allOf||[],b.allOf.push(this.schema.patternProperties[d]),c=!0)}return!c&&this.schema.additionalProperties&&"object"==typeof this.schema.additionalProperties&&(b=e({},this.schema.additionalProperties)),b},preBuild:function(){this._super(),this.editors={},this.cached_editors={};var a=this;if(this.format=this.options.layout||this.options.object_layout||this.schema.format||this.jsoneditor.options.object_layout||"normal",this.schema.properties=this.schema.properties||{},this.minwidth=0,this.maxwidth=0,this.options.table_row)f(this.schema.properties,function(b,c){var d=a.jsoneditor.getEditorClass(c);a.editors[b]=a.jsoneditor.createEditor(d,{jsoneditor:a.jsoneditor,schema:c,path:a.path+"."+b,parent:a,compact:!0,required:!0}),a.editors[b].preBuild();var e=a.editors[b].options.hidden?0:a.editors[b].options.grid_columns||a.editors[b].getNumColumns();a.minwidth+=e,a.maxwidth+=e}),this.no_link_holder=!0;else{if(this.options.table)throw"Not supported yet";this.schema.defaultProperties||(this.jsoneditor.options.display_required_only||this.options.display_required_only?(this.schema.defaultProperties=[],f(this.schema.properties,function(b,c){a.isRequired({key:b,schema:c})&&a.schema.defaultProperties.push(b)})):a.schema.defaultProperties=Object.keys(a.schema.properties)),a.maxwidth+=1,f(this.schema.defaultProperties,function(b,c){a.addObjectProperty(c,!0),a.editors[c]&&(a.minwidth=Math.max(a.minwidth,a.editors[c].options.grid_columns||a.editors[c].getNumColumns()),a.maxwidth+=a.editors[c].options.grid_columns||a.editors[c].getNumColumns())})}this.property_order=Object.keys(this.editors),this.property_order=this.property_order.sort(function(b,c){var d=a.editors[b].schema.propertyOrder,e=a.editors[c].schema.propertyOrder;return"number"!=typeof d&&(d=1e3),"number"!=typeof e&&(e=1e3),d-e})},addTab:function(a){var b=this,c=b.rows[a].schema&&("object"===b.rows[a].schema.type||"array"===b.rows[a].schema.type);b.tabs_holder&&(b.rows[a].tab_text=document.createElement("span"),c?b.rows[a].tab_text.textContent=b.rows[a].getHeaderText():b.rows[a].tab_text.textContent="undefined"==typeof b.schema.basicCategoryTitle?"Basic":b.schema.basicCategoryTitle,b.rows[a].tab=b.theme.getTopTab(b.rows[a].tab_text,this.getValidId(b.rows[a].tab_text.textContent)),b.rows[a].tab.addEventListener("click",function(c){b.active_tab=b.rows[a].tab,b.refreshTabs(),c.preventDefault(),c.stopPropagation()}))},addRow:function(a,b,c){var d=this,e=this.rows.length,f="object"===a.schema.type||"array"===a.schema.type;d.rows[e]=a,d.rows[e].rowPane=c,f?(d.addTab(e),d.theme.addTopTab(b,d.rows[e].tab)):"undefined"==typeof d.basicTab?(d.addTab(e),d.basicTab=e,d.basicPane=c,d.theme.addTopTab(b,d.rows[e].tab)):(d.rows[e].tab=d.rows[d.basicTab].tab,d.rows[e].tab_text=d.rows[d.basicTab].tab_text,d.rows[e].rowPane=d.rows[d.basicTab].rowPane)},refreshTabs:function(a){var b=this,c="undefined"!=typeof b.basicTab,d=!1;f(this.rows,function(e,f){f.tab&&f.rowPane&&f.rowPane.parentNode&&(c&&f.tab==b.rows[b.basicTab].tab&&d||(a?f.tab_text.textContent=f.getHeaderText():(c&&f.tab==b.rows[b.basicTab].tab&&(d=!0),f.tab===b.active_tab?b.theme.markTabActive(f):b.theme.markTabInactive(f))))})},build:function(){var a=this,b="categories"===this.format;if(this.rows=[],this.active_tab=null,this.options.table_row)this.editor_holder=this.container,f(this.editors,function(b,c){var d=a.theme.getTableCell();a.editor_holder.appendChild(d),c.setContainer(d),c.build(),c.postBuild(),a.editors[b].options.hidden&&(d.style.display="none"),a.editors[b].options.input_width&&(d.style.width=a.editors[b].options.input_width)});else{if(this.options.table)throw"Not supported yet";this.header=document.createElement("span"),this.header.textContent=this.getTitle(),this.title=this.theme.getHeader(this.header),this.container.appendChild(this.title),this.container.style.position="relative",this.editjson_holder=this.theme.getModal(),this.editjson_textarea=this.theme.getTextareaInput(),this.editjson_textarea.style.height="170px",this.editjson_textarea.style.width="300px",this.editjson_textarea.style.display="block",this.editjson_save=this.getButton("Save","save","Save"),this.editjson_save.classList.add("json-editor-btntype-save"),this.editjson_save.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.saveJSON()}),this.editjson_copy=this.getButton("Copy","copy","Copy"),this.editjson_copy.classList.add("json-editor-btntype-copy"),this.editjson_copy.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.copyJSON()}),this.editjson_cancel=this.getButton("Cancel","cancel","Cancel"),this.editjson_cancel.classList.add("json-editor-btntype-cancel"),this.editjson_cancel.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.hideEditJSON()}),this.editjson_holder.appendChild(this.editjson_textarea),this.editjson_holder.appendChild(this.editjson_save),this.editjson_holder.appendChild(this.editjson_copy),this.editjson_holder.appendChild(this.editjson_cancel),this.addproperty_holder=this.theme.getModal(),this.addproperty_list=document.createElement("div"),this.addproperty_list.style.width="295px",this.addproperty_list.style.maxHeight="160px",this.addproperty_list.style.padding="5px 0",this.addproperty_list.style.overflowY="auto",this.addproperty_list.style.overflowX="hidden",this.addproperty_list.style.paddingLeft="5px",this.addproperty_list.setAttribute("class","property-selector"),this.addproperty_add=this.getButton("add","add","add"),this.addproperty_add.classList.add("json-editor-btntype-add"),this.addproperty_input=this.theme.getFormInputField("text"),this.addproperty_input.setAttribute("placeholder","Property name..."),this.addproperty_input.style.width="220px",this.addproperty_input.style.marginBottom="0",this.addproperty_input.style.display="inline-block",this.addproperty_add.addEventListener("click",function(b){if(b.preventDefault(),b.stopPropagation(),a.addproperty_input.value){if(a.editors[a.addproperty_input.value])return void window.alert("there is already a property with that name");a.addObjectProperty(a.addproperty_input.value),a.editors[a.addproperty_input.value]&&a.editors[a.addproperty_input.value].disable(),a.onChange(!0)}}),this.addproperty_holder.appendChild(this.addproperty_list),this.addproperty_holder.appendChild(this.addproperty_input),this.addproperty_holder.appendChild(this.addproperty_add);var c=document.createElement("div");c.style.clear="both",this.addproperty_holder.appendChild(c),document.addEventListener("click",function(a){!this.addproperty_holder.contains(a.target)&&this.adding_property&&(a.preventDefault(),a.stopPropagation(),this.toggleAddProperty())}.bind(this)),this.schema.description&&(this.description=this.theme.getDescription(this.schema.description),this.container.appendChild(this.description)),this.error_holder=document.createElement("div"),this.container.appendChild(this.error_holder),this.editor_holder=this.theme.getIndentedPanel(),this.container.appendChild(this.editor_holder),this.row_container=this.theme.getGridContainer(),b?(this.tabs_holder=this.theme.getTopTabHolder(this.getValidId(this.schema.title)),this.tabPanesContainer=this.theme.getTopTabContentHolder(this.tabs_holder),this.editor_holder.appendChild(this.tabs_holder)):(this.tabs_holder=this.theme.getTabHolder(this.getValidId(this.schema.title)),this.tabPanesContainer=this.theme.getTabContentHolder(this.tabs_holder),this.editor_holder.appendChild(this.row_container)),f(this.editors,function(c,d){var e=a.theme.getTabContent(),f=a.theme.getGridColumn(),g=!(!d.schema||"object"!==d.schema.type&&"array"!==d.schema.type);if(e.isObjOrArray=g,b){if(g){var h=a.theme.getGridContainer();h.appendChild(f),e.appendChild(h),a.tabPanesContainer.appendChild(e),a.row_container=h}else"undefined"==typeof a.row_container_basic&&(a.row_container_basic=a.theme.getGridContainer(),e.appendChild(a.row_container_basic),0==a.tabPanesContainer.childElementCount?a.tabPanesContainer.appendChild(e):a.tabPanesContainer.insertBefore(e,a.tabPanesContainer.childNodes[1])),a.row_container_basic.appendChild(f);a.addRow(d,a.tabs_holder,e),e.id=a.getValidId(d.schema.title)}else a.row_container.appendChild(f);d.setContainer(f),d.build(),d.postBuild()}),this.rows[0]&&g(this.rows[0].tab,"click"),this.title_controls=this.theme.getHeaderButtonHolder(),this.editjson_controls=this.theme.getHeaderButtonHolder(),this.addproperty_controls=this.theme.getHeaderButtonHolder(),this.title.appendChild(this.title_controls),this.title.appendChild(this.editjson_controls),this.title.appendChild(this.addproperty_controls),this.collapsed=!1,this.toggle_button=this.getButton("","collapse",this.translate("button_collapse")),this.toggle_button.classList.add("json-editor-btntype-toggle"),this.title_controls.appendChild(this.toggle_button),this.toggle_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.collapsed?(a.editor_holder.style.display="",a.collapsed=!1,a.setButtonText(a.toggle_button,"","collapse",a.translate("button_collapse"))):(a.editor_holder.style.display="none",a.collapsed=!0,a.setButtonText(a.toggle_button,"","expand",a.translate("button_expand")))}),this.options.collapsed&&g(this.toggle_button,"click"),this.schema.options&&"undefined"!=typeof this.schema.options.disable_collapse?this.schema.options.disable_collapse&&(this.toggle_button.style.display="none"):this.jsoneditor.options.disable_collapse&&(this.toggle_button.style.display="none"),this.editjson_button=this.getButton("JSON","edit","Edit JSON"),this.editjson_button.classList.add("json-editor-btntype-editjson"),this.editjson_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.toggleEditJSON()}),this.editjson_controls.appendChild(this.editjson_button),this.editjson_controls.appendChild(this.editjson_holder),this.schema.options&&"undefined"!=typeof this.schema.options.disable_edit_json?this.schema.options.disable_edit_json&&(this.editjson_button.style.display="none"):this.jsoneditor.options.disable_edit_json&&(this.editjson_button.style.display="none"),this.addproperty_button=this.getButton("Properties","edit","Object Properties"),this.addproperty_button.classList.add("json-editor-btntype-properties"),this.addproperty_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.toggleAddProperty()}),this.addproperty_controls.appendChild(this.addproperty_button),this.addproperty_controls.appendChild(this.addproperty_holder),this.refreshAddProperties()}this.options.table_row?(this.editor_holder=this.container,f(this.property_order,function(b,c){a.editor_holder.appendChild(a.editors[c].container)})):(this.layoutEditors(),this.layoutEditors())},showEditJSON:function(){this.editjson_holder&&(this.hideAddProperty(),this.editjson_holder.style.left=this.editjson_button.offsetLeft+"px",this.editjson_holder.style.top=this.editjson_button.offsetTop+this.editjson_button.offsetHeight+"px",this.editjson_textarea.value=JSON.stringify(this.getValue(),null,2),this.disable(),this.editjson_holder.style.display="",this.editjson_button.disabled=!1,this.editing_json=!0)},hideEditJSON:function(){this.editjson_holder&&this.editing_json&&(this.editjson_holder.style.display="none",this.enable(),this.editing_json=!1)},copyJSON:function(){if(this.editjson_holder){var a=document.createElement("textarea");a.value=this.editjson_textarea.value,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}},saveJSON:function(){if(this.editjson_holder)try{var a=JSON.parse(this.editjson_textarea.value);this.setValue(a),this.hideEditJSON(),this.onChange(!0)}catch(b){throw window.alert("invalid JSON"),b}},toggleEditJSON:function(){this.editing_json?this.hideEditJSON():this.showEditJSON()},insertPropertyControlUsingPropertyOrder:function(a,b,c){var d;this.schema.properties[a]&&(d=this.schema.properties[a].propertyOrder),"number"!=typeof d&&(d=1e3),b.propertyOrder=d;for(var e=0;e=this.schema.maxProperties),this.addproperty_checkboxes&&(this.addproperty_list.innerHTML=""),this.addproperty_checkboxes={};for(a in this.cached_editors)this.cached_editors.hasOwnProperty(a)&&(this.addPropertyCheckbox(a),this.isRequired(this.cached_editors[a])&&a in this.editors&&(this.addproperty_checkboxes[a].disabled=!0),"undefined"!=typeof this.schema.minProperties&&d<=this.schema.minProperties?(this.addproperty_checkboxes[a].disabled=this.addproperty_checkboxes[a].checked,this.addproperty_checkboxes[a].checked||(e=!0)):a in this.editors?(e=!0,c=!0):b||this.schema.properties.hasOwnProperty(a)?(this.addproperty_checkboxes[a].disabled=!1,e=!0):this.addproperty_checkboxes[a].disabled=!0);this.canHaveAdditionalProperties()&&(e=!0);for(a in this.schema.properties)this.schema.properties.hasOwnProperty(a)&&(this.cached_editors[a]||(e=!0,this.addPropertyCheckbox(a)));e?this.canHaveAdditionalProperties()?b?this.addproperty_add.disabled=!1:this.addproperty_add.disabled=!0:(this.addproperty_add.style.display="none",this.addproperty_input.style.display="none"):(this.hideAddProperty(),this.addproperty_controls.style.display="none")},isRequired:function(a){return"boolean"==typeof a.schema.required?a.schema.required:Array.isArray(this.schema.required)?this.schema.required.indexOf(a.key)>-1:!!this.jsoneditor.options.required_by_default},setValue:function(a,b){var c=this;a=a||{},("object"!=typeof a||Array.isArray(a))&&(a={}),f(this.cached_editors,function(d,e){"undefined"!=typeof a[d]?(c.addObjectProperty(d),e.setValue(a[d],b)):b||c.isRequired(e)?e.setValue(e.getDefault(),b):c.removeObjectProperty(d)}),f(a,function(a,d){c.cached_editors[a]||(c.addObjectProperty(a),c.editors[a]&&c.editors[a].setValue(d,b))}),this.refreshValue(),this.layoutEditors(),this.onChange()},showValidationErrors:function(a){var b=this,c=[],d=[];if(f(a,function(a,e){e.path===b.path?c.push(e):d.push(e)}),this.error_holder)if(c.length){this.error_holder.innerHTML="",this.error_holder.style.display="",f(c,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none";this.options.table_row&&(c.length?this.theme.addTableRowError(this.container):this.theme.removeTableRowError(this.container)),f(this.editors,function(a,b){b.showValidationErrors(d)})}}),h.defaults.editors.array=h.AbstractEditor.extend({askConfirmation:function(){return this.jsoneditor.options.prompt_before_delete!==!0||confirm("Are you sure you want to remove this node?")!==!1},getDefault:function(){return this.schema["default"]||[]},register:function(){if(this._super(),this.rows)for(var a=0;a=this.schema.items.length?this.schema.additionalItems===!0?{}:this.schema.additionalItems?e({},this.schema.additionalItems):void 0:e({},this.schema.items[a]):this.schema.items?e({},this.schema.items):{}},getItemInfo:function(a){var b=this.getItemSchema(a);this.item_info=this.item_info||{};var c=JSON.stringify(b);return"undefined"!=typeof this.item_info[c]?this.item_info[c]:(b=this.jsoneditor.expandRefs(b),this.item_info[c]={title:b.title||"item","default":b["default"],width:12,child_editors:b.properties||b.items},this.item_info[c])},getElementEditor:function(a){var b=this.getItemInfo(a),c=this.getItemSchema(a);c=this.jsoneditor.expandRefs(c),c.title=b.title+" "+(a+1);var d,e=this.jsoneditor.getEditorClass(c);this.tabs_holder?(d="tabs-top"===this.schema.format?this.theme.getTopTabContent():this.theme.getTabContent(),d.id=this.path+"."+a):d=b.child_editors?this.theme.getChildEditorHolder():this.theme.getIndentedPanel(),this.row_holder.appendChild(d);var f=this.jsoneditor.createEditor(e,{jsoneditor:this.jsoneditor,schema:c,container:d,path:this.path+"."+a,parent:this,required:!0});return f.preBuild(),f.build(),f.postBuild(),f.title_controls||(f.array_controls=this.theme.getButtonHolder(),d.appendChild(f.array_controls)),f},destroy:function(){this.empty(!0),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.row_holder&&this.row_holder.parentNode&&this.row_holder.parentNode.removeChild(this.row_holder),this.controls&&this.controls.parentNode&&this.controls.parentNode.removeChild(this.controls),this.panel&&this.panel.parentNode&&this.panel.parentNode.removeChild(this.panel),this.rows=this.row_cache=this.title=this.description=this.row_holder=this.panel=this.controls=null,this._super()},empty:function(a){if(this.rows){var b=this;f(this.rows,function(c,d){a&&(d.tab&&d.tab.parentNode&&d.tab.parentNode.removeChild(d.tab),b.destroyRow(d,!0),b.row_cache[c]=null),b.rows[c]=null}),b.rows=[],a&&(b.row_cache=[])}},destroyRow:function(a,b){var c=a.container;b?(a.destroy(),c.parentNode&&c.parentNode.removeChild(c),a.tab&&a.tab.parentNode&&a.tab.parentNode.removeChild(a.tab)):(a.tab&&(a.tab.style.display="none"),c.style.display="none",a.unregister())},getMax:function(){return Array.isArray(this.schema.items)&&this.schema.additionalItems===!1?Math.min(this.schema.items.length,this.schema.maxItems||1/0):this.schema.maxItems||1/0},refreshTabs:function(a){var b=this;f(this.rows,function(c,d){d.tab&&(a?d.tab_text.textContent=d.getHeaderText():d.tab===b.active_tab?b.theme.markTabActive(d):b.theme.markTabInactive(d))})},setValue:function(a,b){a=a||[],Array.isArray(a)||(a=[a]);var c=JSON.stringify(a);if(c!==this.serialized){if(this.schema.minItems)for(;a.lengththis.getMax()&&(a=a.slice(0,this.getMax()));var d=this;f(a,function(a,c){d.rows[a]?d.rows[a].setValue(c,b):d.row_cache[a]?(d.rows[a]=d.row_cache[a],d.rows[a].setValue(c,b),d.rows[a].container.style.display="",d.rows[a].tab&&(d.rows[a].tab.style.display=""),d.rows[a].register()):d.addRow(c,b)});for(var e=a.length;e=this.rows.length;f(this.rows,function(a,c){c.movedown_button&&(a===b.rows.length-1?c.movedown_button.style.display="none":c.movedown_button.style.display=""),c.delete_button&&(d?c.delete_button.style.display="none":c.delete_button.style.display=""),b.value[a]=c.getValue()});var e=!1;this.value.length?1===this.value.length?(this.remove_all_rows_button.style.display="none",d||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",e=!0)):(d||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",e=!0),d||this.hide_delete_all_rows_buttons?this.remove_all_rows_button.style.display="none":(this.remove_all_rows_button.style.display="",e=!0)):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"),this.getMax()&&this.getMax()<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",e=!0),!this.collapsed&&e?this.controls.style.display="inline-block":this.controls.style.display="none"}},addRow:function(a,b){var c=this,d=this.rows.length;c.rows[d]=this.getElementEditor(d),c.row_cache[d]=c.rows[d],c.tabs_holder&&(c.rows[d].tab_text=document.createElement("span"),c.rows[d].tab_text.textContent=c.rows[d].getHeaderText(),"tabs-top"===c.schema.format?(c.rows[d].tab=c.theme.getTopTab(c.rows[d].tab_text,this.getValidId(c.rows[d].path)),c.theme.addTopTab(c.tabs_holder,c.rows[d].tab)):(c.rows[d].tab=c.theme.getTab(c.rows[d].tab_text,this.getValidId(c.rows[d].path)),c.theme.addTab(c.tabs_holder,c.rows[d].tab)),c.rows[d].tab.addEventListener("click",function(a){c.active_tab=c.rows[d].tab,c.refreshTabs(),a.preventDefault(),a.stopPropagation()}));var e=c.rows[d].title_controls||c.rows[d].array_controls;c.hide_delete_buttons||(c.rows[d].delete_button=this.getButton(c.getItemTitle(),"delete",this.translate("button_delete_row_title",[c.getItemTitle()])),c.rows[d].delete_button.classList.add("delete","json-editor-btntype-delete"),c.rows[d].delete_button.setAttribute("data-i",d),c.rows[d].delete_button.addEventListener("click",function(a){if(a.preventDefault(),a.stopPropagation(),!c.askConfirmation())return!1;var b=1*this.getAttribute("data-i"),d=c.getValue(),e=[],g=null;f(d,function(a,c){a!==b&&e.push(c)}),c.empty(!0),c.setValue(e),c.rows[b]?g=c.rows[b].tab:c.rows[b-1]&&(g=c.rows[b-1].tab),g&&(c.active_tab=g,c.refreshTabs()),c.onChange(!0),c.jsoneditor.trigger("deleteRow")}),e&&e.appendChild(c.rows[d].delete_button)),c.show_copy_button&&(c.rows[d].copy_button=this.getButton(c.getItemTitle(),"copy","Copy "+c.getItemTitle()),c.rows[d].copy_button.classList.add("copy","json-editor-btntype-copy"),c.rows[d].copy_button.setAttribute("data-i",d),c.rows[d].copy_button.addEventListener("click",function(a){var b=c.getValue();a.preventDefault(),a.stopPropagation();var d=1*this.getAttribute("data-i");f(b,function(a,c){a===d&&b.push(c)}),c.setValue(b),c.refreshValue(!0),c.onChange(!0)}),e.appendChild(c.rows[d].copy_button)),d&&!c.hide_move_buttons&&(c.rows[d].moveup_button=this.getButton("","moveup",this.translate("button_move_up_title")),c.rows[d].moveup_button.classList.add("moveup","json-editor-btntype-move"),c.rows[d].moveup_button.setAttribute("data-i",d),c.rows[d].moveup_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var b=1*this.getAttribute("data-i");if(!(b<=0)){var d=c.getValue(),e=d[b-1];d[b-1]=d[b],d[b]=e,c.setValue(d),c.active_tab=c.rows[b-1].tab,c.refreshTabs(),c.onChange(!0),c.jsoneditor.trigger("moveRow")}}),e&&e.appendChild(c.rows[d].moveup_button)),c.hide_move_buttons||(c.rows[d].movedown_button=this.getButton("","movedown",this.translate("button_move_down_title")),c.rows[d].movedown_button.classList.add("movedown","json-editor-btntype-move"),c.rows[d].movedown_button.setAttribute("data-i",d),c.rows[d].movedown_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var b=1*this.getAttribute("data-i"),d=c.getValue();if(!(b>=d.length-1)){var e=d[b+1];d[b+1]=d[b],d[b]=e,c.setValue(d),c.active_tab=c.rows[b+1].tab,c.refreshTabs(),c.onChange(!0),c.jsoneditor.trigger("moveRow")}}),e&&e.appendChild(c.rows[d].movedown_button)),a&&c.rows[d].setValue(a,b),c.refreshTabs()},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse",this.translate("button_collapse")),this.toggle_button.classList.add("json-editor-btntype-toggle"),this.title_controls.appendChild(this.toggle_button);var b=a.row_holder.style.display,c=a.controls.style.display;this.toggle_button.addEventListener("click",function(d){d.preventDefault(),d.stopPropagation(),a.collapsed?(a.collapsed=!1,a.panel&&(a.panel.style.display=""),a.row_holder.style.display=b,a.tabs_holder&&(a.tabs_holder.style.display=""),a.controls.style.display=c,a.setButtonText(this,"","collapse",a.translate("button_collapse"))):(a.collapsed=!0,a.row_holder.style.display="none",a.tabs_holder&&(a.tabs_holder.style.display="none"),a.controls.style.display="none",a.panel&&(a.panel.style.display="none"),a.setButtonText(this,"","expand",a.translate("button_expand")))}),this.options.collapsed&&g(this.toggle_button,"click"),this.schema.options&&"undefined"!=typeof this.schema.options.disable_collapse?this.schema.options.disable_collapse&&(this.toggle_button.style.display="none"):this.jsoneditor.options.disable_collapse&&(this.toggle_button.style.display="none"),this.add_row_button=this.getButton(this.getItemTitle(),"add",this.translate("button_add_row_title",[this.getItemTitle()])),this.add_row_button.classList.add("json-editor-btntype-add"),this.add_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation();var c=a.rows.length;a.row_cache[c]?(a.rows[c]=a.row_cache[c],a.rows[c].setValue(a.rows[c].getDefault(),!0),a.rows[c].container.style.display="",a.rows[c].tab&&(a.rows[c].tab.style.display=""),a.rows[c].register()):a.addRow(),a.active_tab=a.rows[c].tab,a.refreshTabs(),a.refreshValue(),a.onChange(!0),a.jsoneditor.trigger("addRow")}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton(this.translate("button_delete_last",[this.getItemTitle()]),"delete",this.translate("button_delete_last_title",[this.getItemTitle()])),this.delete_last_row_button.classList.add("json-editor-btntype-deletelast"),this.delete_last_row_button.addEventListener("click",function(b){if(b.preventDefault(),b.stopPropagation(),!a.askConfirmation())return!1;var c=a.getValue(),d=null;c.pop(),a.empty(!0),a.setValue(c),a.rows[a.rows.length-1]&&(d=a.rows[a.rows.length-1].tab),d&&(a.active_tab=d,a.refreshTabs()),a.onChange(!0),a.jsoneditor.trigger("deleteRow")}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton(this.translate("button_delete_all"),"delete",this.translate("button_delete_all_title")),this.remove_all_rows_button.classList.add("json-editor-btntype-deleteall"),this.remove_all_rows_button.addEventListener("click",function(b){return b.preventDefault(),b.stopPropagation(),!!a.askConfirmation()&&(a.empty(!0),a.setValue([]),a.onChange(!0),void a.jsoneditor.trigger("deleteAllRows"))}),a.controls.appendChild(this.remove_all_rows_button),a.tabs&&(this.add_row_button.style.width="100%",this.add_row_button.style.textAlign="left",this.add_row_button.style.marginBottom="3px",this.delete_last_row_button.style.width="100%",this.delete_last_row_button.style.textAlign="left",this.delete_last_row_button.style.marginBottom="3px",this.remove_all_rows_button.style.width="100%",this.remove_all_rows_button.style.textAlign="left",this.remove_all_rows_button.style.marginBottom="3px")},showValidationErrors:function(a){var b=this,c=[],d=[];if(f(a,function(a,e){e.path===b.path?c.push(e):d.push(e)}),this.error_holder)if(c.length){this.error_holder.innerHTML="",this.error_holder.style.display="",f(c,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none";f(this.rows,function(a,b){b.showValidationErrors(d)})}}),h.defaults.editors.table=h.defaults.editors.array.extend({register:function(){if(this._super(),this.rows)for(var a=0;athis.schema.maxItems&&(a=a.slice(0,this.schema.maxItems));var c=JSON.stringify(a);if(c!==this.serialized){var d=!1,e=this;f(a,function(a,b){e.rows[a]?e.rows[a].setValue(b):(e.addRow(b),d=!0)});for(var g=a.length;g=this.rows.length,c=!1;f(this.rows,function(d,e){e.movedown_button&&(d===a.rows.length-1?e.movedown_button.style.display="none":(c=!0,e.movedown_button.style.display="")),e.delete_button&&(b?e.delete_button.style.display="none":(c=!0,e.delete_button.style.display="")),e.moveup_button&&(c=!0)}),f(this.rows,function(a,b){c?b.controls_cell.style.display="":b.controls_cell.style.display="none"}),c?this.controls_header_cell.style.display="":this.controls_header_cell.style.display="none";var d=!1;this.value.length?1===this.value.length?(this.table.style.display="",this.remove_all_rows_button.style.display="none",b||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",d=!0)):(this.table.style.display="",b||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",d=!0),b||this.hide_delete_all_rows_buttons?this.remove_all_rows_button.style.display="none":(this.remove_all_rows_button.style.display="",d=!0)):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none",this.table.style.display="none"),this.schema.maxItems&&this.schema.maxItems<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",d=!0),d?this.controls.style.display="":this.controls.style.display="none"},refreshValue:function(){var a=this;this.value=[],f(this.rows,function(b,c){a.value[b]=c.getValue()}),this.serialized=JSON.stringify(this.value)},addRow:function(a){var b=this,c=this.rows.length;b.rows[c]=this.getElementEditor(c);var d=b.rows[c].table_controls;this.hide_delete_buttons||(b.rows[c].delete_button=this.getButton("","delete",this.translate("button_delete_row_title_short")),b.rows[c].delete_button.classList.add("delete","json-editor-btntype-delete"),b.rows[c].delete_button.setAttribute("data-i",c),b.rows[c].delete_button.addEventListener("click",function(a){if(a.preventDefault(),a.stopPropagation(),!b.askConfirmation())return!1;var c=1*this.getAttribute("data-i"),d=b.getValue(),e=[];f(d,function(a,b){a!==c&&e.push(b)}),b.setValue(e),b.onChange(!0)}),d.appendChild(b.rows[c].delete_button)),c&&!this.hide_move_buttons&&(b.rows[c].moveup_button=this.getButton("","moveup",this.translate("button_move_up_title")),b.rows[c].moveup_button.classList.add("moveup","json-editor-btntype-move"),b.rows[c].moveup_button.setAttribute("data-i",c),b.rows[c].moveup_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i");if(!(c<=0)){var d=b.getValue(),e=d[c-1];d[c-1]=d[c],d[c]=e,b.setValue(d),b.onChange(!0)}}),d.appendChild(b.rows[c].moveup_button)),this.hide_move_buttons||(b.rows[c].movedown_button=this.getButton("","movedown",this.translate("button_move_down_title")),b.rows[c].movedown_button.classList.add("movedown","json-editor-btntype-move"),b.rows[c].movedown_button.setAttribute("data-i",c),b.rows[c].movedown_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i"),d=b.getValue();if(!(c>=d.length-1)){var e=d[c+1];d[c+1]=d[c],d[c]=e,b.setValue(d),b.onChange(!0)}}),d.appendChild(b.rows[c].movedown_button)),a&&b.rows[c].setValue(a)},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse",this.translate("button_collapse")),this.toggle_button.classList.add("json-editor-btntype-toggle"),this.title_controls&&(this.title_controls.appendChild(this.toggle_button),this.toggle_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.collapsed?(a.collapsed=!1,a.panel.style.display="",a.setButtonText(this,"","collapse",a.translate("button_collapse"))):(a.collapsed=!0,a.panel.style.display="none",a.setButtonText(this,"","expand",a.translate("button_expand")))}),this.options.collapsed&&g(this.toggle_button,"click"),this.schema.options&&"undefined"!=typeof this.schema.options.disable_collapse?this.schema.options.disable_collapse&&(this.toggle_button.style.display="none"):this.jsoneditor.options.disable_collapse&&(this.toggle_button.style.display="none")),this.add_row_button=this.getButton(this.getItemTitle(),"add",this.translate("button_add_row_title",[this.getItemTitle()])),this.add_row_button.classList.add("json-editor-btntype-add"),this.add_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.addRow(),a.refreshValue(),a.refreshRowButtons(),a.onChange(!0)}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton(this.translate("button_delete_last",[this.getItemTitle()]),"delete",this.translate("button_delete_last_title",[this.getItemTitle()])),this.delete_last_row_button.classList.add("json-editor-btntype-deletelast"),this.delete_last_row_button.addEventListener("click",function(b){if(b.preventDefault(),b.stopPropagation(),!a.askConfirmation())return!1;var c=a.getValue();c.pop(),a.setValue(c),a.onChange(!0)}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton(this.translate("button_delete_all"),"delete",this.translate("button_delete_all_title")), +this.remove_all_rows_button.classList.add("json-editor-btntype-deleteall"),this.remove_all_rows_button.addEventListener("click",function(b){return b.preventDefault(),b.stopPropagation(),!!a.askConfirmation()&&(a.setValue([]),void a.onChange(!0))}),a.controls.appendChild(this.remove_all_rows_button)}}),h.defaults.editors.multiple=h.AbstractEditor.extend({register:function(){if(this.editors){for(var a=0;anull";if("object"==typeof a){var c="";return f(a,function(d,e){var f=b.getHTML(e);Array.isArray(a)||(f="
"+d+": "+f+"
"),c+="
  • "+f+"
  • "}),c=Array.isArray(a)?"
      "+c+"
    ":"
      "+c+"
    "}return"boolean"==typeof a?a?"true":"false":"string"==typeof a?a.replace(/&/g,"&").replace(//g,">"):a},setValue:function(a){this.value!==a&&(this.value=a,this.refreshValue(),this.onChange())},destroy:function(){this.display_area&&this.display_area.parentNode&&this.display_area.parentNode.removeChild(this.display_area),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.switcher&&this.switcher.parentNode&&this.switcher.parentNode.removeChild(this.switcher),this._super()}}),h.defaults.editors.select=h.AbstractEditor.extend({setValue:function(a,b){a=this.typecast(a||"");var c=a;this.enum_values.indexOf(c)<0&&(c=this.enum_values[0]),this.value!==c&&(b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.input.value=this.enum_options[this.enum_values.indexOf(c)],this.select2&&(this.select2v4?this.select2.val(this.input.value).trigger("change"):this.select2.select2("val",this.input.value)),this.value=c,this.onChange(),this.change())},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){if(!this.enum_options)return 3;for(var a=this.getTitle().length,b=0;b2||this.enum_options.length&&this.enumSource)){var a=e({},h.plugins.select2);this.schema.options&&this.schema.options.select2_options&&(a=e(a,this.schema.options.select2_options)),this.select2=window.jQuery(this.input).select2(a),this.select2v4=this.select2.select2.hasOwnProperty("amd");var b=this;this.select2.on("select2-blur",function(){b.select2v4?b.input.value=b.select2.val():b.input.value=b.select2.select2("val"),b.onInputChange()}),this.select2.on("change",function(){b.select2v4?b.input.value=b.select2.val():b.input.value=b.select2.select2("val"),b.onInputChange()})}else this.select2=null},postBuild:function(){this._super(),this.theme.afterInputReady(this.input),this.setupSelect2()},onWatchedFieldChange:function(){var a,b;if(this.enumSource){a=this.getWatchedFieldValues();for(var c=[],d=[],e=0;e=2||this.enum_options.length&&this.enumSource)){var c=e({},h.plugins.selectize);this.schema.options&&this.schema.options.selectize_options&&(c=e(c,this.schema.options.selectize_options)),this.selectize=window.jQuery(this.input).selectize(e(c,{create:c.create===b||c.create,onChange:function(){a.onInputChange()}}))}else this.selectize=null},postBuild:function(){this._super(),this.theme.afterInputReady(this.input),this.setupSelectize()},onWatchedFieldChange:function(){var a,c;if(this.enumSource){a=this.getWatchedFieldValues();for(var d=[],e=[],f=0;f1&&a.schema.options&&a.schema.options.multiple&&1==a.schema.options.multiple&&a.parent&&"object"==a.parent.schema.type&&a.parent.parent&&"array"==a.parent.parent.schema.type){a.arrayEditor=a.jsoneditor.getEditor(a.parent.parent.path),a.value=a.arrayEditor.getValue(),a.total=this.files.length,a.current_item_index=parseInt(a.parent.key),a.count=a.current_item_index;for(var c=0;cType: "+a+", Size: "+Math.floor((this.value.length-this.value.split(",")[0].length-1)/1.33333)+" bytes","image"===a.substr(0,5)){this.preview.innerHTML+="
    ";var b=document.createElement("img");b.style.maxWidth="100%",b.style.maxHeight="100px",b.src=this.value,this.preview.appendChild(b)}}else this.preview.innerHTML="Invalid data URI"}},enable:function(){this.always_disabled||(this.uploader&&(this.uploader.disabled=!1),this._super())},disable:function(a){a&&(this.always_disabled=!0),this.uploader&&(this.uploader.disabled=!0),this._super()},setValue:function(a){this.value!==a&&(this.value=a,this.input.value=this.value,this.refreshPreview(),this.onChange())},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),h.defaults.editors.upload=h.AbstractEditor.extend({getNumColumns:function(){return 4},build:function(){var a=this;if(this.title=this.header=this.label=this.theme.getFormInputLabel(this.getTitle()),this.input=this.theme.getFormInputField("hidden"),this.container.appendChild(this.input),!this.schema.readOnly&&!this.schema.readonly){if(!this.jsoneditor.options.upload)throw"Upload handler required for upload editor";this.uploader=this.theme.getFormInputField("file"),this.uploader.addEventListener("change",function(b){if(b.preventDefault(),b.stopPropagation(),this.files&&this.files.length){var c=new FileReader;c.onload=function(b){a.preview_value=b.target.result,a.refreshPreview(),a.onChange(!0),c=null},c.readAsDataURL(this.files[0])}})}var b=this.schema.description;b||(b=""),this.preview=this.theme.getFormInputDescription(b),this.container.appendChild(this.preview),this.control=this.theme.getFormControl(this.label,this.uploader||this.input,this.preview),this.container.appendChild(this.control),window.requestAnimationFrame(function(){if(a.value){var b=document.createElement("img");b.style.maxWidth="100%",b.style.maxHeight="100px",b.onload=function(c){a.preview.appendChild(b)},b.onerror=function(a){console.error("upload error",a)},b.src=a.container.querySelector("a").href}})},refreshPreview:function(){if(this.last_preview!==this.preview_value&&(this.last_preview=this.preview_value,this.preview.innerHTML="",this.preview_value)){var a=this,b=this.preview_value.match(/^data:([^;,]+)[;,]/);b&&(b=b[1]),b||(b="unknown");var c=this.uploader.files[0];if(this.preview.innerHTML="Type: "+b+", Size: "+c.size+" bytes","image"===b.substr(0,5)){this.preview.innerHTML+="
    ";var d=document.createElement("img");d.style.maxWidth="100%",d.style.maxHeight="100px",d.src=this.preview_value,this.preview.appendChild(d)}this.preview.innerHTML+="
    ";var e=this.getButton("Upload","upload","Upload");this.preview.appendChild(e),e.addEventListener("click",function(b){b.preventDefault(),e.setAttribute("disabled","disabled"),a.theme.removeInputError(a.uploader),a.theme.getProgressBar&&(a.progressBar=a.theme.getProgressBar(),a.preview.appendChild(a.progressBar)),a.jsoneditor.options.upload(a.path,c,{success:function(b){a.setValue(b),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange(), +a.progressBar&&a.preview.removeChild(a.progressBar),e.removeAttribute("disabled")},failure:function(b){a.theme.addInputError(a.uploader,b),a.progressBar&&a.preview.removeChild(a.progressBar),e.removeAttribute("disabled")},updateProgress:function(b){a.progressBar&&(b?a.theme.updateProgressBar(a.progressBar,b):a.theme.updateProgressBarUnknown(a.progressBar))}})}),(this.jsoneditor.options.auto_upload||this.schema.options.auto_upload)&&(e.dispatchEvent(new MouseEvent("click")),this.preview.removeChild(e))}},enable:function(){this.always_disabled||(this.uploader&&(this.uploader.disabled=!1),this._super())},disable:function(a){a&&(this.always_disabled=!0),this.uploader&&(this.uploader.disabled=!0),this._super()},setValue:function(a){this.value!==a&&(this.value=a,this.input.value=this.value,this.onChange())},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),h.defaults.editors.checkbox=h.AbstractEditor.extend({setValue:function(a,b){this.value=!!a,this.input.checked=this.value,this.onChange()},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){return Math.min(12,Math.max(this.getTitle().length/7,2))},build:function(){var a=this;this.options.compact||(this.label=this.header=this.theme.getCheckboxLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.options.infoText&&(this.infoButton=this.theme.getInfoButton(this.options.infoText)),this.options.compact&&this.container.classList.add("compact"),this.input=this.theme.getCheckbox(),this.control=this.theme.getFormControl(this.label,this.input,this.description,this.infoButton),(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,this.input.disabled=!0),this.input.addEventListener("change",function(b){b.preventDefault(),b.stopPropagation(),a.value=this.checked,a.onChange(!0)}),this.container.appendChild(this.control)},enable:function(){this.always_disabled||(this.input.disabled=!1,this._super())},disable:function(a){a&&(this.always_disabled=!0),this.input.disabled=!0,this._super()},destroy:function(){this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this._super()},showValidationErrors:function(a){var b=this;if("always"===this.jsoneditor.options.show_errors);else if(!this.is_dirty&&this.previous_error_setting===this.jsoneditor.options.show_errors)return;this.previous_error_setting=this.jsoneditor.options.show_errors;var c=[];f(a,function(a,d){d.path===b.path&&c.push(d.message)}),this.input.controlgroup=this.control,c.length?this.theme.addInputError(this.input,c.join(". ")+"."):this.theme.removeInputError(this.input)}}),h.defaults.editors.arraySelectize=h.AbstractEditor.extend({build:function(){this.title=this.theme.getFormInputLabel(this.getTitle()),this.title_controls=this.theme.getHeaderButtonHolder(),this.title.appendChild(this.title_controls),this.error_holder=document.createElement("div"),this.schema.description&&(this.description=this.theme.getDescription(this.schema.description)),this.input=document.createElement("select"),this.input.setAttribute("multiple","multiple");var a=this.theme.getFormControl(this.title,this.input,this.description);this.container.appendChild(a),this.container.appendChild(this.error_holder),window.jQuery(this.input).selectize({delimiter:!1,createOnBlur:!0,create:!0})},postBuild:function(){var a=this;this.input.selectize.on("change",function(b){a.refreshValue(),a.onChange(!0)})},destroy:function(){this.empty(!0),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this._super()},empty:function(a){},setValue:function(a,b){var c=this;a=a||[],Array.isArray(a)||(a=[a]),this.input.selectize.clearOptions(),this.input.selectize.clear(!0),a.forEach(function(a){c.input.selectize.addOption({text:a,value:a})}),this.input.selectize.setValue(a),this.refreshValue(b)},refreshValue:function(a){this.value=this.input.selectize.getValue()},showValidationErrors:function(a){var b=this,c=[],d=[];if(f(a,function(a,e){e.path===b.path?c.push(e):d.push(e)}),this.error_holder)if(c.length){this.error_holder.innerHTML="",this.error_holder.style.display="",f(c,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none"}}),h.defaults.editors.starrating=h.defaults.editors.string.extend({build:function(){var a=this;this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.options.infoText&&(this.infoButton=this.theme.getInfoButton(this.options.infoText)),this.options.compact&&this.container.classList.add("compact"),this.ratingContainer=document.createElement("div"),this.ratingContainer.classList.add("starrating"),this.enum_values=this.schema["enum"],this.radioGroup=[];for(var b=function(b){b.preventDefault(),b.stopPropagation(),a.setValue(this.value),a.onChange(!0)},c=this.enum_values.length-1;c>-1;c--){var d=this.key+"-"+c,e=this.theme.getFormInputField("radio");e.name=this.formname+"[starrating]",e.value=this.enum_values[c],e.id=d,e.addEventListener("change",b,!1),this.radioGroup.push(e);var f=document.createElement("label");f.htmlFor=d,f.title=this.enum_values[c],this.options.displayValue&&f.classList.add("starrating-display-enabled"),this.ratingContainer.appendChild(e),this.ratingContainer.appendChild(f)}if(this.options.displayValue&&(this.displayRating=document.createElement("div"),this.displayRating.classList.add("starrating-display"),this.displayRating.innerText=this.enum_values[0],this.ratingContainer.appendChild(this.displayRating)),this.schema.readOnly||this.schema.readonly){this.always_disabled=!0;for(var g=0;c0){var d=new Date(1e3*a),e=d.getFullYear(),f=this.zeroPad(d.getMonth()+1),g=this.zeroPad(d.getDate()),h=this.zeroPad(d.getHours()),i=this.zeroPad(d.getMinutes()),j=this.zeroPad(d.getSeconds()),k=[e,f,g].join("-"),l=[h,i,j].join(":"),m=k+" "+l;"date"==this.schema.format?m=k:"time"==this.schema.format&&(m=l),this.input.value=m,this.flatpickr&&this.flatpickr.setDate(m)}},destroy:function(){this.flatpickr&&this.flatpickr.destroy(),this.flatpickr=null,this._super()},zeroPad:function(a){return("0"+a).slice(-2)}}),h.defaults.editors.signature=h.defaults.editors.string.extend({build:function(){var a=this;this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description));var b=this.formname.replace(/\W/g,"");if("function"==typeof SignaturePad){var c="json-editor-style-signature";document.getElementById(c);this.input=this.theme.getFormInputField("hidden"),this.container.appendChild(this.input);var d=document.createElement("div");d.classList.add("signature-container");var e=document.createElement("canvas");e.setAttribute("name",b),e.classList.add("signature"),d.appendChild(e),a.signaturePad=new window.SignaturePad(e,{onEnd:function(){a.signaturePad.isEmpty()?a.input.value="":a.input.value=a.signaturePad.toDataURL(),a.is_dirty=!0,a.refreshValue(),a.watch_listener(),a.jsoneditor.notifyWatchers(a.path),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}});var g=document.createElement("div"),h=document.createElement("button");h.classList.add("tiny","button"),h.innerHTML="Clear signature",g.appendChild(h),d.appendChild(g),this.options.compact&&this.container.setAttribute("class",this.container.getAttribute("class")+" compact"),(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,f(this.inputs,function(a,b){e.setAttribute("readOnly","readOnly"),b.disabled=!0})),h.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.signaturePad.clear(),a.signaturePad.strokeEnd()}),this.control=this.theme.getFormControl(this.label,d,this.description),this.container.appendChild(this.control),this.refreshValue(),e.width=d.offsetWidth,a.options&&a.options.canvas_height?e.height=a.options.canvas_height:e.height="300"}else{var i=document.createElement("p");i.innerHTML="Signature pad is not available, please include SignaturePad from https://github.com/szimek/signature_pad",this.container.appendChild(i)}},setValue:function(a){var b=this;if("function"==typeof SignaturePad){var c=(this.formname.replace(/\W/g,""),this.sanitize(a));if(this.value===c)return;return b.value=c,b.input.value=b.value,b.signaturePad.clear(),a&&""!=a&&b.signaturePad.fromDataURL(a),b.watch_listener(),b.jsoneditor.notifyWatchers(b.path),!1}},destroy:function(){var a=this;this.formname.replace(/\W/g,"");a.signaturePad.off(),delete a.signaturePad}});var i=function(){var a=document.documentElement;return a.matches?"matches":a.webkitMatchesSelector?"webkitMatchesSelector":a.mozMatchesSelector?"mozMatchesSelector":a.msMatchesSelector?"msMatchesSelector":a.oMatchesSelector?"oMatchesSelector":void 0}();return h.AbstractTheme=c.extend({getContainer:function(){return document.createElement("div")},getFloatRightLinkHolder:function(){var a=document.createElement("div");return a.style=a.style||{},a.style.cssFloat="right",a.style.marginLeft="10px",a},getModal:function(){var a=document.createElement("div");return a.style.backgroundColor="white",a.style.border="1px solid black",a.style.boxShadow="3px 3px black",a.style.position="absolute",a.style.zIndex="10",a.style.display="none",a},getGridContainer:function(){var a=document.createElement("div");return a},getGridRow:function(){var a=document.createElement("div");return a.classList.add("row"),a},getGridColumn:function(){var a=document.createElement("div");return a},setGridColumnSize:function(a,b){},getLink:function(a){var b=document.createElement("a");return b.setAttribute("href","#"),b.appendChild(document.createTextNode(a)),b},disableHeader:function(a){a.style.color="#ccc"},disableLabel:function(a){a.style.color="#ccc"},enableHeader:function(a){a.style.color=""},enableLabel:function(a){a.style.color=""},getInfoButton:function(a){var b=document.createElement("span");b.innerText="ⓘ",b.style.fontSize="16px",b.style.fontWeight="bold",b.style.padding=".25rem",b.style.position="relative",b.style.display="inline-block";var c=document.createElement("span");return c.style.fontSize="12px",b.style.fontWeight="normal",c.style["font-family"]="sans-serif",c.style.visibility="hidden",c.style["background-color"]="rgba(50, 50, 50, .75)",c.style.margin="0 .25rem",c.style.color="#FAFAFA",c.style.padding=".5rem 1rem",c.style["border-radius"]=".25rem",c.style.width="20rem",c.style.position="absolute",c.innerText=a,b.onmouseover=function(){c.style.visibility="visible"},b.onmouseleave=function(){c.style.visibility="hidden"},b.appendChild(c),b},getFormInputLabel:function(a){var b=document.createElement("label");return b.appendChild(document.createTextNode(a)),b},getCheckboxLabel:function(a){var b=this.getFormInputLabel(a);return b.style.fontWeight="normal",b},getHeader:function(a){var b=document.createElement("h3");return"string"==typeof a?b.textContent=a:b.appendChild(a),b},getCheckbox:function(){var a=this.getFormInputField("checkbox");return a.style.display="inline-block",a.style.width="auto",a},getMultiCheckboxHolder:function(a,b,c){var d=document.createElement("div");b&&(b.style.display="block",d.appendChild(b));for(var e in a)a.hasOwnProperty(e)&&(a[e].style.display="inline-block",a[e].style.marginRight="20px",d.appendChild(a[e]));return c&&d.appendChild(c),d},getSelectInput:function(a){var b=document.createElement("select");return a&&this.setSelectOptions(b,a),b},getSwitcher:function(a){var b=this.getSelectInput(a);return b.style.backgroundColor="transparent",b.style.display="inline-block",b.style.fontStyle="italic",b.style.fontWeight="normal",b.style.height="auto",b.style.marginBottom=0,b.style.marginLeft="5px",b.style.padding="0 0 0 3px",b.style.width="auto",b},getSwitcherOptions:function(a){return a.getElementsByTagName("option")},setSwitcherOptions:function(a,b,c){this.setSelectOptions(a,b,c)},setSelectOptions:function(a,b,c){c=c||[],a.innerHTML="";for(var d=0;d
    ",c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML="
    ",c},applyStyles:function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a.style[c]=b[c])},closest:function(a,b){for(;a&&a!==document;){if(!a[i])return!1;if(a[i](b))return a;a=a.parentNode}return!1},insertBasicTopTab:function(a,b){b.firstChild.insertBefore(a,b.firstChild.firstChild)},getTab:function(a,b){var c=document.createElement("div");return c.appendChild(a),c.id=b,c.style=c.style||{},this.applyStyles(c,{border:"1px solid #ccc",borderWidth:"1px 0 1px 1px",textAlign:"center",lineHeight:"30px",borderRadius:"5px",borderBottomRightRadius:0,borderTopRightRadius:0,fontWeight:"bold",cursor:"pointer"}),c},getTopTab:function(a,b){var c=document.createElement("div");return c.id=b,c.appendChild(a),c.style=c.style||{},this.applyStyles(c,{"float":"left",border:"1px solid #ccc",borderWidth:"1px 1px 0px 1px",textAlign:"center",lineHeight:"30px",borderRadius:"5px",paddingLeft:"5px",paddingRight:"5px",borderBottomRightRadius:0,borderBottomLeftRadius:0,fontWeight:"bold",cursor:"pointer"}),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){return this.getIndentedPanel()},getTopTabContent:function(){return this.getTopIndentedPanel()},markTabActive:function(a){this.applyStyles(a.tab,{opacity:1,background:"white"}),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){this.applyStyles(a.tab,{opacity:.5,background:""}),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)},getBlockLink:function(){var a=document.createElement("a");return a.style.display="block",a},getBlockLinkHolder:function(){var a=document.createElement("div");return a},getLinksHolder:function(){var a=document.createElement("div");return a},createMediaLink:function(a,b,c){a.appendChild(b),c.style.width="100%",a.appendChild(c)},createImageLink:function(a,b,c){a.appendChild(b),b.appendChild(c)},getFirstTab:function(a){return a.firstChild.firstChild},getInputGroup:function(a,c){return b}}),h.defaults.themes.bootstrap2=h.AbstractTheme.extend({getRangeInput:function(a,b,c){return this._super(a,b,c)},getGridContainer:function(){var a=document.createElement("div");return a.classList.add("container-fluid"),a},getGridRow:function(){var a=document.createElement("div");return a.classList.add("row-fluid"),a},getFormInputLabel:function(a){var b=this._super(a);return b.style.display="inline-block",b.style.fontWeight="bold",b},setGridColumnSize:function(a,b){a.classList.add("span"+b)},getSelectInput:function(a){var b=this._super(a);return b.style.width="auto",b.style.maxWidth="98%",b},getFormInputField:function(a){var b=this._super(a);return b.style.width="98%",b},afterInputReady:function(a){if(!a.controlgroup&&(a.controlgroup=this.closest(a,".control-group"),a.controls=this.closest(a,".controls"),this.closest(a,".compact")&&(a.controlgroup.className=a.controlgroup.className.replace(/control-group/g,"").replace(/[ ]{2,}/g," "),a.controls.className=a.controlgroup.className.replace(/controls/g,"").replace(/[ ]{2,}/g," "),a.style.marginBottom=0),this.queuedInputErrorText)){var b=this.queuedInputErrorText;delete this.queuedInputErrorText,this.addInputError(a,b)}},getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("well","well-small"),a.style.paddingBottom=0,a},getInfoButton:function(a){var b=document.createElement("span");b.classList.add("icon-info-sign","pull-right"),b.style.padding=".25rem",b.style.position="relative",b.style.display="inline-block";var c=document.createElement("span");return c.style["font-family"]="sans-serif",c.style.visibility="hidden",c.style["background-color"]="rgba(50, 50, 50, .75)",c.style.margin="0 .25rem",c.style.color="#FAFAFA",c.style.padding=".5rem 1rem",c.style["border-radius"]=".25rem",c.style.width="25rem",c.style.transform="translateX(-27rem) translateY(-.5rem)",c.style.position="absolute",c.innerText=a,b.onmouseover=function(){c.style.visibility="visible"},b.onmouseleave=function(){c.style.visibility="hidden"},b.appendChild(c),b},getFormInputDescription:function(a){var b=document.createElement("p");return b.classList.add("help-inline"),b.textContent=a,b},getFormControl:function(a,b,c,d){var e=document.createElement("div");e.classList.add("control-group");var f=document.createElement("div");return f.classList.add("controls"),a&&"checkbox"===b.getAttribute("type")?(e.appendChild(f),a.classList.add("checkbox"),a.appendChild(b),f.appendChild(a),d&&f.appendChild(d),f.style.height="30px"):(a&&(a.classList.add("control-label"),e.appendChild(a)),d&&f.appendChild(d),f.appendChild(b),e.appendChild(f)),c&&f.appendChild(c),e},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a.style.marginLeft="10px",a},getButtonHolder:function(){var a=document.createElement("div");return a.classList.add("btn-group"),a},getButton:function(a,b,c){var d=this._super(a,b,c);return d.classList.add("btn","btn-default"),d},getTable:function(){var a=document.createElement("table");return a.classList.add("table","table-bordered"),a.style.width="auto",a.style.maxWidth="none",a},addInputError:function(a,b){return a.controlgroup?void(a.controlgroup&&a.controls&&(a.controlgroup.classList.add("error"),a.errmsg?a.errmsg.style.display="":(a.errmsg=document.createElement("p"),a.errmsg.classList.add("help-block","errormsg"),a.controls.appendChild(a.errmsg)),a.errmsg.textContent=b)):void(this.queuedInputErrorText=b)},removeInputError:function(a){a.controlgroup||delete this.queuedInputErrorText,a.errmsg&&(a.errmsg.style.display="none",a.controlgroup.classList.remove("error"))},getTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("tabbable","tabs-left"),c.innerHTML="
    ",c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("tabbable","tabs-over"),c.innerHTML="
    ",c},getTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.add("active"):a.container.classList.add("active")},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.remove("active"):a.container.classList.remove("active")},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)},getProgressBar:function(){var a=document.createElement("div");a.classList.add("progress");var b=document.createElement("div");return b.classList.add("bar"),b.style.width="0%",a.appendChild(b),a},updateProgressBar:function(a,b){a&&(a.firstChild.style.width=b+"%")},updateProgressBarUnknown:function(a){a&&(a.classList.add("progress","progress-striped","active"),a.firstChild.style.width="100%")},getInputGroup:function(a,b){if(a){var c=document.createElement("div");c.classList.add("input-append"),c.appendChild(a);for(var d=0;d
    ",c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML="
    ",c},getTab:function(a,b){var c=document.createElement("li");c.setAttribute("role","presentation");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),d.setAttribute("aria-controls",b),d.setAttribute("role","tab"),d.setAttribute("data-toggle","tab"),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.setAttribute("role","presentation");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),d.setAttribute("aria-controls",b),d.setAttribute("role","tab"),d.setAttribute("data-toggle","tab"),c.appendChild(d),c},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.add("active"):a.container.classList.add("active")},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.remove("active"):a.container.classList.remove("active")},getProgressBar:function(){var a=0,b=100,c=0,d=document.createElement("div");d.classList.add("progress");var e=document.createElement("div");return e.classList.add("progress-bar"),e.setAttribute("role","progressbar"),e.setAttribute("aria-valuenow",c), +e.setAttribute("aria-valuemin",a),e.setAttribute("aria-valuenax",b),e.innerHTML=c+"%",d.appendChild(e),d},updateProgressBar:function(a,b){if(a){var c=a.firstChild,d=b+"%";c.setAttribute("aria-valuenow",b),c.style.width=d,c.innerHTML=d}},updateProgressBarUnknown:function(a){if(a){var b=a.firstChild;a.classList.add("progress","progress-striped","active"),b.removeAttribute("aria-valuenow"),b.style.width="100%",b.innerHTML=""}},getInputGroup:function(a,b){if(a){var c=document.createElement("div");c.classList.add("input-group"),c.appendChild(a);var d=document.createElement("div");d.classList.add("input-group-btn"),c.appendChild(d);for(var e=0;e
    ",b.classList.add("row"),b},addTab:function(a,b){a.children[0].children[0].appendChild(b)},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML="
    ",c},getTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.classList.add("nav-link"),d.setAttribute("style","padding:10px;"),d.setAttribute("href","#"+b),d.setAttribute("data-toggle","tab"),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.classList.add("nav-link"),d.setAttribute("href","#"+b),d.setAttribute("data-toggle","tab"),d.appendChild(a),c.appendChild(d),c},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},markTabActive:function(a){a.tab.firstChild.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.add("active"):a.container.classList.add("active")},markTabInactive:function(a){a.tab.firstChild.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.remove("active"):a.container.classList.remove("active")},getProgressBar:function(){var a=0,b=100,c=0,d=document.createElement("div");d.classList.add("progress");var e=document.createElement("div");return e.classList.add("progress-bar"),e.setAttribute("role","progressbar"),e.setAttribute("aria-valuenow",c),e.setAttribute("aria-valuemin",a),e.setAttribute("aria-valuenax",b),e.innerHTML=c+"%",d.appendChild(e),d},updateProgressBar:function(a,b){if(a){var c=a.firstChild,d=b+"%";c.setAttribute("aria-valuenow",b),c.style.width=d,c.innerHTML=d}},updateProgressBarUnknown:function(a){if(a){var b=a.firstChild;a.classList.add("progress","progress-striped","active"),b.removeAttribute("aria-valuenow"),b.style.width="100%",b.innerHTML=""}},getInputGroup:function(a,b){if(a){var c=document.createElement("div");c.classList.add("input-group"),c.appendChild(a);var d=document.createElement("div");d.classList.add("input-group-prepend"),c.appendChild(d);for(var e=0;e'),a.errmsg=a.parentNode.getElementsByClassName("error")[0]),void(a.errmsg.textContent=b)):void(this.queuedInputErrorText=b)},removeInputError:function(a){a.group||delete this.queuedInputErrorText,a.errmsg&&(a.group.classList.remove("error"),a.errmsg.style.display="none")},getProgressBar:function(){var a=document.createElement("div");a.classList.add("progress");var b=document.createElement("span");return b.classList.add("meter"),b.style.width="0%",a.appendChild(b),a},updateProgressBar:function(a,b){a&&(a.firstChild.style.width=b+"%")},updateProgressBarUnknown:function(a){a&&(a.firstChild.style.width="100%")},getInputGroup:function(a,c){if(!a)return b;var d=document.createElement("div");d.classList.add("input-group"),a.classList.add("input-group-field"),d.appendChild(a);for(var e=0;e
    ',c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("row"),c.innerHTML='
    ',c},setGridColumnSize:function(a,b){var c=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"];a.classList.add("columns",c[b])},getTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("content","active"),a.style.paddingLeft="5px",a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("content","active"),a.style.paddingLeft="5px",a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)}}),h.defaults.themes.foundation4=h.defaults.themes.foundation.extend({getHeaderButtonHolder:function(){var a=this._super();return a.style.fontSize=".6em",a},setGridColumnSize:function(a,b){a.classList.add("columns","large-"+b)},getFormInputDescription:function(a){var b=this._super(a);return b.style.fontSize=".8rem",b},getFormInputLabel:function(a){var b=this._super(a);return b.style.fontWeight="bold",b}}),h.defaults.themes.foundation5=h.defaults.themes.foundation.extend({getFormInputDescription:function(a){var b=this._super(a);return b.style.fontSize=".8rem",b},setGridColumnSize:function(a,b){a.classList.add("columns","medium-"+b)},getButton:function(a,b,c){var d=this._super(a,b,c);return d.className=d.className.replace(/\s*small/g,"")+" tiny",d},getTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML='
    ',c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("row"),c.innerHTML='
    ',c},getTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-content","active"),a.style.paddingLeft="5px",a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-content","active"),a.style.paddingLeft="5px",a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)}}),h.defaults.themes.foundation6=h.defaults.themes.foundation5.extend({getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("callout","secondary"),a.style="padding-left: 10px; margin-left: 10px;",a},getButtonHolder:function(){var a=document.createElement("div");return a.classList.add("button-group","tiny"),a.style.marginBottom=0,a},getFormInputLabel:function(a){var b=this._super(a);return b.style.display="block",b},getFormControl:function(a,b,c,d){var e=document.createElement("div");return e.classList.add("form-control"),a&&e.appendChild(a),"checkbox"===b.type?a.insertBefore(b,a.firstChild):a?(d&&a.appendChild(d),a.appendChild(b)):(d&&e.appendChild(d),e.appendChild(b)),c&&a.appendChild(c),e},addInputError:function(a,b){if(a.group){if(a.group.classList.add("error"),a.errmsg)a.errmsg.style.display="",a.className="";else{var c=document.createElement("span");c.classList.add("form-error","is-visible"),a.group.getElementsByTagName("label")[0].appendChild(c),a.classList.add("is-invalid-input"),a.errmsg=c}a.errmsg.textContent=b}},removeInputError:function(a){a.errmsg&&(a.classList.remove("is-invalid-input"),a.errmsg.parentNode&&a.errmsg.parentNode.removeChild(a.errmsg))},getTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("grid-x"),c.innerHTML='
      ',c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("grid-y"),c.innerHTML='
        ',c},insertBasicTopTab:function(a,b){b.firstChild.firstChild.insertBefore(a,b.firstChild.firstChild.firstChild)},getTab:function(a,b){var c=document.createElement("li");c.classList.add("tabs-title");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.classList.add("tabs-title");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1].firstChild},getTopTabContentHolder:function(a){return a.firstChild.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tabs-panel"),a.style.paddingLeft="5px",a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tabs-panel"),a.style.paddingLeft="5px",a},markTabActive:function(a){a.tab.classList.add("is-active"),a.tab.firstChild.setAttribute("aria-selected","true"),"undefined"!=typeof a.rowPane?(a.rowPane.classList.add("is-active"),a.rowPane.setAttribute("aria-selected","true")):(a.container.classList.add("is-active"),a.container.setAttribute("aria-selected","true"))},markTabInactive:function(a){a.tab.classList.remove("is-active"),a.tab.firstChild.removeAttribute("aria-selected"),"undefined"!=typeof a.rowPane?(a.rowPane.classList.remove("is-active"),a.rowPane.removeAttribute("aria-selected")):(a.container.classList.remove("is-active"),a.container.removeAttribute("aria-selected"))},addTab:function(a,b){a.children[0].firstChild.appendChild(b)},addTopTab:function(a,b){a.firstChild.children[0].appendChild(b)},getFirstTab:function(a){return a.firstChild.firstChild.firstChild}}),h.defaults.themes.html=h.AbstractTheme.extend({getFormInputLabel:function(a){var b=this._super(a);return b.style.display="block",b.style.marginBottom="3px",b.style.fontWeight="bold",b},getFormInputDescription:function(a){var b=this._super(a);return b.style.fontSize=".8em",b.style.margin=0,b.style.display="inline-block",b.style.fontStyle="italic",b},getIndentedPanel:function(){var a=this._super();return a.style.border="1px solid #ddd",a.style.padding="5px",a.style.margin="10px",a.style.borderRadius="3px",a},getTopIndentedPanel:function(){return this.getIndentedPanel()},getChildEditorHolder:function(){var a=this._super();return a.style.marginBottom="8px",a},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a.style.display="inline-block",a.style.marginLeft="10px",a.style.fontSize=".8em",a.style.verticalAlign="middle",a},getTable:function(){var a=this._super();return a.style.borderBottom="1px solid #ccc",a.style.marginBottom="5px",a},addInputError:function(a,b){if(a.style.borderColor="red",a.errmsg)a.errmsg.style.display="block";else{var c=this.closest(a,".form-control");a.errmsg=document.createElement("div"),a.errmsg.setAttribute("class","errmsg"),a.errmsg.style=a.errmsg.style||{},a.errmsg.style.color="red",c.appendChild(a.errmsg)}a.errmsg.innerHTML="",a.errmsg.appendChild(document.createTextNode(b))},removeInputError:function(a){a.style.borderColor="",a.errmsg&&(a.errmsg.style.display="none")},getProgressBar:function(){var a=100,b=0,c=document.createElement("progress");return c.setAttribute("max",a),c.setAttribute("value",b),c},updateProgressBar:function(a,b){a&&a.setAttribute("value",b)},updateProgressBarUnknown:function(a){a&&a.removeAttribute("value")}}),h.defaults.themes.jqueryui=h.AbstractTheme.extend({getTable:function(){var a=this._super();return a.setAttribute("cellpadding",5),a.setAttribute("cellspacing",0),a},getTableHeaderCell:function(a){var b=this._super(a);return b.classList.add("ui-state-active"),b.style.fontWeight="bold",b},getTableCell:function(){var a=this._super();return a.classList.add("ui-widget-content"),a},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a.style.marginLeft="10px",a.style.fontSize=".6em",a.style.display="inline-block",a},getFormInputDescription:function(a){var b=this.getDescription(a);return b.style.marginLeft="10px",b.style.display="inline-block",b},getFormControl:function(a,b,c,d){var e=this._super(a,b,c,d);return"checkbox"===b.type?(e.style.lineHeight="25px",e.style.padding="3px 0"):e.style.padding="4px 0 8px 0",e},getDescription:function(a){var b=document.createElement("span");return b.style.fontSize=".8em",b.style.fontStyle="italic",b.textContent=a,b},getButtonHolder:function(){var a=document.createElement("div");return a.classList.add("ui-buttonset"),a.style.fontSize=".7em",a},getFormInputLabel:function(a){var b=document.createElement("label");return b.style.fontWeight="bold",b.style.display="block",b.textContent=a,b},getButton:function(a,b,c){var d=document.createElement("button");d.classList.add("ui-button","ui-widget","ui-state-default","ui-corner-all"),b&&!a?(d.classList.add("ui-button-icon-only"),b.classList.add("ui-button-icon-primary","ui-icon-primary"),d.appendChild(b)):b?(d.classList.add("ui-button-text-icon-primary"),b.classList.add("ui-button-icon-primary","ui-icon-primary"),d.appendChild(b)):d.classList.add("ui-button-text-only");var e=document.createElement("span");return e.classList.add("ui-button-text"),e.textContent=a||c||".",d.appendChild(e),d.setAttribute("title",c),d},setButtonText:function(a,b,c,d){a.innerHTML="",a.classList.add("ui-button","ui-widget","ui-state-default","ui-corner-all"),c&&!b?(a.classList.add("ui-button-icon-only"),c.classList.add("ui-button-icon-primary","ui-icon-primary"),a.appendChild(c)):c?(a.classList.add("ui-button-text-icon-primary"),c.classList.add("ui-button-icon-primary","ui-icon-primary"),a.appendChild(c)):a.classList.add("ui-button-text-only");var e=document.createElement("span");e.classList.add("ui-button-text"),e.textContent=b||d||".",a.appendChild(e),a.setAttribute("title",d)},getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("ui-widget-content","ui-corner-all"),a.style.padding="1em 1.4em",a.style.marginBottom="20px",a},afterInputReady:function(a){if(!a.controls&&(a.controls=this.closest(a,".form-control"),this.queuedInputErrorText)){var b=this.queuedInputErrorText;delete this.queuedInputErrorText,this.addInputError(a,b)}},addInputError:function(a,b){return a.controls?(a.errmsg?a.errmsg.style.display="":(a.errmsg=document.createElement("div"),a.errmsg.classList.add("ui-state-error"),a.controls.appendChild(a.errmsg)),void(a.errmsg.textContent=b)):void(this.queuedInputErrorText=b)},removeInputError:function(a){a.controls||delete this.queuedInputErrorText,a.errmsg&&(a.errmsg.style.display="none")},markTabActive:function(a){a.tab.classList.remove("ui-widget-header"),a.tab.classList.add("ui-state-active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){a.tab.classList.add("ui-widget-header"),a.tab.classList.remove("ui-state-active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"}}),h.defaults.themes.barebones=h.AbstractTheme.extend({getFormInputLabel:function(a){var b=this._super(a);return b},getFormInputDescription:function(a){var b=this._super(a);return b},getIndentedPanel:function(){var a=this._super();return a},getChildEditorHolder:function(){var a=this._super();return a},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a},getTable:function(){var a=this._super();return a},addInputError:function(a,b){if(a.errmsg)a.errmsg.style.display="block";else{var c=this.closest(a,".form-control");a.errmsg=document.createElement("div"),a.errmsg.setAttribute("class","errmsg"),c.appendChild(a.errmsg)}a.errmsg.innerHTML="",a.errmsg.appendChild(document.createTextNode(b))},removeInputError:function(a){a.style.borderColor="",a.errmsg&&(a.errmsg.style.display="none")},getProgressBar:function(){var a=100,b=0,c=document.createElement("progress");return c.setAttribute("max",a),c.setAttribute("value",b),c},updateProgressBar:function(a,b){a&&a.setAttribute("value",b)},updateProgressBarUnknown:function(a){a&&a.removeAttribute("value")}}),h.defaults.themes.materialize=h.AbstractTheme.extend({setGridColumnSize:function(a,b){a.classList.add("col"),a.classList.add("s"+b)},getHeaderButtonHolder:function(){return this.getButtonHolder()},getButtonHolder:function(){return document.createElement("span")},getButton:function(a,b,c){a&&(b.classList.add("left"),b.style.marginRight="5px");var d=this._super(a,b,c);return d.classList.add("waves-effect","waves-light","btn"),d.style.fontSize="0.75rem",d.style.height="24px",d.style.lineHeight="24px",d.style.marginLeft="5px",d.style.padding="0 0.5rem",d},getFormControl:function(a,b,c,d){var e,f=b.type;if(f&&"checkbox"===f){if(e=document.createElement("p"),a){var g=document.createElement("span");g.innerHTML=a.innerHTML,a.innerHTML="",a.setAttribute("for",b.id),e.appendChild(a),a.appendChild(b),a.appendChild(g)}else e.appendChild(b);return e}return e=this._super(a,b,c,d),f&&f.startsWith("select")||e.classList.add("input-field"),f&&"color"===f&&(b.style.height="3rem",b.style.width="100%",b.style.margin="5px 0 20px 0",b.style.padding="3px",a&&(a.style.transform="translateY(-14px) scale(0.8)",a.style["-webkit-transform"]="translateY(-14px) scale(0.8)",a.style["-webkit-transform-origin"]="0 0",a.style["transform-origin"]="0 0")),e},getDescription:function(a){var b=document.createElement("div");return b.classList.add("grey-text"),b.style.marginTop="-15px",b.innerHTML=a,b},getHeader:function(a){var b=document.createElement("h5");return"string"==typeof a?b.textContent=a:b.appendChild(a),b},getChildEditorHolder:function(){var a=document.createElement("div");return a.marginBottom="10px",a},getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("card-panel"),a},getTable:function(){var a=document.createElement("table");return a.classList.add("striped","bordered"),a.style.marginBottom="10px",a},getTableRow:function(){return document.createElement("tr")},getTableHead:function(){return document.createElement("thead")},getTableBody:function(){return document.createElement("tbody")},getTableHeaderCell:function(a){var b=document.createElement("th");return b.textContent=a,b},getTableCell:function(){var a=document.createElement("td");return a},getTabHolder:function(){var a=['
        ','
          ',"
        ","
        ",'
        ',"
        "].join("\n"),b=document.createElement("div");return b.classList.add("row","card-panel"),b.innerHTML=a,b},addTab:function(a,b){a.children[0].children[0].appendChild(b)},getTab:function(a){var b=document.createElement("li");return b.classList.add("tab"),b.style=b.style||{},this.applyStyles(b,{width:"100%",textAlign:"left",lineHeight:"24px",height:"24px",fontSize:"14px",cursor:"pointer"}),b.appendChild(a),b},markTabActive:function(a){a.style=a.style||{},this.applyStyles(a,{width:"100%",textAlign:"left",lineHeight:"24px",height:"24px",fontSize:"14px",cursor:"pointer",color:"rgba(238,110,115,1)",transition:"border-color .5s ease",borderRight:"3px solid #424242"})},markTabInactive:function(a){a.style=a.style||{},this.applyStyles(a,{width:"100%",textAlign:"left",lineHeight:"24px",height:"24px",fontSize:"14px",cursor:"pointer",color:"rgba(238,110,115,0.7)"})},getTabContentHolder:function(a){return a.children[1]},getTabContent:function(){return document.createElement("div")},addInputError:function(a,b){var c,d=a.parentNode;d&&(this.removeInputError(a),c=document.createElement("div"),c.classList.add("error-text","red-text"),c.textContent=b,d.appendChild(c))},removeInputError:function(a){var b,c=a.parentElement;if(c){b=c.getElementsByClassName("error-text");for(var d=0;d1){var g;c=function(b){for(g=b,a=0;a=0){if(a.items["enum"])return"multiselect";if(h.plugins.selectize.enable&&"string"===a.items.type)return"arraySelectize"}}),h.defaults.resolvers.unshift(function(a){if(a.oneOf||a.anyOf)return"multiple"}),h.defaults.resolvers.unshift(function(a){if(["string","integer"].indexOf(a.type)!==-1&&["date","time","datetime-local"].indexOf(a.format)!==-1)return"datetime"}),h.defaults.resolvers.unshift(function(a){if("string"===a.type&&"starrating"===a.format)return"starrating"}),function(){if(window.jQuery||window.Zepto){var a=window.jQuery||window.Zepto;a.jsoneditor=h.defaults,a.fn.jsoneditor=function(a){var b=this,c=this.data("jsoneditor");if("value"===a){if(!c)throw"Must initialize jsoneditor before getting/setting the value";if(!(arguments.length>1))return c.getValue();c.setValue(arguments[1])}else{if("validate"===a){if(!c)throw"Must initialize jsoneditor before validating";return arguments.length>1?c.validate(arguments[1]):c.validate()}"destroy"===a?c&&(c.destroy(),this.data("jsoneditor",null)):(c&&c.destroy(),c=new h(this.get(0),a),this.data("jsoneditor",c),c.on("change",function(){b.trigger("change")}),c.on("ready",function(){b.trigger("ready")}))}return this}}}(),h}); +//# sourceMappingURL=jsoneditor.min.js.map +)====="; diff --git a/src/net/web/js_sensesp.h b/src/net/web/js_sensesp.h new file mode 100644 index 000000000..2adce8de3 --- /dev/null +++ b/src/net/web/js_sensesp.h @@ -0,0 +1,4 @@ +#include +const char PAGE_js_sensesp[] PROGMEM = R"=====( +function ajax(method,url,data,contentType){return new Promise(function(resolve,reject){var request=new XMLHttpRequest;request.open(method,url,!0),request.onload=function(){200===request.status?resolve(request.response):reject(Error(request.statusText))},request.onerror=function(){reject(Error("Network Error"))},contentType&&request.setRequestHeader("Content-Type",contentType),request.send(data)})}class TreeList{constructor(main,pathList){this.main=main,this.main.appendChild(document.createElement("div")),this.root=document.createElement("ul"),this.root.id="tree",this.main.appendChild(this.root);for(var i=0;i0;){var sectionName=parts.shift();section=this.findNode(section,sectionName)}this.addEntry(section,nodeName,fullPath)}var toggler=document.getElementsByClassName("caret");for(i=0;i{var json=JSON.parse(response),config=json.config,schema=json.schema;if(0==Object.keys(schema).length)return alert(`No schema available for ${config_path}`),void showConfigTree();schema.title||(schema.title=`Configuration for ${config_path}`),main.innerHTML="\n
        \n
        \n
        \n
        \n
        \n \n \n \n
        \n
        \n ",globalEditor=new JSONEditor(document.getElementById("editor_holder"),{schema:schema,startval:config,no_additional_properties:!0,disable_collapse:!0,disable_properties:!0,disable_edit_json:!0,show_opt_in:!0}),document.getElementById("submit").addEventListener("click",function(){saveConfig(config_path,globalEditor.getValue())}),document.getElementById("cancel").addEventListener("click",function(){showConfigTree()}),globalEditor.on("change",function(){var errors=globalEditor.validate(),indicator=document.getElementById("valid_indicator");errors.length?(indicator.className="label alert",indicator.textContent="not valid"):(indicator.className="label success",indicator.textContent="valid")})}).catch(err=>{alert(`Error retrieving configuration ${config_path}: ${err.message}`),showConfigTree()})}function saveConfig(config_path,values){ajax("PUT","/config"+config_path,JSON.stringify(values),"application/json").then(response=>{showConfigTree()}).catch(err=>{alert(`Error saving configuration ${config_path}: ${err.message}`),showConfigTree()})}function showConfigTree(){var main=getEmptyMountDiv();ajax("GET","/config").then(response=>{var configList=JSON.parse(response).keys;return configList.sort(),configList}).then(configList=>{new TreeList(main,configList)}).catch(err=>{alert("Error: "+err.statusText)})}Element.prototype.empty=function(){for(var child=this.lastElementChild;child;)this.removeChild(child),child=this.lastElementChild}; +)====="; diff --git a/src/net/web/setup.h b/src/net/web/setup.h new file mode 100644 index 000000000..d9e6e646a --- /dev/null +++ b/src/net/web/setup.h @@ -0,0 +1,61 @@ +#include +const char PAGE_setup[] PROGMEM = R"=====( + + + Configure SensESP Sensor + + + + + + + + +

        SensESP Sensor

        +
        +
        + + + +)====="; diff --git a/src/net/ws_client.cpp b/src/net/ws_client.cpp index 754ac1e3c..3f41ed36f 100644 --- a/src/net/ws_client.cpp +++ b/src/net/ws_client.cpp @@ -335,6 +335,20 @@ JsonObject& WSClient::get_configuration(JsonBuffer& buf) { return root; } + +String WSClient::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "sk_host": { "title": "SignalK Host", "type": "string" }, + "sk_port": { "title": "SignalK host port", "type": "integer" }, + "client_id": { "title": "Client id", "type": "string" }, + "polling_href": { "title": "Server authorization polling href", "type": "string" } + } + })"; +} + + bool WSClient::set_configuration(const JsonObject& config) { String expected[] = {"sk_host", "sk_port", "token"}; for (auto str : expected) { diff --git a/src/net/ws_client.h b/src/net/ws_client.h index e2021447f..53449adf2 100644 --- a/src/net/ws_client.h +++ b/src/net/ws_client.h @@ -31,6 +31,7 @@ class WSClient : public Configurable { virtual JsonObject& get_configuration(JsonBuffer& buf) override final; virtual bool set_configuration(const JsonObject& config) override final; + virtual String get_config_schema() override; private: String host = ""; diff --git a/src/transforms/difference.cpp b/src/transforms/difference.cpp index 80f7db684..8652acb87 100644 --- a/src/transforms/difference.cpp +++ b/src/transforms/difference.cpp @@ -38,6 +38,20 @@ JsonObject& Difference::get_configuration(JsonBuffer& buf) { return root; } + +String Difference::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "sk_path": { "title": "SignalK Path", "type": "string" }, + "k1": { "title": "Input #1 multiplier", "type": "number" }, + "k2": { "title": "Input #2 multiplier", "type": "number" }, + "value": { "title": "Last value", "type" : "number", "readOnly": true } + } + })"; +} + + bool Difference::set_configuration(const JsonObject& config) { String expected[] = {"k1", "k2", "sk_path"}; for (auto str : expected) { diff --git a/src/transforms/difference.h b/src/transforms/difference.h index da8b2134a..34493c2ed 100644 --- a/src/transforms/difference.h +++ b/src/transforms/difference.h @@ -12,6 +12,7 @@ class Difference : public SymmetricTransform { virtual String as_signalK() override final; virtual JsonObject& get_configuration(JsonBuffer& buf) override final; virtual bool set_configuration(const JsonObject& config) override final; + virtual String get_config_schema() override; private: uint8_t received = 0; diff --git a/src/transforms/frequency.cpp b/src/transforms/frequency.cpp index 64fee9fb3..9d7047747 100644 --- a/src/transforms/frequency.cpp +++ b/src/transforms/frequency.cpp @@ -38,6 +38,18 @@ JsonObject& Frequency::get_configuration(JsonBuffer& buf) { return root; } +String Frequency::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "sk_path": { "title": "SignalK Path", "type": "string" }, + "k": { "title": "Multiplier", "type": "number" }, + "value": { "title": "Last value", "type" : "number", "readOnly": true } + } + })"; +} + + bool Frequency::set_configuration(const JsonObject& config) { String expected[] = {"k", "c", "sk_path"}; for (auto str : expected) { diff --git a/src/transforms/frequency.h b/src/transforms/frequency.h index eaf036da8..c7eeab338 100644 --- a/src/transforms/frequency.h +++ b/src/transforms/frequency.h @@ -14,6 +14,8 @@ class Frequency : public IntegerConsumer, public NumericTransform { virtual void enable() override final; virtual JsonObject& get_configuration(JsonBuffer& buf) override final; virtual bool set_configuration(const JsonObject& config) override final; + virtual String get_config_schema() override; + private: float k; int ticks = 0; diff --git a/src/transforms/gnss_position.cpp b/src/transforms/gnss_position.cpp index 77b3bdfb3..9c0c1357e 100644 --- a/src/transforms/gnss_position.cpp +++ b/src/transforms/gnss_position.cpp @@ -22,6 +22,17 @@ JsonObject& GNSSPosition::get_configuration(JsonBuffer& buf) { return root; } +String GNSSPosition::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "sk_path": { "title": "SignalK Path", "type": "string" } + } + })"; +} + + + bool GNSSPosition::set_configuration(const JsonObject& config) { if (!config.containsKey("sk_path")) { return false; diff --git a/src/transforms/gnss_position.h b/src/transforms/gnss_position.h index d403a6c55..3c8f4bd69 100644 --- a/src/transforms/gnss_position.h +++ b/src/transforms/gnss_position.h @@ -29,6 +29,7 @@ class GNSSPosition : public SymmetricTransform { virtual JsonObject& get_configuration(JsonBuffer& buf) override final; virtual bool set_configuration(const JsonObject& config) override final; + virtual String get_config_schema() override; }; diff --git a/src/transforms/integrator.cpp b/src/transforms/integrator.cpp index ab86e8bdc..0c16dc431 100644 --- a/src/transforms/integrator.cpp +++ b/src/transforms/integrator.cpp @@ -43,8 +43,21 @@ JsonObject& Integrator::get_configuration(JsonBuffer& buf) { return root; } + +String Integrator::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "sk_path": { "title": "SignalK Path", "type": "string" }, + "k": { "title": "Multiplier", "type": "number" }, + "value": { "title": "Current value", "type" : "number", "readOnly": false } + } + })"; +} + + bool Integrator::set_configuration(const JsonObject& config) { - String expected[] = {"k", "value", "sk_path"}; + String expected[] = {"k", "sk_path"}; for (auto str : expected) { if (!config.containsKey(str)) { return false; diff --git a/src/transforms/integrator.h b/src/transforms/integrator.h index adc6a7cd2..0d8770cbe 100644 --- a/src/transforms/integrator.h +++ b/src/transforms/integrator.h @@ -13,7 +13,8 @@ class Integrator : public SymmetricTransform { String as_signalK() override final; virtual JsonObject& get_configuration(JsonBuffer& buf) override final; virtual bool set_configuration(const JsonObject& config) override final; - + virtual String get_config_schema() override; + private: float k; }; diff --git a/src/transforms/interpolate.cpp b/src/transforms/interpolate.cpp index eed9442a9..abdc82e93 100644 --- a/src/transforms/interpolate.cpp +++ b/src/transforms/interpolate.cpp @@ -60,7 +60,7 @@ void Interpolate::set_input(float input, uint8_t inputChannel) { else { // Hit the end of the table with no match. output = 9999.9; - debugE("Could not find sample interval for input %0f", input); +// debugW("Could not find sample interval for input %0f", input); } notify(); @@ -93,6 +93,23 @@ JsonObject& Interpolate::get_configuration(JsonBuffer& buf) { } +String Interpolate::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "sk_path": { "title": "SignalK Path", "type": "string" }, + "samples": { "title": "Sample values", + "type": "array", + "items": { "title": "Sample", + "type": "object", + "properties": { + "input": { "type": "number" }, + "output": { "type": "number" } + }}} + } + })"; +} + bool Interpolate::set_configuration(const JsonObject& config) { String expected[] = { "sk_path", "samples" }; diff --git a/src/transforms/interpolate.h b/src/transforms/interpolate.h index 1789c4a7c..199158be3 100644 --- a/src/transforms/interpolate.h +++ b/src/transforms/interpolate.h @@ -38,7 +38,8 @@ class Interpolate : public SymmetricTransform { // For reading and writing the configuration of this transformation virtual JsonObject& get_configuration(JsonBuffer& buf) override; virtual bool set_configuration(const JsonObject& config) override; - + virtual String get_config_schema() override; + // For manually adding sample points void clearSamples(); void addSample(const Sample& newSample); diff --git a/src/transforms/linear.cpp b/src/transforms/linear.cpp index 1d4683d6b..6bb1214ac 100644 --- a/src/transforms/linear.cpp +++ b/src/transforms/linear.cpp @@ -34,6 +34,20 @@ JsonObject& Linear::get_configuration(JsonBuffer& buf) { return root; } + +String Linear::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "sk_path": { "title": "SignalK Path", "type": "string" }, + "k": { "title": "Multiplier", "type": "number" }, + "c": { "title": "Constant offset", "type": "number" }, + "value": { "title": "Last value", "type" : "number", "readOnly": true } + } + })"; +} + + bool Linear::set_configuration(const JsonObject& config) { String expected[] = {"k", "c", "sk_path"}; for (auto str : expected) { diff --git a/src/transforms/linear.h b/src/transforms/linear.h index c7e88a2c3..4ad2d1eb5 100644 --- a/src/transforms/linear.h +++ b/src/transforms/linear.h @@ -12,6 +12,8 @@ class Linear : public SymmetricTransform { virtual String as_signalK() override final; virtual JsonObject& get_configuration(JsonBuffer& buf) override final; virtual bool set_configuration(const JsonObject& config) override final; + virtual String get_config_schema() override; + private: float k; float c; diff --git a/src/transforms/moving_average.cpp b/src/transforms/moving_average.cpp index 7e778f9e3..236dd45fe 100644 --- a/src/transforms/moving_average.cpp +++ b/src/transforms/moving_average.cpp @@ -37,6 +37,18 @@ JsonObject& MovingAverage::get_configuration(JsonBuffer& buf) { return root; } +String MovingAverage::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "sk_path": { "title": "SignalK Path", "type": "string" }, + "n": { "title": "Number of samples in average", "type": "integer" } + "k": { "title": "Multiplier", "type": "number" } + } + })"; +} + + bool MovingAverage::set_configuration(const JsonObject& config) { String expected[] = {"k", "sk_path"}; for (auto str : expected) { diff --git a/src/transforms/moving_average.h b/src/transforms/moving_average.h index 3e6c548cc..61a257cc4 100644 --- a/src/transforms/moving_average.h +++ b/src/transforms/moving_average.h @@ -14,6 +14,7 @@ class MovingAverage : public SymmetricTransform { virtual String as_signalK() override final; virtual JsonObject& get_configuration(JsonBuffer& buf) override final; virtual bool set_configuration(const JsonObject& config) override final; + virtual String get_config_schema() override; private: std::vector buf; diff --git a/src/transforms/passthrough.h b/src/transforms/passthrough.h index 0e8a181e8..fd8d5728d 100644 --- a/src/transforms/passthrough.h +++ b/src/transforms/passthrough.h @@ -39,6 +39,17 @@ class Passthrough : public SymmetricTransform { return root; } + String get_config_schema() override { + return R"({ + "type": "object", + "properties": { + "sk_path": { "title": "SignalK Path", "type": "string" }, + "value": { "title": "Last value", "type" : "number", "readOnly": true } + } + })"; + } + + virtual bool set_configuration(const JsonObject& config) override { if (!config.containsKey("sk_path")) { return false; diff --git a/src/transforms/timestring.cpp b/src/transforms/timestring.cpp index 75ac1a037..5e99dae51 100644 --- a/src/transforms/timestring.cpp +++ b/src/transforms/timestring.cpp @@ -31,6 +31,16 @@ JsonObject& TimeString::get_configuration(JsonBuffer& buf) { return root; } +String TimeString::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "sk_path": { "title": "SignalK Path", "type": "string" }, + "value": { "title": "Last value", "type" : "string", "readOnly": true } + } + })"; +} + bool TimeString::set_configuration(const JsonObject& config) { String expected[] = {"sk_path"}; for (auto str : expected) { diff --git a/src/transforms/timestring.h b/src/transforms/timestring.h index 5c78becad..e678db34a 100644 --- a/src/transforms/timestring.h +++ b/src/transforms/timestring.h @@ -13,6 +13,7 @@ class TimeString : public ValueConsumer, public StringTransform { String as_signalK() override final; virtual JsonObject& get_configuration(JsonBuffer& buf) override final; virtual bool set_configuration(const JsonObject& config) override final; + virtual String get_config_schema() override; }; #endif diff --git a/src/transforms/voltagedividerR2.cpp b/src/transforms/voltagedividerR2.cpp index a7c47dee6..dbf35e96c 100644 --- a/src/transforms/voltagedividerR2.cpp +++ b/src/transforms/voltagedividerR2.cpp @@ -29,6 +29,18 @@ JsonObject& VoltageDividerR2::get_configuration(JsonBuffer& buf) { } +String VoltageDividerR2::get_config_schema() { + return R"({ + "type": "object", + "properties": { + "sk_path": { "title": "SignalK Path", "type": "string" }, + "Vin": { "title": "Voltage in", "type": "number" }, + "R1": { "title": "Resistance (ohms) of R1", "type": "number" } + } + })"; +} + + bool VoltageDividerR2::set_configuration(const JsonObject& config) { String expected[] = { "sk_path", "Vin", "R1" }; diff --git a/src/transforms/voltagedividerR2.h b/src/transforms/voltagedividerR2.h index e453a4719..87b47b38f 100644 --- a/src/transforms/voltagedividerR2.h +++ b/src/transforms/voltagedividerR2.h @@ -27,6 +27,7 @@ class VoltageDividerR2 : public SymmetricTransform { // For reading and writing the configuration of this transformation virtual JsonObject& get_configuration(JsonBuffer& buf) override; virtual bool set_configuration(const JsonObject& config) override; + virtual String get_config_schema() override; protected: float R1; diff --git a/web/README.md b/web/README.md new file mode 100644 index 000000000..3bcef82b5 --- /dev/null +++ b/web/README.md @@ -0,0 +1,41 @@ +# SensESP Mock Web Environment + +This directory is for development and testing of the HTML and Javascript code that is utilized in the +configuration UI of SensESP. + +# Setting up mock development environment + +If you have a need to make changes to the SensESP web UI, configure a web server on your machine +to point to the "docroot" directory in this web directory. You can then make web requests as normal +and test or modify the behavior of the Javascript without the need to communicate with an actual +sensor running SensESP. + +Once you are done, you can run the "webUI" build target to convert the required files to C header files +that can be used by the SensESP source code. + + +# Rebuilding for deployment + +Rebuilding the Javascript files requires the use of the NodeJS utility Terser. Install it using +the follownig command: + +`npm install terser -g` + + +To build a new version of the web UI, issue the following command in your PlatformIO terminal: + +`pio run -t webUI` + +For information on how this build target works, see the project file extra_script.py + +# Files used by WebUI + +The following files converted to header files for use by the SensESP web UI. See the +src/net/web directory for the results of this conversion. + +1. docroot/index.html +1. docroot/js/jsoneditor.min.js +1. docroot/js/sensesp.js +1. docroot/setup/index.html + +The other directories contain mock files that would be returned by the MCU to a browser making the request. diff --git a/web/docroot/config/gauge/curve.json b/web/docroot/config/gauge/curve.json new file mode 100644 index 000000000..7ee5e5b48 --- /dev/null +++ b/web/docroot/config/gauge/curve.json @@ -0,0 +1,19 @@ +{ +"config":{"sk_path":"","samples":[{"input":0,"output":418.9},{"input":5,"output":414.71},{"input":36,"output":388.71},{"input":56,"output":371.93},{"input":59,"output":366.48},{"input":81,"output":355.37},{"input":112,"output":344.26},{"input":240,"output":322.04},{"input":550,"output":255.37},{"input":10000,"output":237.6}]}, + +"schema":{ + "type": "object", + "properties": { + "sk_path": { "title": "SignalK Path", "type": "string" }, + "samples": { "title": "Sample values", + "type": "array", + "items": { "title": "Sample", + "type": "object", + "properties": { + "input": { "type": "number" }, + "output": { "type": "number" } + }}} + } +} + +} diff --git a/web/docroot/config/index.html b/web/docroot/config/index.html new file mode 100644 index 000000000..6ba70e51c --- /dev/null +++ b/web/docroot/config/index.html @@ -0,0 +1 @@ +{"keys":["/gauge/curve","/gauge/inputs","/system/networking","/system/sk"]} diff --git a/web/docroot/config/system/sk.json b/web/docroot/config/system/sk.json new file mode 100644 index 000000000..6be366f1b --- /dev/null +++ b/web/docroot/config/system/sk.json @@ -0,0 +1 @@ +{"config":{"sk_host":"","sk_port":80,"token":"no-token","client_id":"","polling_href":""},"schema":{}} \ No newline at end of file diff --git a/web/docroot/index.html b/web/docroot/index.html new file mode 100644 index 000000000..2c0d435e6 --- /dev/null +++ b/web/docroot/index.html @@ -0,0 +1,15 @@ + + +SensESP SignalK Sensor + + +

        SensESP SignalK Sensor

        +Your options: + + + diff --git a/web/docroot/js/jsoneditor.min.js b/web/docroot/js/jsoneditor.min.js new file mode 100644 index 000000000..3d8990507 --- /dev/null +++ b/web/docroot/js/jsoneditor.min.js @@ -0,0 +1,19 @@ +/** + * @name JSON Editor + * @description JSON Schema Based Editor + * This library is the continuation of jdorn's great work (see also https://github.com/jdorn/json-editor/issues/800) + * @version 1.3.5 + * @author Jeremy Dorn + * @see https://github.com/jdorn/json-editor/ + * @see https://github.com/json-editor/json-editor + * @license MIT + * @example see README.md and docs/ for requirements, examples and usage info + */ +!function(a,b){"use strict";var c=b(a);"object"==typeof module&&null!=module&&module.exports?module.exports=c:"function"==typeof define&&define.amd?define(function(){return c}):a.JSONEditor=c}("undefined"!=typeof window?window:this,function(a,b){var c;!function(){var a=!1,b=/xyz/.test(function(){window.postMessage("xyz")})?/\b_super\b/:/.*/;return c=function(){},c.extend=function d(c){function e(){!a&&this.init&&this.init.apply(this,arguments)}var f=this.prototype;a=!0;var g=new this;a=!1;for(var h in c)g[h]="function"==typeof c[h]&&"function"==typeof f[h]&&b.test(c[h])?function(a,b){return function(){var c=this._super;this._super=f[a];var d=b.apply(this,arguments);return this._super=c,d}}(h,c[h]):c[h];return e.prototype=g,e.prototype.constructor=e,e.extend=d,e},c}(),function(){function a(a,c){c=c||{bubbles:!1,cancelable:!1,detail:b};var d=document.createEvent("CustomEvent");return d.initCustomEvent(a,c.bubbles,c.cancelable,c.detail),d}a.prototype=window.Event.prototype,window.CustomEvent=a}(),function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c0&&a.length-1 in a){for(c=0;c=i&&!j&&(j=!0,b())},c,k)}},f.send()}}),i||b()},expandRefs:function(a){for(a=e({},a);a.$ref;){var b=this.refs_with_info[a.$ref];delete a.$ref;var c="";b.$ref.startsWith("#")&&(c=b.fetchUrl);var d=c+b.$ref;this.refs[d]||(d=c+decodeURIComponent(b.$ref)),a=this.extendSchemas(a,e({},this.refs[d]))}return a},expandSchema:function(a,b){var c,d=this,g=e({},a);if("object"==typeof a.type&&(Array.isArray(a.type)?f(a.type,function(b,c){"object"==typeof c&&(a.type[b]=d.expandSchema(c))}):a.type=d.expandSchema(a.type)),"object"==typeof a.disallow&&(Array.isArray(a.disallow)?f(a.disallow,function(b,c){"object"==typeof c&&(a.disallow[b]=d.expandSchema(c))}):a.disallow=d.expandSchema(a.disallow)),a.anyOf&&f(a.anyOf,function(b,c){a.anyOf[b]=d.expandSchema(c)}),a.dependencies&&f(a.dependencies,function(b,c){"object"!=typeof c||Array.isArray(c)||(a.dependencies[b]=d.expandSchema(c))}),a.not&&(a.not=this.expandSchema(a.not)),a.allOf){for(c=0;ca.minimum:c>=a.minimum,window.math?g=window.math[a.exclusiveMinimum?"larger":"largerEq"](window.math.bignumber(c),window.math.bignumber(a.minimum)):window.Decimal&&(g=new window.Decimal(c)[a.exclusiveMinimum?"gt":"gte"](new window.Decimal(a.minimum))),g||l.push({path:d,property:"minimum",message:this.translate(a.exclusiveMinimum?"error_minimum_excl":"error_minimum_incl",[a.minimum])}))}else if("string"==typeof c)a.maxLength&&(c+"").length>a.maxLength&&l.push({path:d,property:"maxLength",message:this.translate("error_maxLength",[a.maxLength])}),a.minLength&&(c+"").lengtha.maxItems&&l.push({path:d,property:"maxItems",message:this.translate("error_maxItems",[a.maxItems])}),a.minItems&&c.lengtha.maxProperties&&l.push({path:d,property:"maxProperties",message:this.translate("error_maxProperties",[a.maxProperties])})}if(a.minProperties){g=0;for(i in c)c.hasOwnProperty(i)&&g++;g0:this.dependenciesFulfilled=!g||0===g.length):this.dependenciesFulfilled=!1,this.dependenciesFulfilled!==h&&this.notify(),this.dependenciesFulfilled?d.style.display="block":d.style.display="none"}},setContainer:function(a){this.container=a,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 a=this;if(this.watched={},this.schema.vars&&(this.schema.watch=this.schema.vars),this.watched_values={},this.watch_listener=function(){a.refreshWatchedFieldValues()&&a.onWatchedFieldChange()},this.schema.hasOwnProperty("watch")){var b,c,d,e,f;for(var g in this.schema.watch)if(this.schema.watch.hasOwnProperty(g)){if(b=this.schema.watch[g],Array.isArray(b)){if(b.length<2)continue;c=[b[0]].concat(b[1].split("."))}else c=b.split("."),a.theme.closest(a.container,'[data-schemaid="'+c[0]+'"]')||c.unshift("#");if(d=c.shift(),"#"===d&&(d=a.jsoneditor.schema.id||"root"),e=a.theme.closest(a.container,'[data-schemaid="'+d+'"]'),!e)throw"Could not find ancestor node with id "+d;f=e.getAttribute("data-schemapath")+"."+c.join("."),a.jsoneditor.watch(f,a.watch_listener),a.watched[g]=f}}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 a=0;a=0){b=this.theme.getBlockLinkHolder(),c=this.theme.getBlockLink(),c.setAttribute("target","_blank");var j=document.createElement(e);j.setAttribute("controls","controls"),this.theme.createMediaLink(b,c,j),this.link_watchers.push(function(a){var b=f(a),d=g(a);c.setAttribute("href",b),c.textContent=d||b,j.setAttribute("src",b)})}else c=b=this.theme.getBlockLink(),b.setAttribute("target","_blank"),b.textContent=a.rel,this.link_watchers.push(function(a){var c=f(a),d=g(a);b.setAttribute("href",c),b.textContent=d||c});return h&&c&&(h===!0?c.setAttribute("download",""):this.link_watchers.push(function(a){c.setAttribute("download",h(a))})),a["class"]&&c.classList.add(a["class"]),b},refreshWatchedFieldValues:function(){if(this.watched_values){var a={},b=!1,c=this;if(this.watched){var d,e;for(var f in this.watched)this.watched.hasOwnProperty(f)&&(e=c.jsoneditor.getEditor(this.watched[f]),d=e?e.getValue():null,c.watched_values[f]!==d&&(b=!0),a[f]=d)}return a.self=this.getValue(),this.watched_values.self!==a.self&&(b=!0),this.watched_values=a,b}},getWatchedFieldValues:function(){return this.watched_values},updateHeaderText:function(){if(this.header)if(this.header.children.length){for(var a=0;a-1:!!this.jsoneditor.options.required_by_default},getDisplayText:function(a){var b=[],c={};f(a,function(a,b){b.title&&(c[b.title]=c[b.title]||0,c[b.title]++),b.description&&(c[b.description]=c[b.description]||0,c[b.description]++),b.format&&(c[b.format]=c[b.format]||0,c[b.format]++),b.type&&(c[b.type]=c[b.type]||0,c[b.type]++)}),f(a,function(a,d){var e;e="string"==typeof d?d:d.title&&c[d.title]<=1?d.title:d.format&&c[d.format]<=1?d.format:d.type&&c[d.type]<=1?d.type:d.description&&c[d.description]<=1?d.descripton:d.title?d.title:d.format?d.format:d.type?d.type:d.description?d.description:JSON.stringify(d).length<500?JSON.stringify(d):"type",b.push(e)});var d={};return f(b,function(a,e){d[e]=d[e]||0,d[e]++,c[e]>1&&(b[a]=e+" "+d[e])}),b},getValidId:function(a){return a=a===b?"":a.toString(),a.replace(/\s+/g,"-")},setInputAttributes:function(a){if(this.schema.options&&this.schema.options.inputAttributes){var b=this.schema.options.inputAttributes,c=["name","type"].concat(a);for(var d in b)b.hasOwnProperty(d)&&c.indexOf(d.toLowerCase())==-1&&this.input.setAttribute(d,b[d])}},getOption:function(a){try{throw"getOption is deprecated"}catch(b){window.console.error(b)}return this.options[a]},showValidationErrors:function(a){}}),h.defaults.editors["null"]=h.AbstractEditor.extend({getValue:function(){return this.dependenciesFulfilled?null:b},setValue:function(){this.onChange()},getNumColumns:function(){return 2}}),h.defaults.editors.string=h.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(a,b,c){if((!this.template||c)&&(null===a||"undefined"==typeof a?a="":"object"==typeof a?a=JSON.stringify(a):"string"!=typeof a&&(a=""+a), +a!==this.serialized)){var d=this.sanitize(a);if(this.input.value!==d){this.input.value=d,this.sceditor_instance?this.sceditor_instance.val(d):this.SimpleMDE?this.SimpleMDE.value(d):this.ace_editor&&(this.ace_editor.setValue(d),this.ace_editor.session.getSelection().clearSelection(),this.ace_editor.resize());var e=c||this.getValue()!==a;this.refreshValue(),b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.adjust_height&&this.adjust_height(this.input),this.onChange(e)}}},getNumColumns:function(){var a,b=Math.ceil(Math.max(this.getTitle().length,this.schema.maxLength||0,this.schema.minLength||0)/5);return a="textarea"===this.input_type?6:["text","email"].indexOf(this.input_type)>=0?4:2,Math.min(12,Math.max(b,a))},build:function(){var a=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.options.infoText&&(this.infoButton=this.theme.getInfoButton(this.options.infoText)),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 b=this.schema.minimum||0,c=this.schema.maximum||Math.max(100,b+1),d=1;this.schema.multipleOf&&(b%this.schema.multipleOf&&(b=Math.ceil(b/this.schema.multipleOf)*this.schema.multipleOf),c%this.schema.multipleOf&&(c=Math.floor(c/this.schema.multipleOf)*this.schema.multipleOf),d=this.schema.multipleOf),this.input=this.theme.getRangeInput(b,c,d)}else["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","sqlserver","stylus","svg","twig","vbscript","xml","yaml"].indexOf(this.format)>=0?(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);if("undefined"!=typeof this.schema.maxLength&&this.input.setAttribute("maxlength",this.schema.maxLength),"undefined"!=typeof this.schema.pattern?this.input.setAttribute("pattern",this.schema.pattern):"undefined"!=typeof this.schema.minLength&&this.input.setAttribute("pattern",".{"+this.schema.minLength+",}"),this.options.compact?this.container.classList.add("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.setAttribute("readonly","true")),this.setInputAttributes(["maxlength","pattern","readonly","min","max","step"]),this.input.addEventListener("change",function(b){if(b.preventDefault(),b.stopPropagation(),a.schema.template)return void(this.value=a.value);var c=this.value,d=a.sanitize(c);c!==d&&(this.value=d),a.is_dirty=!0,a.refreshValue(),a.onChange(!0)}),this.options.input_height&&(this.input.style.height=this.options.input_height),this.options.expand_height&&(this.adjust_height=function(a){if(a){var b,c=a.offsetHeight;if(a.offsetHeight100);)b++,c++,a.style.height=c+"px";else{for(b=0;a.offsetHeight>=a.scrollHeight+3&&!(b>100);)b++,c--,a.style.height=c+"px";a.style.height=c+1+"px"}}},this.input.addEventListener("keyup",function(b){a.adjust_height(this)}),this.input.addEventListener("change",function(b){a.adjust_height(this)}),this.adjust_height()),this.format&&this.input.setAttribute("data-schemaformat",this.format),this.control=this.theme.getFormControl(this.label,this.input,this.description,this.infoButton),"range"===this.format){var e=document.createElement("output");e.setAttribute("class","range-output"),this.control.appendChild(e),e.value=this.schema["default"],this.input.addEventListener("change",function(){e.value=a.input.value}),this.input.addEventListener("input",function(){e.value=a.input.value})}this.container.appendChild(this.control),window.requestAnimationFrame(function(){a.input.parentNode&&a.afterInputReady(),a.adjust_height&&a.adjust_height(a.input)}),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue()):this.refreshValue()},postBuild:function(){this._super(),window.Cleave&&this.schema.options&&"object"==typeof this.schema.options.cleave&&(this.cleave=new window.Cleave(this.input,this.schema.options.cleave))},enable:function(){this.always_disabled||(this.input.disabled=!1,this._super())},disable:function(a){a&&(this.always_disabled=!0),this.input.disabled=!0,this._super()},afterInputReady:function(){var a,b=this;if(this.source_code)if(this.options.wysiwyg&&["html","bbcode"].indexOf(this.input_type)>=0&&window.jQuery&&window.jQuery.fn&&window.jQuery.fn.sceditor)a=e({},{plugins:"html"===b.input_type?"xhtml":"bbcode",emoticonsEnabled:!1,width:"100%",height:300},h.plugins.sceditor,b.options.sceditor_options||{}),window.jQuery(b.input).sceditor(a),b.sceditor_instance=window.jQuery(b.input).sceditor("instance"),b.sceditor_instance.blur(function(){var a=window.jQuery("
        "+b.sceditor_instance.val()+"
        ");window.jQuery("#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf",a).remove(),b.input.value=a.html(),b.value=b.input.value,b.is_dirty=!0,b.onChange(!0)});else if("markdown"===this.input_type&&window.SimpleMDE)a=e({},h.plugins.SimpleMDE,{element:this.input}),this.SimpleMDE=new window.SimpleMDE(a),this.SimpleMDE.codemirror.on("change",function(){b.value=b.SimpleMDE.value(),b.is_dirty=!0,b.onChange(!0)});else if(window.ace){var c=this.input_type;"cpp"!==c&&"c++"!==c&&"c"!==c||(c="c_cpp"),this.ace_container=document.createElement("div"),this.ace_container.style.width="100%",this.ace_container.style.position="relative",this.ace_container.style.height="400px",this.input.parentNode.insertBefore(this.ace_container,this.input),this.input.style.display="none",this.ace_editor=window.ace.edit(this.ace_container);var d=this.schema.options&&this.schema.options.ace;d&&this.ace_editor.setOptions(d),this.ace_editor.setValue(this.getValue()),this.ace_editor.session.getSelection().clearSelection(),this.ace_editor.resize(),h.plugins.ace.theme&&this.ace_editor.setTheme("ace/theme/"+h.plugins.ace.theme),this.ace_editor.getSession().setMode("ace/mode/"+this.schema.format),this.ace_editor.on("change",function(){var a=b.ace_editor.getValue();b.input.value=a,b.refreshValue(),b.is_dirty=!0,b.onChange(!0)})}b.theme.afterInputReady(b.input)},refreshValue:function(){this.value=this.input.value,"string"!=typeof this.value&&(this.value=""),this.serialized=this.value},destroy:function(){this.sceditor_instance?this.sceditor_instance.destroy():this.SimpleMDE?(this.SimpleMDE.toTextArea(),this.SimpleMDE=null):this.ace_editor&&this.ace_editor.destroy(),this.cleave&&this.cleave.destroy(),this.template=null,this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this._super()},sanitize:function(a){return a},onWatchedFieldChange:function(){var a;this.template&&(a=this.getWatchedFieldValues(),this.setValue(this.template(a),!1,!0)),this._super()},showValidationErrors:function(a){var b=this;if("always"===this.jsoneditor.options.show_errors);else if(!this.is_dirty&&this.previous_error_setting===this.jsoneditor.options.show_errors)return;this.previous_error_setting=this.jsoneditor.options.show_errors;var c=[];f(a,function(a,d){d.path===b.path&&c.push(d.message)}),c.length?this.theme.addInputError(this.input,c.join(". ")+"."):this.theme.removeInputError(this.input)}}),h.defaults.editors.hidden=h.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(a,b,c){if((!this.template||c)&&(null===a||"undefined"==typeof a?a="":"object"==typeof a?a=JSON.stringify(a):"string"!=typeof a&&(a=""+a),a!==this.serialized)){var d=this.sanitize(a);if(this.input.value!==d){this.input.value=d;var e=c||this.getValue()!==a;this.refreshValue(),b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.adjust_height&&this.adjust_height(this.input),this.onChange(e)}}},getNumColumns:function(){return 2},enable:function(){this._super()},disable:function(){this._super()},refreshValue:function(){this.value=this.input.value,"string"!=typeof this.value&&(this.value=""),this.serialized=this.value},destroy:function(){this.template=null,this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this._super()},sanitize:function(a){return a},onWatchedFieldChange:function(){var a;this.template&&(a=this.getWatchedFieldValues(),this.setValue(this.template(a),!1,!0)),this._super()},build:function(){this.format=this.schema.format,!this.format&&this.options.default_format&&(this.format=this.options.default_format),this.options.format&&(this.format=this.options.format),this.input_type="hidden",this.input=this.theme.getFormInputField(this.input_type),this.format&&this.input.setAttribute("data-schemaformat",this.format),this.container.appendChild(this.input),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue()):this.refreshValue()}}),h.defaults.editors.number=h.defaults.editors.string.extend({build:function(){if(this._super(),"undefined"!=typeof this.schema.minimum){var a=this.schema.minimum;"undefined"!=typeof this.schema.exclusiveMinimum&&(a+=1),this.input.setAttribute("min",a)}if("undefined"!=typeof this.schema.maximum){var b=this.schema.maximum;"undefined"!=typeof this.schema.exclusiveMaximum&&(b-=1),this.input.setAttribute("max",b)}if("undefined"!=typeof this.schema.step){var c=this.schema.step||1;this.input.setAttribute("step",c)}this.setInputAttributes(["maxlength","pattern","readonly","min","max","step"])},sanitize:function(a){return(a+"").replace(/[^0-9\.\-eE]/g,"")},getNumColumns:function(){return 2},getValue:function(){return this.dependenciesFulfilled?""===this.value?b:1*this.value:b}}),h.defaults.editors.integer=h.defaults.editors.number.extend({sanitize:function(a){return a+="",a.replace(/[^0-9\-]/g,"")},getNumColumns:function(){return 2}}),h.defaults.editors.rating=h.defaults.editors.integer.extend({build:function(){var a,b=this;this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description));var c="json-editor-style-rating",d=document.getElementById(c);if(!d){var e=document.createElement("style");e.id=c,e.type="text/css",e.innerHTML=" .rating-container { display: inline-block; clear: both; } .rating { float:left; } /* :not(:checked) is a filter, so that browsers that don’t support :checked don’t follow these rules. Every browser that supports :checked also supports :not(), so it doesn’t make the test unnecessarily selective */ .rating:not(:checked) > input { position:absolute; top:-9999px; clip:rect(0,0,0,0); } .rating:not(:checked) > label { float:right; width:1em; padding:0 .1em; overflow:hidden; white-space:nowrap; cursor:pointer; color:#ddd; } .rating:not(:checked) > label:before { content: '★ '; } .rating > input:checked ~ label { color: #FFB200; } .rating:not([readOnly]):not(:checked) > label:hover, .rating:not([readOnly]):not(:checked) > label:hover ~ label { color: #FFDA00; } .rating:not([readOnly]) > input:checked + label:hover, .rating:not([readOnly]) > input:checked + label:hover ~ label, .rating:not([readOnly]) > input:checked ~ label:hover, .rating:not([readOnly]) > input:checked ~ label:hover ~ label, .rating:not([readOnly]) > label:hover ~ input:checked ~ label { color: #FF8C0D; } .rating:not([readOnly]) > label:active { position:relative; top:2px; left:2px; }",document.getElementsByTagName("head")[0].appendChild(e)}this.input=this.theme.getFormInputField("hidden"),this.container.appendChild(this.input);var g=document.createElement("div");g.classList.add("rating-container");var h=document.createElement("div");h.setAttribute("name",this.formname),h.classList.add("rating"),g.appendChild(h),this.options.compact&&this.container.setAttribute("class",this.container.getAttribute("class")+" compact");var i=this.schema.maximum?this.schema.maximum:5;for(this.schema.exclusiveMaximum&&i--,this.inputs=[],a=i;a>0;a--){var j=this.formname+a,k=this.theme.getFormInputField("radio");k.setAttribute("id",j),k.setAttribute("value",a),k.setAttribute("name",this.formname),h.appendChild(k),this.inputs.push(k);var l=document.createElement("label");l.setAttribute("for",j),l.appendChild(document.createTextNode(a+(1==a?" star":" stars"))),h.appendChild(l)}(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,f(this.inputs,function(a,b){h.setAttribute("readOnly","readOnly"),b.disabled=!0})),g.addEventListener("change",function(a){a.preventDefault(),a.stopPropagation(),b.input.value=a.srcElement.value,b.is_dirty=!0,b.refreshValue(),b.watch_listener(),b.jsoneditor.notifyWatchers(b.path),b.parent?b.parent.onChildEditorChange(b):b.jsoneditor.onChange()}),this.control=this.theme.getFormControl(this.label,g,this.description),this.container.appendChild(this.control),this.refreshValue()},setValue:function(a){var b=this.sanitize(a);if(this.value!==b){var c=this;f(this.inputs,function(a,d){if(d.value===b)return d.checked=!0,c.value=b,c.input.value=c.value,c.watch_listener(),c.jsoneditor.notifyWatchers(c.path),!1})}}}),h.defaults.editors.object=h.AbstractEditor.extend({getDefault:function(){return e({},this.schema["default"]||{})},getChildEditors:function(){return this.editors},register:function(){if(this._super(),this.editors)for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].register()},unregister:function(){if(this._super(),this.editors)for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].unregister()},getNumColumns:function(){return Math.max(Math.min(12,this.maxwidth),3)},enable:function(){if(!this.always_disabled&&(this.editjson_button&&(this.editjson_button.disabled=!1),this.addproperty_button&&(this.addproperty_button.disabled=!1),this._super(),this.editors))for(var a in this.editors)this.editors.hasOwnProperty(a)&&this.editors[a].enable()},disable:function(a){if(a&&(this.always_disabled=!0),this.editjson_button&&(this.editjson_button.disabled=!0),this.addproperty_button&&(this.addproperty_button.disabled=!0),this.hideEditJSON(),this._super(),this.editors)for(var b in this.editors)this.editors.hasOwnProperty(b)&&this.editors[b].disable(a)},layoutEditors:function(){var a,b,c=this;if(this.row_container){this.property_order=Object.keys(this.editors),this.property_order=this.property_order.sort(function(a,b){var d=c.editors[a].schema.propertyOrder,e=c.editors[b].schema.propertyOrder;return"number"!=typeof d&&(d=1e3),"number"!=typeof e&&(e=1e3),d-e});var d,e="categories"===this.format;if("grid"===this.format){var h=[];for(f(this.property_order,function(a,b){var d=c.editors[b];if(!d.property_removed){for(var e=!1,f=d.options.hidden?0:d.options.grid_columns||d.getNumColumns(),g=d.options.hidden?0:d.container.offsetHeight,i=0;ig)&&(e=i);e===!1&&(h.push({width:0,minh:999999,maxh:0,editors:[]}),e=h.length-1),h[e].editors.push({key:b,width:f,height:g}),h[e].width+=f,h[e].minh=Math.min(h[e].minh,g),h[e].maxh=Math.max(h[e].maxh,g)}}),a=0;ah[a].editors[i].width&&(i=b),h[a].editors[b].width*=12/h[a].width,h[a].editors[b].width=Math.floor(h[a].editors[b].width),j+=h[a].editors[b].width;j<12&&(h[a].editors[i].width+=12-j),h[a].width=12}if(this.layout===JSON.stringify(h))return!1;for(this.layout=JSON.stringify(h),d=document.createElement("div"),a=0;a0?p.firstChild.isObjOrArray&&(e.appendChild(n),p.insertBefore(e,p.firstChild),c.theme.insertBasicTopTab(d.tab,o),d.basicPane=e):(e.appendChild(n),p.appendChild(e),c.theme.addTopTab(o,d.tab),d.basicPane=e)),d.options.hidden?d.container.style.display="none":c.theme.setGridColumnSize(d.container,12),g.appendChild(d.container),d.rowPane=e}});this.tabPanesContainer.firstChild;)this.tabPanesContainer.removeChild(this.tabPanesContainer.firstChild);var q=this.tabs_holder.parentNode;q.removeChild(q.firstChild),q.appendChild(o),this.tabPanesContainer=p,this.tabs_holder=o;var r=this.theme.getFirstTab(this.tabs_holder);return void(r&&g(r,"click"))}f(this.property_order,function(a,b){var e=c.editors[b];if(!e.property_removed){var f=c.theme.getGridRow();d.appendChild(f),e.options.hidden?e.container.style.display="none":c.theme.setGridColumnSize(e.container,12),f.appendChild(e.container)}})}for(;this.row_container.firstChild;)this.row_container.removeChild(this.row_container.firstChild);this.row_container.appendChild(d)}},getPropertySchema:function(a){var b=this.schema.properties[a]||{};b=e({},b);var c=!!this.schema.properties[a];if(this.schema.patternProperties)for(var d in this.schema.patternProperties)if(this.schema.patternProperties.hasOwnProperty(d)){var f=new RegExp(d);f.test(a)&&(b.allOf=b.allOf||[],b.allOf.push(this.schema.patternProperties[d]),c=!0)}return!c&&this.schema.additionalProperties&&"object"==typeof this.schema.additionalProperties&&(b=e({},this.schema.additionalProperties)),b},preBuild:function(){this._super(),this.editors={},this.cached_editors={};var a=this;if(this.format=this.options.layout||this.options.object_layout||this.schema.format||this.jsoneditor.options.object_layout||"normal",this.schema.properties=this.schema.properties||{},this.minwidth=0,this.maxwidth=0,this.options.table_row)f(this.schema.properties,function(b,c){var d=a.jsoneditor.getEditorClass(c);a.editors[b]=a.jsoneditor.createEditor(d,{jsoneditor:a.jsoneditor,schema:c,path:a.path+"."+b,parent:a,compact:!0,required:!0}),a.editors[b].preBuild();var e=a.editors[b].options.hidden?0:a.editors[b].options.grid_columns||a.editors[b].getNumColumns();a.minwidth+=e,a.maxwidth+=e}),this.no_link_holder=!0;else{if(this.options.table)throw"Not supported yet";this.schema.defaultProperties||(this.jsoneditor.options.display_required_only||this.options.display_required_only?(this.schema.defaultProperties=[],f(this.schema.properties,function(b,c){a.isRequired({key:b,schema:c})&&a.schema.defaultProperties.push(b)})):a.schema.defaultProperties=Object.keys(a.schema.properties)),a.maxwidth+=1,f(this.schema.defaultProperties,function(b,c){a.addObjectProperty(c,!0),a.editors[c]&&(a.minwidth=Math.max(a.minwidth,a.editors[c].options.grid_columns||a.editors[c].getNumColumns()),a.maxwidth+=a.editors[c].options.grid_columns||a.editors[c].getNumColumns())})}this.property_order=Object.keys(this.editors),this.property_order=this.property_order.sort(function(b,c){var d=a.editors[b].schema.propertyOrder,e=a.editors[c].schema.propertyOrder;return"number"!=typeof d&&(d=1e3),"number"!=typeof e&&(e=1e3),d-e})},addTab:function(a){var b=this,c=b.rows[a].schema&&("object"===b.rows[a].schema.type||"array"===b.rows[a].schema.type);b.tabs_holder&&(b.rows[a].tab_text=document.createElement("span"),c?b.rows[a].tab_text.textContent=b.rows[a].getHeaderText():b.rows[a].tab_text.textContent="undefined"==typeof b.schema.basicCategoryTitle?"Basic":b.schema.basicCategoryTitle,b.rows[a].tab=b.theme.getTopTab(b.rows[a].tab_text,this.getValidId(b.rows[a].tab_text.textContent)),b.rows[a].tab.addEventListener("click",function(c){b.active_tab=b.rows[a].tab,b.refreshTabs(),c.preventDefault(),c.stopPropagation()}))},addRow:function(a,b,c){var d=this,e=this.rows.length,f="object"===a.schema.type||"array"===a.schema.type;d.rows[e]=a,d.rows[e].rowPane=c,f?(d.addTab(e),d.theme.addTopTab(b,d.rows[e].tab)):"undefined"==typeof d.basicTab?(d.addTab(e),d.basicTab=e,d.basicPane=c,d.theme.addTopTab(b,d.rows[e].tab)):(d.rows[e].tab=d.rows[d.basicTab].tab,d.rows[e].tab_text=d.rows[d.basicTab].tab_text,d.rows[e].rowPane=d.rows[d.basicTab].rowPane)},refreshTabs:function(a){var b=this,c="undefined"!=typeof b.basicTab,d=!1;f(this.rows,function(e,f){f.tab&&f.rowPane&&f.rowPane.parentNode&&(c&&f.tab==b.rows[b.basicTab].tab&&d||(a?f.tab_text.textContent=f.getHeaderText():(c&&f.tab==b.rows[b.basicTab].tab&&(d=!0),f.tab===b.active_tab?b.theme.markTabActive(f):b.theme.markTabInactive(f))))})},build:function(){var a=this,b="categories"===this.format;if(this.rows=[],this.active_tab=null,this.options.table_row)this.editor_holder=this.container,f(this.editors,function(b,c){var d=a.theme.getTableCell();a.editor_holder.appendChild(d),c.setContainer(d),c.build(),c.postBuild(),a.editors[b].options.hidden&&(d.style.display="none"),a.editors[b].options.input_width&&(d.style.width=a.editors[b].options.input_width)});else{if(this.options.table)throw"Not supported yet";this.header=document.createElement("span"),this.header.textContent=this.getTitle(),this.title=this.theme.getHeader(this.header),this.container.appendChild(this.title),this.container.style.position="relative",this.editjson_holder=this.theme.getModal(),this.editjson_textarea=this.theme.getTextareaInput(),this.editjson_textarea.style.height="170px",this.editjson_textarea.style.width="300px",this.editjson_textarea.style.display="block",this.editjson_save=this.getButton("Save","save","Save"),this.editjson_save.classList.add("json-editor-btntype-save"),this.editjson_save.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.saveJSON()}),this.editjson_copy=this.getButton("Copy","copy","Copy"),this.editjson_copy.classList.add("json-editor-btntype-copy"),this.editjson_copy.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.copyJSON()}),this.editjson_cancel=this.getButton("Cancel","cancel","Cancel"),this.editjson_cancel.classList.add("json-editor-btntype-cancel"),this.editjson_cancel.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.hideEditJSON()}),this.editjson_holder.appendChild(this.editjson_textarea),this.editjson_holder.appendChild(this.editjson_save),this.editjson_holder.appendChild(this.editjson_copy),this.editjson_holder.appendChild(this.editjson_cancel),this.addproperty_holder=this.theme.getModal(),this.addproperty_list=document.createElement("div"),this.addproperty_list.style.width="295px",this.addproperty_list.style.maxHeight="160px",this.addproperty_list.style.padding="5px 0",this.addproperty_list.style.overflowY="auto",this.addproperty_list.style.overflowX="hidden",this.addproperty_list.style.paddingLeft="5px",this.addproperty_list.setAttribute("class","property-selector"),this.addproperty_add=this.getButton("add","add","add"),this.addproperty_add.classList.add("json-editor-btntype-add"),this.addproperty_input=this.theme.getFormInputField("text"),this.addproperty_input.setAttribute("placeholder","Property name..."),this.addproperty_input.style.width="220px",this.addproperty_input.style.marginBottom="0",this.addproperty_input.style.display="inline-block",this.addproperty_add.addEventListener("click",function(b){if(b.preventDefault(),b.stopPropagation(),a.addproperty_input.value){if(a.editors[a.addproperty_input.value])return void window.alert("there is already a property with that name");a.addObjectProperty(a.addproperty_input.value),a.editors[a.addproperty_input.value]&&a.editors[a.addproperty_input.value].disable(),a.onChange(!0)}}),this.addproperty_holder.appendChild(this.addproperty_list),this.addproperty_holder.appendChild(this.addproperty_input),this.addproperty_holder.appendChild(this.addproperty_add);var c=document.createElement("div");c.style.clear="both",this.addproperty_holder.appendChild(c),document.addEventListener("click",function(a){!this.addproperty_holder.contains(a.target)&&this.adding_property&&(a.preventDefault(),a.stopPropagation(),this.toggleAddProperty())}.bind(this)),this.schema.description&&(this.description=this.theme.getDescription(this.schema.description),this.container.appendChild(this.description)),this.error_holder=document.createElement("div"),this.container.appendChild(this.error_holder),this.editor_holder=this.theme.getIndentedPanel(),this.container.appendChild(this.editor_holder),this.row_container=this.theme.getGridContainer(),b?(this.tabs_holder=this.theme.getTopTabHolder(this.getValidId(this.schema.title)),this.tabPanesContainer=this.theme.getTopTabContentHolder(this.tabs_holder),this.editor_holder.appendChild(this.tabs_holder)):(this.tabs_holder=this.theme.getTabHolder(this.getValidId(this.schema.title)),this.tabPanesContainer=this.theme.getTabContentHolder(this.tabs_holder),this.editor_holder.appendChild(this.row_container)),f(this.editors,function(c,d){var e=a.theme.getTabContent(),f=a.theme.getGridColumn(),g=!(!d.schema||"object"!==d.schema.type&&"array"!==d.schema.type);if(e.isObjOrArray=g,b){if(g){var h=a.theme.getGridContainer();h.appendChild(f),e.appendChild(h),a.tabPanesContainer.appendChild(e),a.row_container=h}else"undefined"==typeof a.row_container_basic&&(a.row_container_basic=a.theme.getGridContainer(),e.appendChild(a.row_container_basic),0==a.tabPanesContainer.childElementCount?a.tabPanesContainer.appendChild(e):a.tabPanesContainer.insertBefore(e,a.tabPanesContainer.childNodes[1])),a.row_container_basic.appendChild(f);a.addRow(d,a.tabs_holder,e),e.id=a.getValidId(d.schema.title)}else a.row_container.appendChild(f);d.setContainer(f),d.build(),d.postBuild()}),this.rows[0]&&g(this.rows[0].tab,"click"),this.title_controls=this.theme.getHeaderButtonHolder(),this.editjson_controls=this.theme.getHeaderButtonHolder(),this.addproperty_controls=this.theme.getHeaderButtonHolder(),this.title.appendChild(this.title_controls),this.title.appendChild(this.editjson_controls),this.title.appendChild(this.addproperty_controls),this.collapsed=!1,this.toggle_button=this.getButton("","collapse",this.translate("button_collapse")),this.toggle_button.classList.add("json-editor-btntype-toggle"),this.title_controls.appendChild(this.toggle_button),this.toggle_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.collapsed?(a.editor_holder.style.display="",a.collapsed=!1,a.setButtonText(a.toggle_button,"","collapse",a.translate("button_collapse"))):(a.editor_holder.style.display="none",a.collapsed=!0,a.setButtonText(a.toggle_button,"","expand",a.translate("button_expand")))}),this.options.collapsed&&g(this.toggle_button,"click"),this.schema.options&&"undefined"!=typeof this.schema.options.disable_collapse?this.schema.options.disable_collapse&&(this.toggle_button.style.display="none"):this.jsoneditor.options.disable_collapse&&(this.toggle_button.style.display="none"),this.editjson_button=this.getButton("JSON","edit","Edit JSON"),this.editjson_button.classList.add("json-editor-btntype-editjson"),this.editjson_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.toggleEditJSON()}),this.editjson_controls.appendChild(this.editjson_button),this.editjson_controls.appendChild(this.editjson_holder),this.schema.options&&"undefined"!=typeof this.schema.options.disable_edit_json?this.schema.options.disable_edit_json&&(this.editjson_button.style.display="none"):this.jsoneditor.options.disable_edit_json&&(this.editjson_button.style.display="none"),this.addproperty_button=this.getButton("Properties","edit","Object Properties"),this.addproperty_button.classList.add("json-editor-btntype-properties"),this.addproperty_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.toggleAddProperty()}),this.addproperty_controls.appendChild(this.addproperty_button),this.addproperty_controls.appendChild(this.addproperty_holder),this.refreshAddProperties()}this.options.table_row?(this.editor_holder=this.container,f(this.property_order,function(b,c){a.editor_holder.appendChild(a.editors[c].container)})):(this.layoutEditors(),this.layoutEditors())},showEditJSON:function(){this.editjson_holder&&(this.hideAddProperty(),this.editjson_holder.style.left=this.editjson_button.offsetLeft+"px",this.editjson_holder.style.top=this.editjson_button.offsetTop+this.editjson_button.offsetHeight+"px",this.editjson_textarea.value=JSON.stringify(this.getValue(),null,2),this.disable(),this.editjson_holder.style.display="",this.editjson_button.disabled=!1,this.editing_json=!0)},hideEditJSON:function(){this.editjson_holder&&this.editing_json&&(this.editjson_holder.style.display="none",this.enable(),this.editing_json=!1)},copyJSON:function(){if(this.editjson_holder){var a=document.createElement("textarea");a.value=this.editjson_textarea.value,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}},saveJSON:function(){if(this.editjson_holder)try{var a=JSON.parse(this.editjson_textarea.value);this.setValue(a),this.hideEditJSON(),this.onChange(!0)}catch(b){throw window.alert("invalid JSON"),b}},toggleEditJSON:function(){this.editing_json?this.hideEditJSON():this.showEditJSON()},insertPropertyControlUsingPropertyOrder:function(a,b,c){var d;this.schema.properties[a]&&(d=this.schema.properties[a].propertyOrder),"number"!=typeof d&&(d=1e3),b.propertyOrder=d;for(var e=0;e=this.schema.maxProperties),this.addproperty_checkboxes&&(this.addproperty_list.innerHTML=""),this.addproperty_checkboxes={};for(a in this.cached_editors)this.cached_editors.hasOwnProperty(a)&&(this.addPropertyCheckbox(a),this.isRequired(this.cached_editors[a])&&a in this.editors&&(this.addproperty_checkboxes[a].disabled=!0),"undefined"!=typeof this.schema.minProperties&&d<=this.schema.minProperties?(this.addproperty_checkboxes[a].disabled=this.addproperty_checkboxes[a].checked,this.addproperty_checkboxes[a].checked||(e=!0)):a in this.editors?(e=!0,c=!0):b||this.schema.properties.hasOwnProperty(a)?(this.addproperty_checkboxes[a].disabled=!1,e=!0):this.addproperty_checkboxes[a].disabled=!0);this.canHaveAdditionalProperties()&&(e=!0);for(a in this.schema.properties)this.schema.properties.hasOwnProperty(a)&&(this.cached_editors[a]||(e=!0,this.addPropertyCheckbox(a)));e?this.canHaveAdditionalProperties()?b?this.addproperty_add.disabled=!1:this.addproperty_add.disabled=!0:(this.addproperty_add.style.display="none",this.addproperty_input.style.display="none"):(this.hideAddProperty(),this.addproperty_controls.style.display="none")},isRequired:function(a){return"boolean"==typeof a.schema.required?a.schema.required:Array.isArray(this.schema.required)?this.schema.required.indexOf(a.key)>-1:!!this.jsoneditor.options.required_by_default},setValue:function(a,b){var c=this;a=a||{},("object"!=typeof a||Array.isArray(a))&&(a={}),f(this.cached_editors,function(d,e){"undefined"!=typeof a[d]?(c.addObjectProperty(d),e.setValue(a[d],b)):b||c.isRequired(e)?e.setValue(e.getDefault(),b):c.removeObjectProperty(d)}),f(a,function(a,d){c.cached_editors[a]||(c.addObjectProperty(a),c.editors[a]&&c.editors[a].setValue(d,b))}),this.refreshValue(),this.layoutEditors(),this.onChange()},showValidationErrors:function(a){var b=this,c=[],d=[];if(f(a,function(a,e){e.path===b.path?c.push(e):d.push(e)}),this.error_holder)if(c.length){this.error_holder.innerHTML="",this.error_holder.style.display="",f(c,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none";this.options.table_row&&(c.length?this.theme.addTableRowError(this.container):this.theme.removeTableRowError(this.container)),f(this.editors,function(a,b){b.showValidationErrors(d)})}}),h.defaults.editors.array=h.AbstractEditor.extend({askConfirmation:function(){return this.jsoneditor.options.prompt_before_delete!==!0||confirm("Are you sure you want to remove this node?")!==!1},getDefault:function(){return this.schema["default"]||[]},register:function(){if(this._super(),this.rows)for(var a=0;a=this.schema.items.length?this.schema.additionalItems===!0?{}:this.schema.additionalItems?e({},this.schema.additionalItems):void 0:e({},this.schema.items[a]):this.schema.items?e({},this.schema.items):{}},getItemInfo:function(a){var b=this.getItemSchema(a);this.item_info=this.item_info||{};var c=JSON.stringify(b);return"undefined"!=typeof this.item_info[c]?this.item_info[c]:(b=this.jsoneditor.expandRefs(b),this.item_info[c]={title:b.title||"item","default":b["default"],width:12,child_editors:b.properties||b.items},this.item_info[c])},getElementEditor:function(a){var b=this.getItemInfo(a),c=this.getItemSchema(a);c=this.jsoneditor.expandRefs(c),c.title=b.title+" "+(a+1);var d,e=this.jsoneditor.getEditorClass(c);this.tabs_holder?(d="tabs-top"===this.schema.format?this.theme.getTopTabContent():this.theme.getTabContent(),d.id=this.path+"."+a):d=b.child_editors?this.theme.getChildEditorHolder():this.theme.getIndentedPanel(),this.row_holder.appendChild(d);var f=this.jsoneditor.createEditor(e,{jsoneditor:this.jsoneditor,schema:c,container:d,path:this.path+"."+a,parent:this,required:!0});return f.preBuild(),f.build(),f.postBuild(),f.title_controls||(f.array_controls=this.theme.getButtonHolder(),d.appendChild(f.array_controls)),f},destroy:function(){this.empty(!0),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.row_holder&&this.row_holder.parentNode&&this.row_holder.parentNode.removeChild(this.row_holder),this.controls&&this.controls.parentNode&&this.controls.parentNode.removeChild(this.controls),this.panel&&this.panel.parentNode&&this.panel.parentNode.removeChild(this.panel),this.rows=this.row_cache=this.title=this.description=this.row_holder=this.panel=this.controls=null,this._super()},empty:function(a){if(this.rows){var b=this;f(this.rows,function(c,d){a&&(d.tab&&d.tab.parentNode&&d.tab.parentNode.removeChild(d.tab),b.destroyRow(d,!0),b.row_cache[c]=null),b.rows[c]=null}),b.rows=[],a&&(b.row_cache=[])}},destroyRow:function(a,b){var c=a.container;b?(a.destroy(),c.parentNode&&c.parentNode.removeChild(c),a.tab&&a.tab.parentNode&&a.tab.parentNode.removeChild(a.tab)):(a.tab&&(a.tab.style.display="none"),c.style.display="none",a.unregister())},getMax:function(){return Array.isArray(this.schema.items)&&this.schema.additionalItems===!1?Math.min(this.schema.items.length,this.schema.maxItems||1/0):this.schema.maxItems||1/0},refreshTabs:function(a){var b=this;f(this.rows,function(c,d){d.tab&&(a?d.tab_text.textContent=d.getHeaderText():d.tab===b.active_tab?b.theme.markTabActive(d):b.theme.markTabInactive(d))})},setValue:function(a,b){a=a||[],Array.isArray(a)||(a=[a]);var c=JSON.stringify(a);if(c!==this.serialized){if(this.schema.minItems)for(;a.lengththis.getMax()&&(a=a.slice(0,this.getMax()));var d=this;f(a,function(a,c){d.rows[a]?d.rows[a].setValue(c,b):d.row_cache[a]?(d.rows[a]=d.row_cache[a],d.rows[a].setValue(c,b),d.rows[a].container.style.display="",d.rows[a].tab&&(d.rows[a].tab.style.display=""),d.rows[a].register()):d.addRow(c,b)});for(var e=a.length;e=this.rows.length;f(this.rows,function(a,c){c.movedown_button&&(a===b.rows.length-1?c.movedown_button.style.display="none":c.movedown_button.style.display=""),c.delete_button&&(d?c.delete_button.style.display="none":c.delete_button.style.display=""),b.value[a]=c.getValue()});var e=!1;this.value.length?1===this.value.length?(this.remove_all_rows_button.style.display="none",d||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",e=!0)):(d||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",e=!0),d||this.hide_delete_all_rows_buttons?this.remove_all_rows_button.style.display="none":(this.remove_all_rows_button.style.display="",e=!0)):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"),this.getMax()&&this.getMax()<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",e=!0),!this.collapsed&&e?this.controls.style.display="inline-block":this.controls.style.display="none"}},addRow:function(a,b){var c=this,d=this.rows.length;c.rows[d]=this.getElementEditor(d),c.row_cache[d]=c.rows[d],c.tabs_holder&&(c.rows[d].tab_text=document.createElement("span"),c.rows[d].tab_text.textContent=c.rows[d].getHeaderText(),"tabs-top"===c.schema.format?(c.rows[d].tab=c.theme.getTopTab(c.rows[d].tab_text,this.getValidId(c.rows[d].path)),c.theme.addTopTab(c.tabs_holder,c.rows[d].tab)):(c.rows[d].tab=c.theme.getTab(c.rows[d].tab_text,this.getValidId(c.rows[d].path)),c.theme.addTab(c.tabs_holder,c.rows[d].tab)),c.rows[d].tab.addEventListener("click",function(a){c.active_tab=c.rows[d].tab,c.refreshTabs(),a.preventDefault(),a.stopPropagation()}));var e=c.rows[d].title_controls||c.rows[d].array_controls;c.hide_delete_buttons||(c.rows[d].delete_button=this.getButton(c.getItemTitle(),"delete",this.translate("button_delete_row_title",[c.getItemTitle()])),c.rows[d].delete_button.classList.add("delete","json-editor-btntype-delete"),c.rows[d].delete_button.setAttribute("data-i",d),c.rows[d].delete_button.addEventListener("click",function(a){if(a.preventDefault(),a.stopPropagation(),!c.askConfirmation())return!1;var b=1*this.getAttribute("data-i"),d=c.getValue(),e=[],g=null;f(d,function(a,c){a!==b&&e.push(c)}),c.empty(!0),c.setValue(e),c.rows[b]?g=c.rows[b].tab:c.rows[b-1]&&(g=c.rows[b-1].tab),g&&(c.active_tab=g,c.refreshTabs()),c.onChange(!0),c.jsoneditor.trigger("deleteRow")}),e&&e.appendChild(c.rows[d].delete_button)),c.show_copy_button&&(c.rows[d].copy_button=this.getButton(c.getItemTitle(),"copy","Copy "+c.getItemTitle()),c.rows[d].copy_button.classList.add("copy","json-editor-btntype-copy"),c.rows[d].copy_button.setAttribute("data-i",d),c.rows[d].copy_button.addEventListener("click",function(a){var b=c.getValue();a.preventDefault(),a.stopPropagation();var d=1*this.getAttribute("data-i");f(b,function(a,c){a===d&&b.push(c)}),c.setValue(b),c.refreshValue(!0),c.onChange(!0)}),e.appendChild(c.rows[d].copy_button)),d&&!c.hide_move_buttons&&(c.rows[d].moveup_button=this.getButton("","moveup",this.translate("button_move_up_title")),c.rows[d].moveup_button.classList.add("moveup","json-editor-btntype-move"),c.rows[d].moveup_button.setAttribute("data-i",d),c.rows[d].moveup_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var b=1*this.getAttribute("data-i");if(!(b<=0)){var d=c.getValue(),e=d[b-1];d[b-1]=d[b],d[b]=e,c.setValue(d),c.active_tab=c.rows[b-1].tab,c.refreshTabs(),c.onChange(!0),c.jsoneditor.trigger("moveRow")}}),e&&e.appendChild(c.rows[d].moveup_button)),c.hide_move_buttons||(c.rows[d].movedown_button=this.getButton("","movedown",this.translate("button_move_down_title")),c.rows[d].movedown_button.classList.add("movedown","json-editor-btntype-move"),c.rows[d].movedown_button.setAttribute("data-i",d),c.rows[d].movedown_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var b=1*this.getAttribute("data-i"),d=c.getValue();if(!(b>=d.length-1)){var e=d[b+1];d[b+1]=d[b],d[b]=e,c.setValue(d),c.active_tab=c.rows[b+1].tab,c.refreshTabs(),c.onChange(!0),c.jsoneditor.trigger("moveRow")}}),e&&e.appendChild(c.rows[d].movedown_button)),a&&c.rows[d].setValue(a,b),c.refreshTabs()},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse",this.translate("button_collapse")),this.toggle_button.classList.add("json-editor-btntype-toggle"),this.title_controls.appendChild(this.toggle_button);var b=a.row_holder.style.display,c=a.controls.style.display;this.toggle_button.addEventListener("click",function(d){d.preventDefault(),d.stopPropagation(),a.collapsed?(a.collapsed=!1,a.panel&&(a.panel.style.display=""),a.row_holder.style.display=b,a.tabs_holder&&(a.tabs_holder.style.display=""),a.controls.style.display=c,a.setButtonText(this,"","collapse",a.translate("button_collapse"))):(a.collapsed=!0,a.row_holder.style.display="none",a.tabs_holder&&(a.tabs_holder.style.display="none"),a.controls.style.display="none",a.panel&&(a.panel.style.display="none"),a.setButtonText(this,"","expand",a.translate("button_expand")))}),this.options.collapsed&&g(this.toggle_button,"click"),this.schema.options&&"undefined"!=typeof this.schema.options.disable_collapse?this.schema.options.disable_collapse&&(this.toggle_button.style.display="none"):this.jsoneditor.options.disable_collapse&&(this.toggle_button.style.display="none"),this.add_row_button=this.getButton(this.getItemTitle(),"add",this.translate("button_add_row_title",[this.getItemTitle()])),this.add_row_button.classList.add("json-editor-btntype-add"),this.add_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation();var c=a.rows.length;a.row_cache[c]?(a.rows[c]=a.row_cache[c],a.rows[c].setValue(a.rows[c].getDefault(),!0),a.rows[c].container.style.display="",a.rows[c].tab&&(a.rows[c].tab.style.display=""),a.rows[c].register()):a.addRow(),a.active_tab=a.rows[c].tab,a.refreshTabs(),a.refreshValue(),a.onChange(!0),a.jsoneditor.trigger("addRow")}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton(this.translate("button_delete_last",[this.getItemTitle()]),"delete",this.translate("button_delete_last_title",[this.getItemTitle()])),this.delete_last_row_button.classList.add("json-editor-btntype-deletelast"),this.delete_last_row_button.addEventListener("click",function(b){if(b.preventDefault(),b.stopPropagation(),!a.askConfirmation())return!1;var c=a.getValue(),d=null;c.pop(),a.empty(!0),a.setValue(c),a.rows[a.rows.length-1]&&(d=a.rows[a.rows.length-1].tab),d&&(a.active_tab=d,a.refreshTabs()),a.onChange(!0),a.jsoneditor.trigger("deleteRow")}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton(this.translate("button_delete_all"),"delete",this.translate("button_delete_all_title")),this.remove_all_rows_button.classList.add("json-editor-btntype-deleteall"),this.remove_all_rows_button.addEventListener("click",function(b){return b.preventDefault(),b.stopPropagation(),!!a.askConfirmation()&&(a.empty(!0),a.setValue([]),a.onChange(!0),void a.jsoneditor.trigger("deleteAllRows"))}),a.controls.appendChild(this.remove_all_rows_button),a.tabs&&(this.add_row_button.style.width="100%",this.add_row_button.style.textAlign="left",this.add_row_button.style.marginBottom="3px",this.delete_last_row_button.style.width="100%",this.delete_last_row_button.style.textAlign="left",this.delete_last_row_button.style.marginBottom="3px",this.remove_all_rows_button.style.width="100%",this.remove_all_rows_button.style.textAlign="left",this.remove_all_rows_button.style.marginBottom="3px")},showValidationErrors:function(a){var b=this,c=[],d=[];if(f(a,function(a,e){e.path===b.path?c.push(e):d.push(e)}),this.error_holder)if(c.length){this.error_holder.innerHTML="",this.error_holder.style.display="",f(c,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none";f(this.rows,function(a,b){b.showValidationErrors(d)})}}),h.defaults.editors.table=h.defaults.editors.array.extend({register:function(){if(this._super(),this.rows)for(var a=0;athis.schema.maxItems&&(a=a.slice(0,this.schema.maxItems));var c=JSON.stringify(a);if(c!==this.serialized){var d=!1,e=this;f(a,function(a,b){e.rows[a]?e.rows[a].setValue(b):(e.addRow(b),d=!0)});for(var g=a.length;g=this.rows.length,c=!1;f(this.rows,function(d,e){e.movedown_button&&(d===a.rows.length-1?e.movedown_button.style.display="none":(c=!0,e.movedown_button.style.display="")),e.delete_button&&(b?e.delete_button.style.display="none":(c=!0,e.delete_button.style.display="")),e.moveup_button&&(c=!0)}),f(this.rows,function(a,b){c?b.controls_cell.style.display="":b.controls_cell.style.display="none"}),c?this.controls_header_cell.style.display="":this.controls_header_cell.style.display="none";var d=!1;this.value.length?1===this.value.length?(this.table.style.display="",this.remove_all_rows_button.style.display="none",b||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",d=!0)):(this.table.style.display="",b||this.hide_delete_last_row_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",d=!0),b||this.hide_delete_all_rows_buttons?this.remove_all_rows_button.style.display="none":(this.remove_all_rows_button.style.display="",d=!0)):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none",this.table.style.display="none"),this.schema.maxItems&&this.schema.maxItems<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",d=!0),d?this.controls.style.display="":this.controls.style.display="none"},refreshValue:function(){var a=this;this.value=[],f(this.rows,function(b,c){a.value[b]=c.getValue()}),this.serialized=JSON.stringify(this.value)},addRow:function(a){var b=this,c=this.rows.length;b.rows[c]=this.getElementEditor(c);var d=b.rows[c].table_controls;this.hide_delete_buttons||(b.rows[c].delete_button=this.getButton("","delete",this.translate("button_delete_row_title_short")),b.rows[c].delete_button.classList.add("delete","json-editor-btntype-delete"),b.rows[c].delete_button.setAttribute("data-i",c),b.rows[c].delete_button.addEventListener("click",function(a){if(a.preventDefault(),a.stopPropagation(),!b.askConfirmation())return!1;var c=1*this.getAttribute("data-i"),d=b.getValue(),e=[];f(d,function(a,b){a!==c&&e.push(b)}),b.setValue(e),b.onChange(!0)}),d.appendChild(b.rows[c].delete_button)),c&&!this.hide_move_buttons&&(b.rows[c].moveup_button=this.getButton("","moveup",this.translate("button_move_up_title")),b.rows[c].moveup_button.classList.add("moveup","json-editor-btntype-move"),b.rows[c].moveup_button.setAttribute("data-i",c),b.rows[c].moveup_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i");if(!(c<=0)){var d=b.getValue(),e=d[c-1];d[c-1]=d[c],d[c]=e,b.setValue(d),b.onChange(!0)}}),d.appendChild(b.rows[c].moveup_button)),this.hide_move_buttons||(b.rows[c].movedown_button=this.getButton("","movedown",this.translate("button_move_down_title")),b.rows[c].movedown_button.classList.add("movedown","json-editor-btntype-move"),b.rows[c].movedown_button.setAttribute("data-i",c),b.rows[c].movedown_button.addEventListener("click",function(a){a.preventDefault(),a.stopPropagation();var c=1*this.getAttribute("data-i"),d=b.getValue();if(!(c>=d.length-1)){var e=d[c+1];d[c+1]=d[c],d[c]=e,b.setValue(d),b.onChange(!0)}}),d.appendChild(b.rows[c].movedown_button)),a&&b.rows[c].setValue(a)},addControls:function(){var a=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse",this.translate("button_collapse")),this.toggle_button.classList.add("json-editor-btntype-toggle"),this.title_controls&&(this.title_controls.appendChild(this.toggle_button),this.toggle_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.collapsed?(a.collapsed=!1,a.panel.style.display="",a.setButtonText(this,"","collapse",a.translate("button_collapse"))):(a.collapsed=!0,a.panel.style.display="none",a.setButtonText(this,"","expand",a.translate("button_expand")))}),this.options.collapsed&&g(this.toggle_button,"click"),this.schema.options&&"undefined"!=typeof this.schema.options.disable_collapse?this.schema.options.disable_collapse&&(this.toggle_button.style.display="none"):this.jsoneditor.options.disable_collapse&&(this.toggle_button.style.display="none")),this.add_row_button=this.getButton(this.getItemTitle(),"add",this.translate("button_add_row_title",[this.getItemTitle()])),this.add_row_button.classList.add("json-editor-btntype-add"),this.add_row_button.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.addRow(),a.refreshValue(),a.refreshRowButtons(),a.onChange(!0)}),a.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton(this.translate("button_delete_last",[this.getItemTitle()]),"delete",this.translate("button_delete_last_title",[this.getItemTitle()])),this.delete_last_row_button.classList.add("json-editor-btntype-deletelast"),this.delete_last_row_button.addEventListener("click",function(b){if(b.preventDefault(),b.stopPropagation(),!a.askConfirmation())return!1;var c=a.getValue();c.pop(),a.setValue(c),a.onChange(!0)}),a.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton(this.translate("button_delete_all"),"delete",this.translate("button_delete_all_title")), +this.remove_all_rows_button.classList.add("json-editor-btntype-deleteall"),this.remove_all_rows_button.addEventListener("click",function(b){return b.preventDefault(),b.stopPropagation(),!!a.askConfirmation()&&(a.setValue([]),void a.onChange(!0))}),a.controls.appendChild(this.remove_all_rows_button)}}),h.defaults.editors.multiple=h.AbstractEditor.extend({register:function(){if(this.editors){for(var a=0;anull";if("object"==typeof a){var c="";return f(a,function(d,e){var f=b.getHTML(e);Array.isArray(a)||(f="
        "+d+": "+f+"
        "),c+="
      • "+f+"
      • "}),c=Array.isArray(a)?"
          "+c+"
        ":"
          "+c+"
        "}return"boolean"==typeof a?a?"true":"false":"string"==typeof a?a.replace(/&/g,"&").replace(//g,">"):a},setValue:function(a){this.value!==a&&(this.value=a,this.refreshValue(),this.onChange())},destroy:function(){this.display_area&&this.display_area.parentNode&&this.display_area.parentNode.removeChild(this.display_area),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.switcher&&this.switcher.parentNode&&this.switcher.parentNode.removeChild(this.switcher),this._super()}}),h.defaults.editors.select=h.AbstractEditor.extend({setValue:function(a,b){a=this.typecast(a||"");var c=a;this.enum_values.indexOf(c)<0&&(c=this.enum_values[0]),this.value!==c&&(b?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.input.value=this.enum_options[this.enum_values.indexOf(c)],this.select2&&(this.select2v4?this.select2.val(this.input.value).trigger("change"):this.select2.select2("val",this.input.value)),this.value=c,this.onChange(),this.change())},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){if(!this.enum_options)return 3;for(var a=this.getTitle().length,b=0;b2||this.enum_options.length&&this.enumSource)){var a=e({},h.plugins.select2);this.schema.options&&this.schema.options.select2_options&&(a=e(a,this.schema.options.select2_options)),this.select2=window.jQuery(this.input).select2(a),this.select2v4=this.select2.select2.hasOwnProperty("amd");var b=this;this.select2.on("select2-blur",function(){b.select2v4?b.input.value=b.select2.val():b.input.value=b.select2.select2("val"),b.onInputChange()}),this.select2.on("change",function(){b.select2v4?b.input.value=b.select2.val():b.input.value=b.select2.select2("val"),b.onInputChange()})}else this.select2=null},postBuild:function(){this._super(),this.theme.afterInputReady(this.input),this.setupSelect2()},onWatchedFieldChange:function(){var a,b;if(this.enumSource){a=this.getWatchedFieldValues();for(var c=[],d=[],e=0;e=2||this.enum_options.length&&this.enumSource)){var c=e({},h.plugins.selectize);this.schema.options&&this.schema.options.selectize_options&&(c=e(c,this.schema.options.selectize_options)),this.selectize=window.jQuery(this.input).selectize(e(c,{create:c.create===b||c.create,onChange:function(){a.onInputChange()}}))}else this.selectize=null},postBuild:function(){this._super(),this.theme.afterInputReady(this.input),this.setupSelectize()},onWatchedFieldChange:function(){var a,c;if(this.enumSource){a=this.getWatchedFieldValues();for(var d=[],e=[],f=0;f1&&a.schema.options&&a.schema.options.multiple&&1==a.schema.options.multiple&&a.parent&&"object"==a.parent.schema.type&&a.parent.parent&&"array"==a.parent.parent.schema.type){a.arrayEditor=a.jsoneditor.getEditor(a.parent.parent.path),a.value=a.arrayEditor.getValue(),a.total=this.files.length,a.current_item_index=parseInt(a.parent.key),a.count=a.current_item_index;for(var c=0;cType: "+a+", Size: "+Math.floor((this.value.length-this.value.split(",")[0].length-1)/1.33333)+" bytes","image"===a.substr(0,5)){this.preview.innerHTML+="
        ";var b=document.createElement("img");b.style.maxWidth="100%",b.style.maxHeight="100px",b.src=this.value,this.preview.appendChild(b)}}else this.preview.innerHTML="Invalid data URI"}},enable:function(){this.always_disabled||(this.uploader&&(this.uploader.disabled=!1),this._super())},disable:function(a){a&&(this.always_disabled=!0),this.uploader&&(this.uploader.disabled=!0),this._super()},setValue:function(a){this.value!==a&&(this.value=a,this.input.value=this.value,this.refreshPreview(),this.onChange())},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),h.defaults.editors.upload=h.AbstractEditor.extend({getNumColumns:function(){return 4},build:function(){var a=this;if(this.title=this.header=this.label=this.theme.getFormInputLabel(this.getTitle()),this.input=this.theme.getFormInputField("hidden"),this.container.appendChild(this.input),!this.schema.readOnly&&!this.schema.readonly){if(!this.jsoneditor.options.upload)throw"Upload handler required for upload editor";this.uploader=this.theme.getFormInputField("file"),this.uploader.addEventListener("change",function(b){if(b.preventDefault(),b.stopPropagation(),this.files&&this.files.length){var c=new FileReader;c.onload=function(b){a.preview_value=b.target.result,a.refreshPreview(),a.onChange(!0),c=null},c.readAsDataURL(this.files[0])}})}var b=this.schema.description;b||(b=""),this.preview=this.theme.getFormInputDescription(b),this.container.appendChild(this.preview),this.control=this.theme.getFormControl(this.label,this.uploader||this.input,this.preview),this.container.appendChild(this.control),window.requestAnimationFrame(function(){if(a.value){var b=document.createElement("img");b.style.maxWidth="100%",b.style.maxHeight="100px",b.onload=function(c){a.preview.appendChild(b)},b.onerror=function(a){console.error("upload error",a)},b.src=a.container.querySelector("a").href}})},refreshPreview:function(){if(this.last_preview!==this.preview_value&&(this.last_preview=this.preview_value,this.preview.innerHTML="",this.preview_value)){var a=this,b=this.preview_value.match(/^data:([^;,]+)[;,]/);b&&(b=b[1]),b||(b="unknown");var c=this.uploader.files[0];if(this.preview.innerHTML="Type: "+b+", Size: "+c.size+" bytes","image"===b.substr(0,5)){this.preview.innerHTML+="
        ";var d=document.createElement("img");d.style.maxWidth="100%",d.style.maxHeight="100px",d.src=this.preview_value,this.preview.appendChild(d)}this.preview.innerHTML+="
        ";var e=this.getButton("Upload","upload","Upload");this.preview.appendChild(e),e.addEventListener("click",function(b){b.preventDefault(),e.setAttribute("disabled","disabled"),a.theme.removeInputError(a.uploader),a.theme.getProgressBar&&(a.progressBar=a.theme.getProgressBar(),a.preview.appendChild(a.progressBar)),a.jsoneditor.options.upload(a.path,c,{success:function(b){a.setValue(b),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange(), +a.progressBar&&a.preview.removeChild(a.progressBar),e.removeAttribute("disabled")},failure:function(b){a.theme.addInputError(a.uploader,b),a.progressBar&&a.preview.removeChild(a.progressBar),e.removeAttribute("disabled")},updateProgress:function(b){a.progressBar&&(b?a.theme.updateProgressBar(a.progressBar,b):a.theme.updateProgressBarUnknown(a.progressBar))}})}),(this.jsoneditor.options.auto_upload||this.schema.options.auto_upload)&&(e.dispatchEvent(new MouseEvent("click")),this.preview.removeChild(e))}},enable:function(){this.always_disabled||(this.uploader&&(this.uploader.disabled=!1),this._super())},disable:function(a){a&&(this.always_disabled=!0),this.uploader&&(this.uploader.disabled=!0),this._super()},setValue:function(a){this.value!==a&&(this.value=a,this.input.value=this.value,this.onChange())},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),h.defaults.editors.checkbox=h.AbstractEditor.extend({setValue:function(a,b){this.value=!!a,this.input.checked=this.value,this.onChange()},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){return Math.min(12,Math.max(this.getTitle().length/7,2))},build:function(){var a=this;this.options.compact||(this.label=this.header=this.theme.getCheckboxLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.options.infoText&&(this.infoButton=this.theme.getInfoButton(this.options.infoText)),this.options.compact&&this.container.classList.add("compact"),this.input=this.theme.getCheckbox(),this.control=this.theme.getFormControl(this.label,this.input,this.description,this.infoButton),(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,this.input.disabled=!0),this.input.addEventListener("change",function(b){b.preventDefault(),b.stopPropagation(),a.value=this.checked,a.onChange(!0)}),this.container.appendChild(this.control)},enable:function(){this.always_disabled||(this.input.disabled=!1,this._super())},disable:function(a){a&&(this.always_disabled=!0),this.input.disabled=!0,this._super()},destroy:function(){this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this._super()},showValidationErrors:function(a){var b=this;if("always"===this.jsoneditor.options.show_errors);else if(!this.is_dirty&&this.previous_error_setting===this.jsoneditor.options.show_errors)return;this.previous_error_setting=this.jsoneditor.options.show_errors;var c=[];f(a,function(a,d){d.path===b.path&&c.push(d.message)}),this.input.controlgroup=this.control,c.length?this.theme.addInputError(this.input,c.join(". ")+"."):this.theme.removeInputError(this.input)}}),h.defaults.editors.arraySelectize=h.AbstractEditor.extend({build:function(){this.title=this.theme.getFormInputLabel(this.getTitle()),this.title_controls=this.theme.getHeaderButtonHolder(),this.title.appendChild(this.title_controls),this.error_holder=document.createElement("div"),this.schema.description&&(this.description=this.theme.getDescription(this.schema.description)),this.input=document.createElement("select"),this.input.setAttribute("multiple","multiple");var a=this.theme.getFormControl(this.title,this.input,this.description);this.container.appendChild(a),this.container.appendChild(this.error_holder),window.jQuery(this.input).selectize({delimiter:!1,createOnBlur:!0,create:!0})},postBuild:function(){var a=this;this.input.selectize.on("change",function(b){a.refreshValue(),a.onChange(!0)})},destroy:function(){this.empty(!0),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this._super()},empty:function(a){},setValue:function(a,b){var c=this;a=a||[],Array.isArray(a)||(a=[a]),this.input.selectize.clearOptions(),this.input.selectize.clear(!0),a.forEach(function(a){c.input.selectize.addOption({text:a,value:a})}),this.input.selectize.setValue(a),this.refreshValue(b)},refreshValue:function(a){this.value=this.input.selectize.getValue()},showValidationErrors:function(a){var b=this,c=[],d=[];if(f(a,function(a,e){e.path===b.path?c.push(e):d.push(e)}),this.error_holder)if(c.length){this.error_holder.innerHTML="",this.error_holder.style.display="",f(c,function(a,c){b.error_holder.appendChild(b.theme.getErrorMessage(c.message))})}else this.error_holder.style.display="none"}}),h.defaults.editors.starrating=h.defaults.editors.string.extend({build:function(){var a=this;this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.options.infoText&&(this.infoButton=this.theme.getInfoButton(this.options.infoText)),this.options.compact&&this.container.classList.add("compact"),this.ratingContainer=document.createElement("div"),this.ratingContainer.classList.add("starrating"),this.enum_values=this.schema["enum"],this.radioGroup=[];for(var b=function(b){b.preventDefault(),b.stopPropagation(),a.setValue(this.value),a.onChange(!0)},c=this.enum_values.length-1;c>-1;c--){var d=this.key+"-"+c,e=this.theme.getFormInputField("radio");e.name=this.formname+"[starrating]",e.value=this.enum_values[c],e.id=d,e.addEventListener("change",b,!1),this.radioGroup.push(e);var f=document.createElement("label");f.htmlFor=d,f.title=this.enum_values[c],this.options.displayValue&&f.classList.add("starrating-display-enabled"),this.ratingContainer.appendChild(e),this.ratingContainer.appendChild(f)}if(this.options.displayValue&&(this.displayRating=document.createElement("div"),this.displayRating.classList.add("starrating-display"),this.displayRating.innerText=this.enum_values[0],this.ratingContainer.appendChild(this.displayRating)),this.schema.readOnly||this.schema.readonly){this.always_disabled=!0;for(var g=0;c0){var d=new Date(1e3*a),e=d.getFullYear(),f=this.zeroPad(d.getMonth()+1),g=this.zeroPad(d.getDate()),h=this.zeroPad(d.getHours()),i=this.zeroPad(d.getMinutes()),j=this.zeroPad(d.getSeconds()),k=[e,f,g].join("-"),l=[h,i,j].join(":"),m=k+" "+l;"date"==this.schema.format?m=k:"time"==this.schema.format&&(m=l),this.input.value=m,this.flatpickr&&this.flatpickr.setDate(m)}},destroy:function(){this.flatpickr&&this.flatpickr.destroy(),this.flatpickr=null,this._super()},zeroPad:function(a){return("0"+a).slice(-2)}}),h.defaults.editors.signature=h.defaults.editors.string.extend({build:function(){var a=this;this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description));var b=this.formname.replace(/\W/g,"");if("function"==typeof SignaturePad){var c="json-editor-style-signature";document.getElementById(c);this.input=this.theme.getFormInputField("hidden"),this.container.appendChild(this.input);var d=document.createElement("div");d.classList.add("signature-container");var e=document.createElement("canvas");e.setAttribute("name",b),e.classList.add("signature"),d.appendChild(e),a.signaturePad=new window.SignaturePad(e,{onEnd:function(){a.signaturePad.isEmpty()?a.input.value="":a.input.value=a.signaturePad.toDataURL(),a.is_dirty=!0,a.refreshValue(),a.watch_listener(),a.jsoneditor.notifyWatchers(a.path),a.parent?a.parent.onChildEditorChange(a):a.jsoneditor.onChange()}});var g=document.createElement("div"),h=document.createElement("button");h.classList.add("tiny","button"),h.innerHTML="Clear signature",g.appendChild(h),d.appendChild(g),this.options.compact&&this.container.setAttribute("class",this.container.getAttribute("class")+" compact"),(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,f(this.inputs,function(a,b){e.setAttribute("readOnly","readOnly"),b.disabled=!0})),h.addEventListener("click",function(b){b.preventDefault(),b.stopPropagation(),a.signaturePad.clear(),a.signaturePad.strokeEnd()}),this.control=this.theme.getFormControl(this.label,d,this.description),this.container.appendChild(this.control),this.refreshValue(),e.width=d.offsetWidth,a.options&&a.options.canvas_height?e.height=a.options.canvas_height:e.height="300"}else{var i=document.createElement("p");i.innerHTML="Signature pad is not available, please include SignaturePad from https://github.com/szimek/signature_pad",this.container.appendChild(i)}},setValue:function(a){var b=this;if("function"==typeof SignaturePad){var c=(this.formname.replace(/\W/g,""),this.sanitize(a));if(this.value===c)return;return b.value=c,b.input.value=b.value,b.signaturePad.clear(),a&&""!=a&&b.signaturePad.fromDataURL(a),b.watch_listener(),b.jsoneditor.notifyWatchers(b.path),!1}},destroy:function(){var a=this;this.formname.replace(/\W/g,"");a.signaturePad.off(),delete a.signaturePad}});var i=function(){var a=document.documentElement;return a.matches?"matches":a.webkitMatchesSelector?"webkitMatchesSelector":a.mozMatchesSelector?"mozMatchesSelector":a.msMatchesSelector?"msMatchesSelector":a.oMatchesSelector?"oMatchesSelector":void 0}();return h.AbstractTheme=c.extend({getContainer:function(){return document.createElement("div")},getFloatRightLinkHolder:function(){var a=document.createElement("div");return a.style=a.style||{},a.style.cssFloat="right",a.style.marginLeft="10px",a},getModal:function(){var a=document.createElement("div");return a.style.backgroundColor="white",a.style.border="1px solid black",a.style.boxShadow="3px 3px black",a.style.position="absolute",a.style.zIndex="10",a.style.display="none",a},getGridContainer:function(){var a=document.createElement("div");return a},getGridRow:function(){var a=document.createElement("div");return a.classList.add("row"),a},getGridColumn:function(){var a=document.createElement("div");return a},setGridColumnSize:function(a,b){},getLink:function(a){var b=document.createElement("a");return b.setAttribute("href","#"),b.appendChild(document.createTextNode(a)),b},disableHeader:function(a){a.style.color="#ccc"},disableLabel:function(a){a.style.color="#ccc"},enableHeader:function(a){a.style.color=""},enableLabel:function(a){a.style.color=""},getInfoButton:function(a){var b=document.createElement("span");b.innerText="ⓘ",b.style.fontSize="16px",b.style.fontWeight="bold",b.style.padding=".25rem",b.style.position="relative",b.style.display="inline-block";var c=document.createElement("span");return c.style.fontSize="12px",b.style.fontWeight="normal",c.style["font-family"]="sans-serif",c.style.visibility="hidden",c.style["background-color"]="rgba(50, 50, 50, .75)",c.style.margin="0 .25rem",c.style.color="#FAFAFA",c.style.padding=".5rem 1rem",c.style["border-radius"]=".25rem",c.style.width="20rem",c.style.position="absolute",c.innerText=a,b.onmouseover=function(){c.style.visibility="visible"},b.onmouseleave=function(){c.style.visibility="hidden"},b.appendChild(c),b},getFormInputLabel:function(a){var b=document.createElement("label");return b.appendChild(document.createTextNode(a)),b},getCheckboxLabel:function(a){var b=this.getFormInputLabel(a);return b.style.fontWeight="normal",b},getHeader:function(a){var b=document.createElement("h3");return"string"==typeof a?b.textContent=a:b.appendChild(a),b},getCheckbox:function(){var a=this.getFormInputField("checkbox");return a.style.display="inline-block",a.style.width="auto",a},getMultiCheckboxHolder:function(a,b,c){var d=document.createElement("div");b&&(b.style.display="block",d.appendChild(b));for(var e in a)a.hasOwnProperty(e)&&(a[e].style.display="inline-block",a[e].style.marginRight="20px",d.appendChild(a[e]));return c&&d.appendChild(c),d},getSelectInput:function(a){var b=document.createElement("select");return a&&this.setSelectOptions(b,a),b},getSwitcher:function(a){var b=this.getSelectInput(a);return b.style.backgroundColor="transparent",b.style.display="inline-block",b.style.fontStyle="italic",b.style.fontWeight="normal",b.style.height="auto",b.style.marginBottom=0,b.style.marginLeft="5px",b.style.padding="0 0 0 3px",b.style.width="auto",b},getSwitcherOptions:function(a){return a.getElementsByTagName("option")},setSwitcherOptions:function(a,b,c){this.setSelectOptions(a,b,c)},setSelectOptions:function(a,b,c){c=c||[],a.innerHTML="";for(var d=0;d
        ",c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML="
        ",c},applyStyles:function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a.style[c]=b[c])},closest:function(a,b){for(;a&&a!==document;){if(!a[i])return!1;if(a[i](b))return a;a=a.parentNode}return!1},insertBasicTopTab:function(a,b){b.firstChild.insertBefore(a,b.firstChild.firstChild)},getTab:function(a,b){var c=document.createElement("div");return c.appendChild(a),c.id=b,c.style=c.style||{},this.applyStyles(c,{border:"1px solid #ccc",borderWidth:"1px 0 1px 1px",textAlign:"center",lineHeight:"30px",borderRadius:"5px",borderBottomRightRadius:0,borderTopRightRadius:0,fontWeight:"bold",cursor:"pointer"}),c},getTopTab:function(a,b){var c=document.createElement("div");return c.id=b,c.appendChild(a),c.style=c.style||{},this.applyStyles(c,{"float":"left",border:"1px solid #ccc",borderWidth:"1px 1px 0px 1px",textAlign:"center",lineHeight:"30px",borderRadius:"5px",paddingLeft:"5px",paddingRight:"5px",borderBottomRightRadius:0,borderBottomLeftRadius:0,fontWeight:"bold",cursor:"pointer"}),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){return this.getIndentedPanel()},getTopTabContent:function(){return this.getTopIndentedPanel()},markTabActive:function(a){this.applyStyles(a.tab,{opacity:1,background:"white"}),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){this.applyStyles(a.tab,{opacity:.5,background:""}),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)},getBlockLink:function(){var a=document.createElement("a");return a.style.display="block",a},getBlockLinkHolder:function(){var a=document.createElement("div");return a},getLinksHolder:function(){var a=document.createElement("div");return a},createMediaLink:function(a,b,c){a.appendChild(b),c.style.width="100%",a.appendChild(c)},createImageLink:function(a,b,c){a.appendChild(b),b.appendChild(c)},getFirstTab:function(a){return a.firstChild.firstChild},getInputGroup:function(a,c){return b}}),h.defaults.themes.bootstrap2=h.AbstractTheme.extend({getRangeInput:function(a,b,c){return this._super(a,b,c)},getGridContainer:function(){var a=document.createElement("div");return a.classList.add("container-fluid"),a},getGridRow:function(){var a=document.createElement("div");return a.classList.add("row-fluid"),a},getFormInputLabel:function(a){var b=this._super(a);return b.style.display="inline-block",b.style.fontWeight="bold",b},setGridColumnSize:function(a,b){a.classList.add("span"+b)},getSelectInput:function(a){var b=this._super(a);return b.style.width="auto",b.style.maxWidth="98%",b},getFormInputField:function(a){var b=this._super(a);return b.style.width="98%",b},afterInputReady:function(a){if(!a.controlgroup&&(a.controlgroup=this.closest(a,".control-group"),a.controls=this.closest(a,".controls"),this.closest(a,".compact")&&(a.controlgroup.className=a.controlgroup.className.replace(/control-group/g,"").replace(/[ ]{2,}/g," "),a.controls.className=a.controlgroup.className.replace(/controls/g,"").replace(/[ ]{2,}/g," "),a.style.marginBottom=0),this.queuedInputErrorText)){var b=this.queuedInputErrorText;delete this.queuedInputErrorText,this.addInputError(a,b)}},getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("well","well-small"),a.style.paddingBottom=0,a},getInfoButton:function(a){var b=document.createElement("span");b.classList.add("icon-info-sign","pull-right"),b.style.padding=".25rem",b.style.position="relative",b.style.display="inline-block";var c=document.createElement("span");return c.style["font-family"]="sans-serif",c.style.visibility="hidden",c.style["background-color"]="rgba(50, 50, 50, .75)",c.style.margin="0 .25rem",c.style.color="#FAFAFA",c.style.padding=".5rem 1rem",c.style["border-radius"]=".25rem",c.style.width="25rem",c.style.transform="translateX(-27rem) translateY(-.5rem)",c.style.position="absolute",c.innerText=a,b.onmouseover=function(){c.style.visibility="visible"},b.onmouseleave=function(){c.style.visibility="hidden"},b.appendChild(c),b},getFormInputDescription:function(a){var b=document.createElement("p");return b.classList.add("help-inline"),b.textContent=a,b},getFormControl:function(a,b,c,d){var e=document.createElement("div");e.classList.add("control-group");var f=document.createElement("div");return f.classList.add("controls"),a&&"checkbox"===b.getAttribute("type")?(e.appendChild(f),a.classList.add("checkbox"),a.appendChild(b),f.appendChild(a),d&&f.appendChild(d),f.style.height="30px"):(a&&(a.classList.add("control-label"),e.appendChild(a)),d&&f.appendChild(d),f.appendChild(b),e.appendChild(f)),c&&f.appendChild(c),e},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a.style.marginLeft="10px",a},getButtonHolder:function(){var a=document.createElement("div");return a.classList.add("btn-group"),a},getButton:function(a,b,c){var d=this._super(a,b,c);return d.classList.add("btn","btn-default"),d},getTable:function(){var a=document.createElement("table");return a.classList.add("table","table-bordered"),a.style.width="auto",a.style.maxWidth="none",a},addInputError:function(a,b){return a.controlgroup?void(a.controlgroup&&a.controls&&(a.controlgroup.classList.add("error"),a.errmsg?a.errmsg.style.display="":(a.errmsg=document.createElement("p"),a.errmsg.classList.add("help-block","errormsg"),a.controls.appendChild(a.errmsg)),a.errmsg.textContent=b)):void(this.queuedInputErrorText=b)},removeInputError:function(a){a.controlgroup||delete this.queuedInputErrorText,a.errmsg&&(a.errmsg.style.display="none",a.controlgroup.classList.remove("error"))},getTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("tabbable","tabs-left"),c.innerHTML="
        ",c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("tabbable","tabs-over"),c.innerHTML="
        ",c},getTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.add("active"):a.container.classList.add("active")},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.remove("active"):a.container.classList.remove("active")},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)},getProgressBar:function(){var a=document.createElement("div");a.classList.add("progress");var b=document.createElement("div");return b.classList.add("bar"),b.style.width="0%",a.appendChild(b),a},updateProgressBar:function(a,b){a&&(a.firstChild.style.width=b+"%")},updateProgressBarUnknown:function(a){a&&(a.classList.add("progress","progress-striped","active"),a.firstChild.style.width="100%")},getInputGroup:function(a,b){if(a){var c=document.createElement("div");c.classList.add("input-append"),c.appendChild(a);for(var d=0;d
        ",c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML="
        ",c},getTab:function(a,b){var c=document.createElement("li");c.setAttribute("role","presentation");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),d.setAttribute("aria-controls",b),d.setAttribute("role","tab"),d.setAttribute("data-toggle","tab"),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.setAttribute("role","presentation");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),d.setAttribute("aria-controls",b),d.setAttribute("role","tab"),d.setAttribute("data-toggle","tab"),c.appendChild(d),c},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.add("active"):a.container.classList.add("active")},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.remove("active"):a.container.classList.remove("active")},getProgressBar:function(){var a=0,b=100,c=0,d=document.createElement("div");d.classList.add("progress");var e=document.createElement("div");return e.classList.add("progress-bar"),e.setAttribute("role","progressbar"),e.setAttribute("aria-valuenow",c), +e.setAttribute("aria-valuemin",a),e.setAttribute("aria-valuenax",b),e.innerHTML=c+"%",d.appendChild(e),d},updateProgressBar:function(a,b){if(a){var c=a.firstChild,d=b+"%";c.setAttribute("aria-valuenow",b),c.style.width=d,c.innerHTML=d}},updateProgressBarUnknown:function(a){if(a){var b=a.firstChild;a.classList.add("progress","progress-striped","active"),b.removeAttribute("aria-valuenow"),b.style.width="100%",b.innerHTML=""}},getInputGroup:function(a,b){if(a){var c=document.createElement("div");c.classList.add("input-group"),c.appendChild(a);var d=document.createElement("div");d.classList.add("input-group-btn"),c.appendChild(d);for(var e=0;e
        ",b.classList.add("row"),b},addTab:function(a,b){a.children[0].children[0].appendChild(b)},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML="
        ",c},getTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.classList.add("nav-link"),d.setAttribute("style","padding:10px;"),d.setAttribute("href","#"+b),d.setAttribute("data-toggle","tab"),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.classList.add("nav-item");var d=document.createElement("a");return d.classList.add("nav-link"),d.setAttribute("href","#"+b),d.setAttribute("data-toggle","tab"),d.appendChild(a),c.appendChild(d),c},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-pane"),a.setAttribute("role","tabpanel"),a},markTabActive:function(a){a.tab.firstChild.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.add("active"):a.container.classList.add("active")},markTabInactive:function(a){a.tab.firstChild.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.classList.remove("active"):a.container.classList.remove("active")},getProgressBar:function(){var a=0,b=100,c=0,d=document.createElement("div");d.classList.add("progress");var e=document.createElement("div");return e.classList.add("progress-bar"),e.setAttribute("role","progressbar"),e.setAttribute("aria-valuenow",c),e.setAttribute("aria-valuemin",a),e.setAttribute("aria-valuenax",b),e.innerHTML=c+"%",d.appendChild(e),d},updateProgressBar:function(a,b){if(a){var c=a.firstChild,d=b+"%";c.setAttribute("aria-valuenow",b),c.style.width=d,c.innerHTML=d}},updateProgressBarUnknown:function(a){if(a){var b=a.firstChild;a.classList.add("progress","progress-striped","active"),b.removeAttribute("aria-valuenow"),b.style.width="100%",b.innerHTML=""}},getInputGroup:function(a,b){if(a){var c=document.createElement("div");c.classList.add("input-group"),c.appendChild(a);var d=document.createElement("div");d.classList.add("input-group-prepend"),c.appendChild(d);for(var e=0;e'),a.errmsg=a.parentNode.getElementsByClassName("error")[0]),void(a.errmsg.textContent=b)):void(this.queuedInputErrorText=b)},removeInputError:function(a){a.group||delete this.queuedInputErrorText,a.errmsg&&(a.group.classList.remove("error"),a.errmsg.style.display="none")},getProgressBar:function(){var a=document.createElement("div");a.classList.add("progress");var b=document.createElement("span");return b.classList.add("meter"),b.style.width="0%",a.appendChild(b),a},updateProgressBar:function(a,b){a&&(a.firstChild.style.width=b+"%")},updateProgressBarUnknown:function(a){a&&(a.firstChild.style.width="100%")},getInputGroup:function(a,c){if(!a)return b;var d=document.createElement("div");d.classList.add("input-group"),a.classList.add("input-group-field"),d.appendChild(a);for(var e=0;e
        ',c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("row"),c.innerHTML='
        ',c},setGridColumnSize:function(a,b){var c=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"];a.classList.add("columns",c[b])},getTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("content","active"),a.style.paddingLeft="5px",a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("content","active"),a.style.paddingLeft="5px",a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)}}),h.defaults.themes.foundation4=h.defaults.themes.foundation.extend({getHeaderButtonHolder:function(){var a=this._super();return a.style.fontSize=".6em",a},setGridColumnSize:function(a,b){a.classList.add("columns","large-"+b)},getFormInputDescription:function(a){var b=this._super(a);return b.style.fontSize=".8rem",b},getFormInputLabel:function(a){var b=this._super(a);return b.style.fontWeight="bold",b}}),h.defaults.themes.foundation5=h.defaults.themes.foundation.extend({getFormInputDescription:function(a){var b=this._super(a);return b.style.fontSize=".8rem",b},setGridColumnSize:function(a,b){a.classList.add("columns","medium-"+b)},getButton:function(a,b,c){var d=this._super(a,b,c);return d.className=d.className.replace(/\s*small/g,"")+" tiny",d},getTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.innerHTML='
        ',c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("row"),c.innerHTML='
        ',c},getTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("dd"),d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1]},getTopTabContentHolder:function(a){return a.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-content","active"),a.style.paddingLeft="5px",a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tab-content","active"),a.style.paddingLeft="5px",a},markTabActive:function(a){a.tab.classList.add("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){a.tab.classList.remove("active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"},addTab:function(a,b){a.children[0].appendChild(b)},addTopTab:function(a,b){a.children[0].appendChild(b)}}),h.defaults.themes.foundation6=h.defaults.themes.foundation5.extend({getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("callout","secondary"),a.style="padding-left: 10px; margin-left: 10px;",a},getButtonHolder:function(){var a=document.createElement("div");return a.classList.add("button-group","tiny"),a.style.marginBottom=0,a},getFormInputLabel:function(a){var b=this._super(a);return b.style.display="block",b},getFormControl:function(a,b,c,d){var e=document.createElement("div");return e.classList.add("form-control"),a&&e.appendChild(a),"checkbox"===b.type?a.insertBefore(b,a.firstChild):a?(d&&a.appendChild(d),a.appendChild(b)):(d&&e.appendChild(d),e.appendChild(b)),c&&a.appendChild(c),e},addInputError:function(a,b){if(a.group){if(a.group.classList.add("error"),a.errmsg)a.errmsg.style.display="",a.className="";else{var c=document.createElement("span");c.classList.add("form-error","is-visible"),a.group.getElementsByTagName("label")[0].appendChild(c),a.classList.add("is-invalid-input"),a.errmsg=c}a.errmsg.textContent=b}},removeInputError:function(a){a.errmsg&&(a.classList.remove("is-invalid-input"),a.errmsg.parentNode&&a.errmsg.parentNode.removeChild(a.errmsg))},getTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("grid-x"),c.innerHTML='
          ',c},getTopTabHolder:function(a){var b="undefined"==typeof a?"":a,c=document.createElement("div");return c.classList.add("grid-y"),c.innerHTML='
            ',c},insertBasicTopTab:function(a,b){b.firstChild.firstChild.insertBefore(a,b.firstChild.firstChild.firstChild)},getTab:function(a,b){var c=document.createElement("li");c.classList.add("tabs-title");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTopTab:function(a,b){var c=document.createElement("li");c.classList.add("tabs-title");var d=document.createElement("a");return d.setAttribute("href","#"+b),d.appendChild(a),c.appendChild(d),c},getTabContentHolder:function(a){return a.children[1].firstChild},getTopTabContentHolder:function(a){return a.firstChild.children[1]},getTabContent:function(){var a=document.createElement("div");return a.classList.add("tabs-panel"),a.style.paddingLeft="5px",a},getTopTabContent:function(){var a=document.createElement("div");return a.classList.add("tabs-panel"),a.style.paddingLeft="5px",a},markTabActive:function(a){a.tab.classList.add("is-active"),a.tab.firstChild.setAttribute("aria-selected","true"),"undefined"!=typeof a.rowPane?(a.rowPane.classList.add("is-active"),a.rowPane.setAttribute("aria-selected","true")):(a.container.classList.add("is-active"),a.container.setAttribute("aria-selected","true"))},markTabInactive:function(a){a.tab.classList.remove("is-active"),a.tab.firstChild.removeAttribute("aria-selected"),"undefined"!=typeof a.rowPane?(a.rowPane.classList.remove("is-active"),a.rowPane.removeAttribute("aria-selected")):(a.container.classList.remove("is-active"),a.container.removeAttribute("aria-selected"))},addTab:function(a,b){a.children[0].firstChild.appendChild(b)},addTopTab:function(a,b){a.firstChild.children[0].appendChild(b)},getFirstTab:function(a){return a.firstChild.firstChild.firstChild}}),h.defaults.themes.html=h.AbstractTheme.extend({getFormInputLabel:function(a){var b=this._super(a);return b.style.display="block",b.style.marginBottom="3px",b.style.fontWeight="bold",b},getFormInputDescription:function(a){var b=this._super(a);return b.style.fontSize=".8em",b.style.margin=0,b.style.display="inline-block",b.style.fontStyle="italic",b},getIndentedPanel:function(){var a=this._super();return a.style.border="1px solid #ddd",a.style.padding="5px",a.style.margin="10px",a.style.borderRadius="3px",a},getTopIndentedPanel:function(){return this.getIndentedPanel()},getChildEditorHolder:function(){var a=this._super();return a.style.marginBottom="8px",a},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a.style.display="inline-block",a.style.marginLeft="10px",a.style.fontSize=".8em",a.style.verticalAlign="middle",a},getTable:function(){var a=this._super();return a.style.borderBottom="1px solid #ccc",a.style.marginBottom="5px",a},addInputError:function(a,b){if(a.style.borderColor="red",a.errmsg)a.errmsg.style.display="block";else{var c=this.closest(a,".form-control");a.errmsg=document.createElement("div"),a.errmsg.setAttribute("class","errmsg"),a.errmsg.style=a.errmsg.style||{},a.errmsg.style.color="red",c.appendChild(a.errmsg)}a.errmsg.innerHTML="",a.errmsg.appendChild(document.createTextNode(b))},removeInputError:function(a){a.style.borderColor="",a.errmsg&&(a.errmsg.style.display="none")},getProgressBar:function(){var a=100,b=0,c=document.createElement("progress");return c.setAttribute("max",a),c.setAttribute("value",b),c},updateProgressBar:function(a,b){a&&a.setAttribute("value",b)},updateProgressBarUnknown:function(a){a&&a.removeAttribute("value")}}),h.defaults.themes.jqueryui=h.AbstractTheme.extend({getTable:function(){var a=this._super();return a.setAttribute("cellpadding",5),a.setAttribute("cellspacing",0),a},getTableHeaderCell:function(a){var b=this._super(a);return b.classList.add("ui-state-active"),b.style.fontWeight="bold",b},getTableCell:function(){var a=this._super();return a.classList.add("ui-widget-content"),a},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a.style.marginLeft="10px",a.style.fontSize=".6em",a.style.display="inline-block",a},getFormInputDescription:function(a){var b=this.getDescription(a);return b.style.marginLeft="10px",b.style.display="inline-block",b},getFormControl:function(a,b,c,d){var e=this._super(a,b,c,d);return"checkbox"===b.type?(e.style.lineHeight="25px",e.style.padding="3px 0"):e.style.padding="4px 0 8px 0",e},getDescription:function(a){var b=document.createElement("span");return b.style.fontSize=".8em",b.style.fontStyle="italic",b.textContent=a,b},getButtonHolder:function(){var a=document.createElement("div");return a.classList.add("ui-buttonset"),a.style.fontSize=".7em",a},getFormInputLabel:function(a){var b=document.createElement("label");return b.style.fontWeight="bold",b.style.display="block",b.textContent=a,b},getButton:function(a,b,c){var d=document.createElement("button");d.classList.add("ui-button","ui-widget","ui-state-default","ui-corner-all"),b&&!a?(d.classList.add("ui-button-icon-only"),b.classList.add("ui-button-icon-primary","ui-icon-primary"),d.appendChild(b)):b?(d.classList.add("ui-button-text-icon-primary"),b.classList.add("ui-button-icon-primary","ui-icon-primary"),d.appendChild(b)):d.classList.add("ui-button-text-only");var e=document.createElement("span");return e.classList.add("ui-button-text"),e.textContent=a||c||".",d.appendChild(e),d.setAttribute("title",c),d},setButtonText:function(a,b,c,d){a.innerHTML="",a.classList.add("ui-button","ui-widget","ui-state-default","ui-corner-all"),c&&!b?(a.classList.add("ui-button-icon-only"),c.classList.add("ui-button-icon-primary","ui-icon-primary"),a.appendChild(c)):c?(a.classList.add("ui-button-text-icon-primary"),c.classList.add("ui-button-icon-primary","ui-icon-primary"),a.appendChild(c)):a.classList.add("ui-button-text-only");var e=document.createElement("span");e.classList.add("ui-button-text"),e.textContent=b||d||".",a.appendChild(e),a.setAttribute("title",d)},getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("ui-widget-content","ui-corner-all"),a.style.padding="1em 1.4em",a.style.marginBottom="20px",a},afterInputReady:function(a){if(!a.controls&&(a.controls=this.closest(a,".form-control"),this.queuedInputErrorText)){var b=this.queuedInputErrorText;delete this.queuedInputErrorText,this.addInputError(a,b)}},addInputError:function(a,b){return a.controls?(a.errmsg?a.errmsg.style.display="":(a.errmsg=document.createElement("div"),a.errmsg.classList.add("ui-state-error"),a.controls.appendChild(a.errmsg)),void(a.errmsg.textContent=b)):void(this.queuedInputErrorText=b)},removeInputError:function(a){a.controls||delete this.queuedInputErrorText,a.errmsg&&(a.errmsg.style.display="none")},markTabActive:function(a){a.tab.classList.remove("ui-widget-header"),a.tab.classList.add("ui-state-active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="":a.container.style.display=""},markTabInactive:function(a){a.tab.classList.add("ui-widget-header"),a.tab.classList.remove("ui-state-active"),"undefined"!=typeof a.rowPane?a.rowPane.style.display="none":a.container.style.display="none"}}),h.defaults.themes.barebones=h.AbstractTheme.extend({getFormInputLabel:function(a){var b=this._super(a);return b},getFormInputDescription:function(a){var b=this._super(a);return b},getIndentedPanel:function(){var a=this._super();return a},getChildEditorHolder:function(){var a=this._super();return a},getHeaderButtonHolder:function(){var a=this.getButtonHolder();return a},getTable:function(){var a=this._super();return a},addInputError:function(a,b){if(a.errmsg)a.errmsg.style.display="block";else{var c=this.closest(a,".form-control");a.errmsg=document.createElement("div"),a.errmsg.setAttribute("class","errmsg"),c.appendChild(a.errmsg)}a.errmsg.innerHTML="",a.errmsg.appendChild(document.createTextNode(b))},removeInputError:function(a){a.style.borderColor="",a.errmsg&&(a.errmsg.style.display="none")},getProgressBar:function(){var a=100,b=0,c=document.createElement("progress");return c.setAttribute("max",a),c.setAttribute("value",b),c},updateProgressBar:function(a,b){a&&a.setAttribute("value",b)},updateProgressBarUnknown:function(a){a&&a.removeAttribute("value")}}),h.defaults.themes.materialize=h.AbstractTheme.extend({setGridColumnSize:function(a,b){a.classList.add("col"),a.classList.add("s"+b)},getHeaderButtonHolder:function(){return this.getButtonHolder()},getButtonHolder:function(){return document.createElement("span")},getButton:function(a,b,c){a&&(b.classList.add("left"),b.style.marginRight="5px");var d=this._super(a,b,c);return d.classList.add("waves-effect","waves-light","btn"),d.style.fontSize="0.75rem",d.style.height="24px",d.style.lineHeight="24px",d.style.marginLeft="5px",d.style.padding="0 0.5rem",d},getFormControl:function(a,b,c,d){var e,f=b.type;if(f&&"checkbox"===f){if(e=document.createElement("p"),a){var g=document.createElement("span");g.innerHTML=a.innerHTML,a.innerHTML="",a.setAttribute("for",b.id),e.appendChild(a),a.appendChild(b),a.appendChild(g)}else e.appendChild(b);return e}return e=this._super(a,b,c,d),f&&f.startsWith("select")||e.classList.add("input-field"),f&&"color"===f&&(b.style.height="3rem",b.style.width="100%",b.style.margin="5px 0 20px 0",b.style.padding="3px",a&&(a.style.transform="translateY(-14px) scale(0.8)",a.style["-webkit-transform"]="translateY(-14px) scale(0.8)",a.style["-webkit-transform-origin"]="0 0",a.style["transform-origin"]="0 0")),e},getDescription:function(a){var b=document.createElement("div");return b.classList.add("grey-text"),b.style.marginTop="-15px",b.innerHTML=a,b},getHeader:function(a){var b=document.createElement("h5");return"string"==typeof a?b.textContent=a:b.appendChild(a),b},getChildEditorHolder:function(){var a=document.createElement("div");return a.marginBottom="10px",a},getIndentedPanel:function(){var a=document.createElement("div");return a.classList.add("card-panel"),a},getTable:function(){var a=document.createElement("table");return a.classList.add("striped","bordered"),a.style.marginBottom="10px",a},getTableRow:function(){return document.createElement("tr")},getTableHead:function(){return document.createElement("thead")},getTableBody:function(){return document.createElement("tbody")},getTableHeaderCell:function(a){var b=document.createElement("th");return b.textContent=a,b},getTableCell:function(){var a=document.createElement("td");return a},getTabHolder:function(){var a=['
            ','
              ',"
            ","
            ",'
            ',"
            "].join("\n"),b=document.createElement("div");return b.classList.add("row","card-panel"),b.innerHTML=a,b},addTab:function(a,b){a.children[0].children[0].appendChild(b)},getTab:function(a){var b=document.createElement("li");return b.classList.add("tab"),b.style=b.style||{},this.applyStyles(b,{width:"100%",textAlign:"left",lineHeight:"24px",height:"24px",fontSize:"14px",cursor:"pointer"}),b.appendChild(a),b},markTabActive:function(a){a.style=a.style||{},this.applyStyles(a,{width:"100%",textAlign:"left",lineHeight:"24px",height:"24px",fontSize:"14px",cursor:"pointer",color:"rgba(238,110,115,1)",transition:"border-color .5s ease",borderRight:"3px solid #424242"})},markTabInactive:function(a){a.style=a.style||{},this.applyStyles(a,{width:"100%",textAlign:"left",lineHeight:"24px",height:"24px",fontSize:"14px",cursor:"pointer",color:"rgba(238,110,115,0.7)"})},getTabContentHolder:function(a){return a.children[1]},getTabContent:function(){return document.createElement("div")},addInputError:function(a,b){var c,d=a.parentNode;d&&(this.removeInputError(a),c=document.createElement("div"),c.classList.add("error-text","red-text"),c.textContent=b,d.appendChild(c))},removeInputError:function(a){var b,c=a.parentElement;if(c){b=c.getElementsByClassName("error-text");for(var d=0;d1){var g;c=function(b){for(g=b,a=0;a=0){if(a.items["enum"])return"multiselect";if(h.plugins.selectize.enable&&"string"===a.items.type)return"arraySelectize"}}),h.defaults.resolvers.unshift(function(a){if(a.oneOf||a.anyOf)return"multiple"}),h.defaults.resolvers.unshift(function(a){if(["string","integer"].indexOf(a.type)!==-1&&["date","time","datetime-local"].indexOf(a.format)!==-1)return"datetime"}),h.defaults.resolvers.unshift(function(a){if("string"===a.type&&"starrating"===a.format)return"starrating"}),function(){if(window.jQuery||window.Zepto){var a=window.jQuery||window.Zepto;a.jsoneditor=h.defaults,a.fn.jsoneditor=function(a){var b=this,c=this.data("jsoneditor");if("value"===a){if(!c)throw"Must initialize jsoneditor before getting/setting the value";if(!(arguments.length>1))return c.getValue();c.setValue(arguments[1])}else{if("validate"===a){if(!c)throw"Must initialize jsoneditor before validating";return arguments.length>1?c.validate(arguments[1]):c.validate()}"destroy"===a?c&&(c.destroy(),this.data("jsoneditor",null)):(c&&c.destroy(),c=new h(this.get(0),a),this.data("jsoneditor",c),c.on("change",function(){b.trigger("change")}),c.on("ready",function(){b.trigger("ready")}))}return this}}}(),h}); +//# sourceMappingURL=jsoneditor.min.js.map \ No newline at end of file diff --git a/web/docroot/js/sensesp.js b/web/docroot/js/sensesp.js new file mode 100644 index 000000000..c42e0c2fc --- /dev/null +++ b/web/docroot/js/sensesp.js @@ -0,0 +1,243 @@ + +function ajax(method, url, data, contentType) { + return new Promise(function(resolve, reject) { + var request = new XMLHttpRequest(); + + request.open(method, url, true); + + request.onload = function() { + if (request.status === 200) { + resolve(request.response); + } else { + reject(Error(request.statusText)); + } + }; + + request.onerror = function() { + reject(Error("Network Error")); + }; + + if (contentType) { + request.setRequestHeader("Content-Type", contentType); + } + + request.send(data); + }); +} + + +class TreeList { + + constructor(main, pathList) { + + this.main = main; + this.main.appendChild(document.createElement('div')); + this.root = document.createElement('ul'); + this.root.id = 'tree'; + this.main.appendChild(this.root); + + // Build the tree structure out of the configuration list + for (var i = 0; i < pathList.length; i++) { + var entry = pathList[i]; + var fullPath = entry; + var parts = entry.split('/'); + var nodeName = parts.pop(); + var section = this.main; + parts.shift(); // Get rid of first blank entry (due to forward slash)... + while (parts.length > 0) { + var sectionName = parts.shift(); + section = this.findNode(section, sectionName); + } + this.addEntry(section, nodeName, fullPath); + } + + // Add section expand/collapse to the "folder" nodes + var toggler = document.getElementsByClassName("caret"); + for (var i = 0; i < toggler.length; i++) { + toggler[i].addEventListener("click", function() { + this.parentElement.querySelector(".nested").classList.toggle("active"); + this.classList.toggle("caret-down"); + }); + } + + } + + makeSectionNode(name) { + var section = document.createElement('li'); + var caret = document.createElement('span'); + caret.className = 'caret'; + caret.innerHTML = name; + section.appendChild(caret); + var ul = document.createElement('ul'); + ul.className = 'nested'; + section.appendChild(ul); + return section; + } + + addEntry(section, name, fullPath) { + var entry = document.createElement('li'); + entry.innerHTML = name; + section.children[1].appendChild(entry); + entry.className = 'selectable'; + entry.addEventListener('click', function () { editConfig(fullPath); } ) + } + + findNode(sectionRoot, nodeName) { + if (nodeName != '') { + var i; + var nextEntry; + var searchChildren = sectionRoot.children[1].childNodes; + for (i = 0; i < searchChildren.length; i++) { + nextEntry = searchChildren[i] + if (nextEntry.childNodes[0].textContent == nodeName) { + return nextEntry; + } + } + // If we get here, the node does not yet exist. Add it... + nextEntry = this.makeSectionNode(nodeName); + sectionRoot.children[1].appendChild(nextEntry); + return nextEntry; + } + else { + return sectionRoot; + } + } + + } + +var globalEditor = null; + +function getEmptyMountDiv() { + + var main = document.getElementById("mountNode"); + main.empty(); + globalEditor = null; + return main; +} + + +function editConfig(config_path) { + + var main = getEmptyMountDiv(); + + ajax('GET', '/config' + config_path) + + .then(response => { + + var json = JSON.parse(response); + var config = json.config; + var schema = json.schema; + + if (Object.keys(schema).length == 0) { + alert(`No schema available for ${config_path}`); + showConfigTree(); + return; + } + + if (!schema.title) { + schema.title = `Configuration for ${config_path}`; + } + + main.innerHTML = ` +
            +
            +
            +
            +
            + + + +
            +
            + `; + + globalEditor = new JSONEditor(document.getElementById('editor_holder'), + { + 'schema': schema, + 'startval': config, + 'no_additional_properties': true, + 'disable_collapse': true, + 'disable_properties': true, + 'disable_edit_json': true, + 'show_opt_in': true, + }); + + document.getElementById('submit').addEventListener('click',function() { + saveConfig(config_path, globalEditor.getValue()); + }); + + document.getElementById('cancel').addEventListener('click',function() { + showConfigTree(); + }); + + // Hook up the validation indicator to update its + // status whenever the editor changes + globalEditor.on('change',function() { + // Get an array of errors from the validator + var errors = globalEditor.validate(); + + var indicator = document.getElementById('valid_indicator'); + + // Not valid + if(errors.length) { + indicator.className = 'label alert'; + indicator.textContent = 'not valid'; + } + // Valid + else { + indicator.className = 'label success'; + indicator.textContent = 'valid'; + } + }) + }) + .catch(err => { + alert(`Error retrieving configuration ${config_path}: ${err.message}`); + showConfigTree(); + }); + +} + + +function saveConfig(config_path, values) { + + ajax('PUT', '/config' + config_path, JSON.stringify(values), 'application/json') + .then(response => { + showConfigTree(); + }) + .catch(err => { + alert(`Error saving configuration ${config_path}: ${err.message}`); + showConfigTree(); + }); +} + + +Element.prototype.empty = function() { + var child = this.lastElementChild; + while (child) { + this.removeChild(child); + child = this.lastElementChild; + } +} + + +function showConfigTree() { + + var main = getEmptyMountDiv(); + + ajax('GET', '/config') + .then(response => { + var json = JSON.parse(response); + var configList = json.keys; + configList.sort(); + return configList; + }) + .then(configList => { + + var treeList = new TreeList(main, configList); + + }) + .catch(err => { + alert('Error: ' + err.statusText); + }); + +} diff --git a/web/docroot/js/sensesp.min.js b/web/docroot/js/sensesp.min.js new file mode 100644 index 000000000..1365a60f0 --- /dev/null +++ b/web/docroot/js/sensesp.min.js @@ -0,0 +1 @@ +function ajax(method,url,data,contentType){return new Promise(function(resolve,reject){var request=new XMLHttpRequest;request.open(method,url,!0),request.onload=function(){200===request.status?resolve(request.response):reject(Error(request.statusText))},request.onerror=function(){reject(Error("Network Error"))},contentType&&request.setRequestHeader("Content-Type",contentType),request.send(data)})}class TreeList{constructor(main,pathList){this.main=main,this.main.appendChild(document.createElement("div")),this.root=document.createElement("ul"),this.root.id="tree",this.main.appendChild(this.root);for(var i=0;i0;){var sectionName=parts.shift();section=this.findNode(section,sectionName)}this.addEntry(section,nodeName,fullPath)}var toggler=document.getElementsByClassName("caret");for(i=0;i{var json=JSON.parse(response),config=json.config,schema=json.schema;if(0==Object.keys(schema).length)return alert(`No schema available for ${config_path}`),void showConfigTree();schema.title||(schema.title=`Configuration for ${config_path}`),main.innerHTML="\n
            \n
            \n
            \n
            \n
            \n \n \n \n
            \n
            \n ",globalEditor=new JSONEditor(document.getElementById("editor_holder"),{schema:schema,startval:config,no_additional_properties:!0,disable_collapse:!0,disable_properties:!0,disable_edit_json:!0,show_opt_in:!0}),document.getElementById("submit").addEventListener("click",function(){saveConfig(config_path,globalEditor.getValue())}),document.getElementById("cancel").addEventListener("click",function(){showConfigTree()}),globalEditor.on("change",function(){var errors=globalEditor.validate(),indicator=document.getElementById("valid_indicator");errors.length?(indicator.className="label alert",indicator.textContent="not valid"):(indicator.className="label success",indicator.textContent="valid")})}).catch(err=>{alert(`Error retrieving configuration ${config_path}: ${err.message}`),showConfigTree()})}function saveConfig(config_path,values){ajax("PUT","/config"+config_path,JSON.stringify(values),"application/json").then(response=>{showConfigTree()}).catch(err=>{alert(`Error saving configuration ${config_path}: ${err.message}`),showConfigTree()})}function showConfigTree(){var main=getEmptyMountDiv();ajax("GET","/config").then(response=>{var configList=JSON.parse(response).keys;return configList.sort(),configList}).then(configList=>{new TreeList(main,configList)}).catch(err=>{alert("Error: "+err.statusText)})}Element.prototype.empty=function(){for(var child=this.lastElementChild;child;)this.removeChild(child),child=this.lastElementChild}; \ No newline at end of file diff --git a/web/docroot/setup/index.html b/web/docroot/setup/index.html new file mode 100644 index 000000000..e47950816 --- /dev/null +++ b/web/docroot/setup/index.html @@ -0,0 +1,57 @@ + + + Configure SensESP Sensor + + + + + + + + +

            SensESP Sensor

            +
            +
            + +