JSONEditor.defaults.editors.colorPicker = JSONEditor.defaults.editors.string.extend({ getValue: function() { color = $(this.input).data('colorpicker').color.toRGB(); return [color.r, color.g, color.b]; }, setValue: function(val) { function rgb2hex(rgb){ return "#" + ("0" + parseInt(rgb[0],10).toString(16)).slice(-2) + ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) + ("0" + parseInt(rgb[2],10).toString(16)).slice(-2); } $(this.input).colorpicker('setValue', rgb2hex(val)); }, build: function() { this._super(); var myinput = this $(this.input).colorpicker({ format: 'rgb', customClass: 'colorpicker-2x', sliders: { saturation: { maxLeft: 200, maxTop: 200 }, hue: { maxTop: 200 }, }, }) //$(this.input).colorpicker().on('changeColor', function(e) { //$(this.input).trigger("change"); //}); } }); JSONEditor.defaults.resolvers.unshift(function(schema) { if(schema.type === "array" && schema.format === "colorpicker") { return "colorPicker"; } }); $(hyperion).one("cmd-config-getschema", function(event) { effects = parsedConfSchemaJSON.properties.effectSchemas.internal EffectsHtml = ""; for(var idx=0; idx'+effects[idx].schemaContent.title+''; } $("#effectslist").html(EffectsHtml); $("#effectslist").trigger("change"); }); function validateEditor() { if(effects_editor.validate().length) { showInfoDialog('error','INVALID VALUES','Please check for red marked inputs and try again.'); return false; } else { return true; } }; function validateName() { effectName = $('#name-input').val(); if (effectName == "") { showInfoDialog('error','INVALID NAME FIELD','Effect name is empty! Please fill in a name and try again.'); return false; } else { return true; } }; function triggerTestEffect() { var args = effects_editor.getEditor('root.args'); requestTestEffect(effectName, ":/effects/" + effectPy.slice(1), JSON.stringify(args.getValue())); }; effectName = ""; effects_editor = null; effectPy = ""; $("#effectslist").off().on("change", function(event) { for(var idx=0; idx'+delList[idx].name+''; } } $("#effectsdellist").html(EffectHtml); $('#btn_delete').off().on('click',function() { var name = $("#effectsdellist").val(); requestDeleteEffect(name); }); $(document).ready( function() { requestServerConfigSchema(); });