2017-02-08 14:36:28 +01:00
|
|
|
$(document).ready( function() {
|
|
|
|
performTranslation();
|
2016-11-21 22:16:57 +01:00
|
|
|
var oldDelList = [];
|
2017-02-08 14:36:28 +01:00
|
|
|
var effectName = "";
|
|
|
|
var effects_editor = null;
|
|
|
|
var effectPy = "";
|
2017-02-15 15:53:35 +01:00
|
|
|
var testrun;
|
2017-02-08 14:36:28 +01:00
|
|
|
|
|
|
|
if(showOptHelp)
|
|
|
|
createHintH("intro", $.i18n('effectsconfigurator_label_intro'), "intro_effc");
|
2016-11-21 22:16:57 +01:00
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
function updateDelEffectlist(){
|
2017-03-18 00:05:04 +01:00
|
|
|
var newDelList = serverInfo.effects;
|
2016-11-21 22:16:57 +01:00
|
|
|
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-10-31 06:26:54 +01:00
|
|
|
|
|
|
|
function triggerTestEffect() {
|
2017-02-15 15:53:35 +01:00
|
|
|
testrun = true;
|
2016-10-31 06:26:54 +01:00
|
|
|
var args = effects_editor.getEditor('root.args');
|
|
|
|
requestTestEffect(effectName, ":/effects/" + effectPy.slice(1), JSON.stringify(args.getValue()));
|
|
|
|
};
|
|
|
|
|
2016-10-30 17:54:38 +01:00
|
|
|
|
|
|
|
$("#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,
|
2016-12-21 18:24:03 +01:00
|
|
|
},false, true);
|
2016-10-30 17:54:38 +01:00
|
|
|
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() {
|
2017-02-08 14:36:28 +01:00
|
|
|
if ($("#btn_cont_test").hasClass("btn-success") && effects_editor.validate().length == 0 && effectName != "")
|
2016-10-31 06:26:54 +01:00
|
|
|
{
|
|
|
|
triggerTestEffect();
|
|
|
|
}
|
2017-02-08 14:36:28 +01:00
|
|
|
if( effects_editor.validate().length == 0 && effectName != "")
|
|
|
|
{
|
|
|
|
$('#btn_start_test').attr('disabled', false);
|
|
|
|
$('#btn_write').attr('disabled', false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('#btn_start_test').attr('disabled', true);
|
|
|
|
$('#btn_write').attr('disabled', true);
|
|
|
|
}
|
2016-10-31 06:26:54 +01:00
|
|
|
});
|
2016-10-30 17:54:38 +01:00
|
|
|
});
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
$("#name-input").on('change keyup', function(event) {
|
2016-12-04 19:32:23 +01:00
|
|
|
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() {
|
2017-02-08 14:36:28 +01:00
|
|
|
requestWriteEffect(effectName,effectPy,JSON.stringify(effects_editor.getValue()));
|
|
|
|
$(hyperion).one("cmd-create-effect", function(event) {
|
|
|
|
if (event.response.success)
|
|
|
|
showInfoDialog('success', "", $.i18n('infoDialog_effconf_created_text', effectName));
|
|
|
|
});
|
|
|
|
|
2017-02-15 15:53:35 +01:00
|
|
|
if (testrun)
|
|
|
|
setTimeout(requestPriorityClear,100);
|
|
|
|
|
2016-10-30 17:54:38 +01:00
|
|
|
});
|
|
|
|
|
2016-10-31 06:26:54 +01:00
|
|
|
$('#btn_start_test').off().on('click',function() {
|
2017-02-08 14:36:28 +01:00
|
|
|
triggerTestEffect();
|
2016-10-31 06:26:54 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$('#btn_stop_test').off().on('click',function() {
|
|
|
|
requestPriorityClear();
|
2017-02-15 15:53:35 +01:00
|
|
|
testrun = false;
|
2016-10-31 06:26:54 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$('#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);
|
2017-02-08 14:36:28 +01:00
|
|
|
$(hyperion).one("cmd-delete-effect", function(event) {
|
|
|
|
if (event.response.success)
|
|
|
|
showInfoDialog('success', "", $.i18n('infoDialog_effconf_deleted_text', name));
|
|
|
|
});
|
2016-12-04 19:32:23 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$('#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
|
|
|
});
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
//create basic effect list
|
|
|
|
var effects = serverSchema.properties.effectSchemas.internal
|
|
|
|
for(var idx=0; idx<effects.length; idx++)
|
|
|
|
{
|
|
|
|
$("#effectslist").append(createSelOpt(effects[idx].schemaContent.script, $.i18n(effects[idx].schemaContent.title)));
|
|
|
|
}
|
|
|
|
$("#effectslist").trigger("change");
|
|
|
|
|
|
|
|
updateDelEffectlist();
|
|
|
|
|
|
|
|
//interval update
|
2016-11-21 22:16:57 +01:00
|
|
|
$(hyperion).on("cmd-serverinfo",updateDelEffectlist);
|
2017-02-08 14:36:28 +01:00
|
|
|
|
|
|
|
removeOverlay();
|
|
|
|
});
|