$(document).ready( function() {
performTranslation();
var importedConf;
var confName;
var conf_editor = null;
$('#conf_cont').append(createOptPanel('fa-wrench', $.i18n("edt_conf_gen_heading_title"), 'editor_container', 'btn_submit'));
if(window.showOptHelp)
{
$('#conf_cont').append(createHelpTable(window.schema.general.properties, $.i18n("edt_conf_gen_heading_title")));
}
else
$('#conf_imp').appendTo('#conf_cont');
conf_editor = createJsonEditor('editor_container', {
general: window.schema.general
}, true, true);
conf_editor.on('change',function() {
conf_editor.validate().length ? $('#btn_submit').attr('disabled', true) : $('#btn_submit').attr('disabled', false);
});
$('#btn_submit').off().on('click',function() {
requestWriteConfig(conf_editor.getValue());
});
// Token handling
function buildTokenList()
{
console.log(tokenList)
$('.tktbody').html("");
for(var key in tokenList)
{
var lastUse = (tokenList[key].last_use) ? tokenList[key].last_use : "-";
var btn = '';
$('.tktbody').append(createTableRow([tokenList[key].comment, lastUse, btn], false, true));
$('#tok'+tokenList[key].id).off().on('click', handleDeleteToken);
}
}
createTable('tkthead', 'tktbody', 'tktable');
$('.tkthead').html(createTableRow([$.i18n('conf_general_tok_cidhead'), $.i18n('conf_general_tok_lastuse'), $.i18n('general_btn_delete')], true, true));
buildTokenList();
function handleDeleteToken(e)
{
var key = e.currentTarget.id.replace("tok","");
requestTokenDelete(key);
$('#tok'+key).parent().parent().remove();
// rm deleted token id
tokenList = tokenList.filter(function( obj ) {
return obj.id !== key;
});
}
$('#btn_create_tok').off().on('click',function() {
requestToken($('#tok_comment').val())
$('#tok_comment').val("")
$('#btn_create_tok').attr('disabled', true)
});
$('#tok_comment').off().on('input',function(e) {
(e.currentTarget.value.length >= 10) ? $('#btn_create_tok').attr('disabled', false) : $('#btn_create_tok').attr('disabled', true);
});
$(window.hyperion).off("cmd-authorize-createToken").on("cmd-authorize-createToken", function(event) {
var val = event.response.info;
showInfoDialog("newToken",$.i18n('conf_general_tok_diaTitle'),$.i18n('conf_general_tok_diaMsg')+'