2016-12-08 23:39:41 +01:00
|
|
|
JSONEditor.defaults.editors.colorPicker = JSONEditor.defaults.editors.string.extend({
|
2016-11-30 17:32:12 +01:00
|
|
|
|
2016-12-08 23:39:41 +01:00
|
|
|
getValue: function() {
|
|
|
|
if ($(this.input).data("colorpicker") !== undefined) {
|
|
|
|
var color = $(this.input).data('colorpicker').color.toRGB();
|
|
|
|
return [color.r,color.g, color.b];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return [0,0,0];
|
|
|
|
}
|
|
|
|
},
|
2016-11-18 18:39:27 +01:00
|
|
|
|
2016-12-08 23:39:41 +01:00
|
|
|
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);
|
|
|
|
}
|
2016-11-18 18:39:27 +01:00
|
|
|
|
2016-12-08 23:39:41 +01:00
|
|
|
$(this.input).colorpicker('updateInput', 'rgb('+val+')');
|
|
|
|
$(this.input).colorpicker('updateData', val);
|
|
|
|
$(this.input).colorpicker('updatePicker', rgb2hex(val));
|
|
|
|
$(this.input).colorpicker('updateComponent', 'rgb('+val+')');
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build: function() {
|
|
|
|
this._super();
|
|
|
|
var myinput = this;
|
|
|
|
$(myinput.input).parent().attr("class", $(myinput.input).parent().attr('class') + " colorpicker-element");
|
|
|
|
$(myinput.input).append("<span class='input-group-addon' id='event_catcher'><i></i></span>");
|
|
|
|
$(myinput.input).colorpicker({
|
|
|
|
format: 'rgb',
|
|
|
|
customClass: 'colorpicker-2x',
|
|
|
|
sliders: {
|
|
|
|
saturation: {
|
|
|
|
maxLeft: 200,
|
|
|
|
maxTop: 200
|
2016-11-18 18:39:27 +01:00
|
|
|
},
|
2016-12-08 23:39:41 +01:00
|
|
|
hue: {
|
|
|
|
maxTop: 200
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
2016-11-30 17:32:12 +01:00
|
|
|
|
2016-12-08 23:39:41 +01:00
|
|
|
$("#event_catcher").detach().insertAfter(myinput.input);
|
|
|
|
$("#event_catcher").attr("id", "selector");
|
|
|
|
|
|
|
|
$(this.input).colorpicker().on('changeColor', function(e) {
|
|
|
|
$(myinput).val(e.color.toRGB()).change();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2016-11-18 18:39:27 +01:00
|
|
|
|
2016-12-08 23:39:41 +01:00
|
|
|
JSONEditor.defaults.resolvers.unshift(function(schema) {
|
|
|
|
if(schema.type === "array" && schema.format === "colorpicker") {
|
|
|
|
return "colorPicker";
|
|
|
|
}
|
2016-11-18 18:39:27 +01:00
|
|
|
|
2016-12-08 23:39:41 +01:00
|
|
|
});
|
2016-11-18 18:39:27 +01:00
|
|
|
|
2016-11-21 22:16:57 +01:00
|
|
|
var oldDelList = [];
|
|
|
|
|
|
|
|
function updateDelEffectlist(event){
|
|
|
|
var newDelList = event.response.info.effects
|
|
|
|
if(newDelList.length != oldDelList.length)
|
|
|
|
{
|
|
|
|
var EffectHtml = null;
|
|
|
|
for(var idx=0; idx<newDelList.length; idx++)
|
|
|
|
{
|
|
|
|
if(!/^\:/.test(newDelList[idx].file))
|
|
|
|
{
|
|
|
|
EffectHtml += '<option value="'+newDelList[idx].name+'">'+newDelList[idx].name+'</option>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$("#effectsdellist").html(EffectHtml);
|
|
|
|
oldDelList = newDelList;
|
2016-12-04 19:32:23 +01:00
|
|
|
$('#effectsdellist').trigger('change');
|
2016-11-21 22:16:57 +01:00
|
|
|
}
|
|
|
|
}
|
2016-12-04 19:32:23 +01:00
|
|
|
|
2016-10-30 17:54:38 +01:00
|
|
|
$(hyperion).one("cmd-config-getschema", function(event) {
|
|
|
|
effects = parsedConfSchemaJSON.properties.effectSchemas.internal
|
|
|
|
EffectsHtml = "";
|
|
|
|
for(var idx=0; idx<effects.length; idx++)
|
|
|
|
{
|
2016-12-04 19:32:23 +01:00
|
|
|
EffectsHtml += '<option value="'+effects[idx].schemaContent.script+'">'+$.i18n(effects[idx].schemaContent.title)+'</option>';
|
2016-10-30 17:54:38 +01:00
|
|
|
}
|
|
|
|
$("#effectslist").html(EffectsHtml);
|
|
|
|
$("#effectslist").trigger("change");
|
|
|
|
});
|
2016-10-31 06:26:54 +01:00
|
|
|
|
|
|
|
function validateEditor() {
|
|
|
|
if(effects_editor.validate().length)
|
|
|
|
{
|
2016-12-04 19:32:23 +01:00
|
|
|
showInfoDialog('error', $.i18n('infoDialog_effconf_invalidvalue_title'), $.i18n('infoDialog_effconf_invalidvalue_text'));
|
2016-10-31 06:26:54 +01:00
|
|
|
return false;
|
|
|
|
}
|
2016-12-04 19:32:23 +01:00
|
|
|
return true;
|
2016-10-31 06:26:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
function triggerTestEffect() {
|
|
|
|
var args = effects_editor.getEditor('root.args');
|
|
|
|
requestTestEffect(effectName, ":/effects/" + effectPy.slice(1), JSON.stringify(args.getValue()));
|
|
|
|
};
|
|
|
|
|
|
|
|
effectName = "";
|
2016-10-30 17:54:38 +01:00
|
|
|
effects_editor = null;
|
|
|
|
effectPy = "";
|
|
|
|
|
|
|
|
$("#effectslist").off().on("change", function(event) {
|
|
|
|
for(var idx=0; idx<effects.length; idx++){
|
|
|
|
if (effects[idx].schemaContent.script == this.value){
|
|
|
|
effects_editor = createJsonEditor('editor_container', {
|
|
|
|
args : effects[idx].schemaContent,
|
|
|
|
},false);
|
|
|
|
effectPy = ':';
|
|
|
|
effectPy += effects[idx].schemaContent.script;
|
|
|
|
}
|
2016-12-04 19:32:23 +01:00
|
|
|
$("#name-input").trigger("change");
|
2016-10-30 17:54:38 +01:00
|
|
|
}
|
2016-10-31 06:26:54 +01:00
|
|
|
effects_editor.on('change',function() {
|
2016-12-04 19:32:23 +01:00
|
|
|
if ($("#btn_cont_test").hasClass("btn-success") && validateEditor())
|
2016-10-31 06:26:54 +01:00
|
|
|
{
|
|
|
|
triggerTestEffect();
|
|
|
|
}
|
|
|
|
});
|
2016-10-30 17:54:38 +01:00
|
|
|
});
|
|
|
|
|
2016-12-04 19:32:23 +01:00
|
|
|
$("#name-input").on('change keydown click', function(event) {
|
|
|
|
effectName = $(this).val();
|
|
|
|
if ($(this).val() == '') {
|
|
|
|
effects_editor.disable();
|
|
|
|
$("#eff_footer").children().attr('disabled',true);
|
|
|
|
} else {
|
|
|
|
effects_editor.enable();
|
|
|
|
$("#eff_footer").children().attr('disabled',false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-10-30 17:54:38 +01:00
|
|
|
$('#btn_write').off().on('click',function() {
|
2016-12-04 19:32:23 +01:00
|
|
|
if(validateEditor())
|
2016-10-30 17:54:38 +01:00
|
|
|
{
|
2016-10-31 06:26:54 +01:00
|
|
|
requestWriteEffect(effectName,effectPy,JSON.stringify(effects_editor.getValue()));
|
2016-12-04 19:32:23 +01:00
|
|
|
showInfoDialog('success', $.i18n('infoDialog_effconf_created_title'), $.i18n('infoDialog_effconf_created_text', effectName));
|
2016-10-30 17:54:38 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-10-31 06:26:54 +01:00
|
|
|
$('#btn_start_test').off().on('click',function() {
|
2016-12-04 19:32:23 +01:00
|
|
|
if(validateEditor())
|
2016-10-30 22:59:45 +01:00
|
|
|
{
|
2016-10-31 06:26:54 +01:00
|
|
|
triggerTestEffect();
|
2016-10-30 22:59:45 +01:00
|
|
|
}
|
2016-10-31 06:26:54 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$('#btn_stop_test').off().on('click',function() {
|
|
|
|
requestPriorityClear();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#btn_cont_test').off().on('click',function() {
|
|
|
|
toggleClass('#btn_cont_test', "btn-success", "btn-danger");
|
2016-10-30 22:59:45 +01:00
|
|
|
});
|
2016-11-18 18:39:27 +01:00
|
|
|
|
|
|
|
$('#btn_delete').off().on('click',function() {
|
|
|
|
var name = $("#effectsdellist").val();
|
|
|
|
requestDeleteEffect(name);
|
2016-12-04 19:32:23 +01:00
|
|
|
showInfoDialog('success', $.i18n('infoDialog_effconf_deleted_title'), $.i18n('infoDialog_effconf_deleted_text', name));
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#effectsdellist').off().on('change', function(){
|
|
|
|
if ($(this).val() == null) {
|
|
|
|
$('#btn_delete').prop('disabled',true);
|
|
|
|
} else {
|
|
|
|
$('#btn_delete').prop('disabled',false);
|
|
|
|
}
|
2016-11-18 18:39:27 +01:00
|
|
|
});
|
|
|
|
|
2016-10-30 17:54:38 +01:00
|
|
|
$(document).ready( function() {
|
2016-12-04 19:32:23 +01:00
|
|
|
performTranslation();
|
2016-10-30 17:54:38 +01:00
|
|
|
requestServerConfigSchema();
|
2016-11-21 22:16:57 +01:00
|
|
|
$(hyperion).on("cmd-serverinfo",updateDelEffectlist);
|
2016-10-30 17:54:38 +01:00
|
|
|
});
|