2017-02-08 14:36:28 +01:00
|
|
|
|
var prevTag;
|
|
|
|
|
|
|
|
|
|
function removeOverlay()
|
|
|
|
|
{
|
|
|
|
|
$("#loading_overlay").removeClass("overlay");
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
function reload()
|
|
|
|
|
{
|
2018-12-27 23:11:32 +01:00
|
|
|
|
location.reload();
|
2017-01-17 21:53:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function storageComp()
|
|
|
|
|
{
|
|
|
|
|
if (typeof(Storage) !== "undefined")
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
function getStorage(item, session)
|
2017-01-17 21:53:35 +01:00
|
|
|
|
{
|
2017-02-08 14:36:28 +01:00
|
|
|
|
if(storageComp())
|
|
|
|
|
{
|
|
|
|
|
if(session === true)
|
|
|
|
|
return sessionStorage.getItem(item);
|
|
|
|
|
else
|
|
|
|
|
return localStorage.getItem(item);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
2017-01-17 21:53:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
function setStorage(item, value, session)
|
2017-01-17 21:53:35 +01:00
|
|
|
|
{
|
2017-02-08 14:36:28 +01:00
|
|
|
|
if(storageComp())
|
|
|
|
|
{
|
|
|
|
|
if(session === true)
|
|
|
|
|
sessionStorage.setItem(item, value);
|
|
|
|
|
else
|
|
|
|
|
localStorage.setItem(item, value);
|
|
|
|
|
}
|
2017-01-17 21:53:35 +01:00
|
|
|
|
}
|
2016-09-03 15:54:33 +02:00
|
|
|
|
|
2016-12-18 19:00:14 +01:00
|
|
|
|
function debugMessage(msg)
|
|
|
|
|
{
|
2019-06-05 18:19:08 +02:00
|
|
|
|
if (window.debugMessagesActive)
|
2016-12-18 19:00:14 +01:00
|
|
|
|
{
|
|
|
|
|
console.log(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
|
function updateSessions()
|
|
|
|
|
{
|
2019-06-05 18:19:08 +02:00
|
|
|
|
var sess = window.serverInfo.sessions;
|
2018-12-27 23:11:32 +01:00
|
|
|
|
if (sess.length)
|
|
|
|
|
{
|
2019-06-05 18:19:08 +02:00
|
|
|
|
window.wSess = [];
|
2018-12-27 23:11:32 +01:00
|
|
|
|
for(var i = 0; i<sess.length; i++)
|
|
|
|
|
{
|
|
|
|
|
if(sess[i].type == "_hyperiond-http._tcp.")
|
|
|
|
|
{
|
2019-06-05 18:19:08 +02:00
|
|
|
|
window.wSess.push(sess[i]);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
|
if (window.wSess.length > 1)
|
2018-12-27 23:11:32 +01:00
|
|
|
|
$('#btn_instanceswitch').toggle(true);
|
|
|
|
|
else
|
|
|
|
|
$('#btn_instanceswitch').toggle(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-02 11:52:27 +01:00
|
|
|
|
function validateDuration(d)
|
|
|
|
|
{
|
|
|
|
|
if(typeof d === "undefined" || d < 0)
|
2019-06-05 18:19:08 +02:00
|
|
|
|
return 0;
|
2017-03-02 11:52:27 +01:00
|
|
|
|
else
|
|
|
|
|
return d *= 1000;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
function getHashtag()
|
2016-09-03 15:54:33 +02:00
|
|
|
|
{
|
2017-02-08 14:36:28 +01:00
|
|
|
|
if(getStorage('lasthashtag', true) != null)
|
|
|
|
|
return getStorage('lasthashtag', true);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var tag = document.URL;
|
|
|
|
|
tag = tag.substr(tag.indexOf("#") + 1);
|
|
|
|
|
if(tag == "" || typeof tag === "undefined" || tag.startsWith("http"))
|
|
|
|
|
tag = "dashboard"
|
|
|
|
|
return tag;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-01 19:47:07 +01:00
|
|
|
|
function loadContent(event, forceRefresh)
|
2017-02-08 14:36:28 +01:00
|
|
|
|
{
|
|
|
|
|
var tag;
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
if(typeof event != "undefined")
|
2018-12-27 23:11:32 +01:00
|
|
|
|
{
|
2017-02-08 14:36:28 +01:00
|
|
|
|
tag = event.currentTarget.hash;
|
|
|
|
|
tag = tag.substr(tag.indexOf("#") + 1);
|
|
|
|
|
setStorage('lasthashtag', tag, true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
tag = getHashtag();
|
|
|
|
|
|
2019-01-01 19:47:07 +01:00
|
|
|
|
if(forceRefresh || prevTag != tag)
|
2016-09-03 15:54:33 +02:00
|
|
|
|
{
|
2017-02-08 14:36:28 +01:00
|
|
|
|
prevTag = tag;
|
|
|
|
|
$("#page-content").off();
|
|
|
|
|
$("#page-content").load("/content/"+tag+".html", function(response,status,xhr){
|
|
|
|
|
if(status == "error")
|
2019-06-05 18:19:08 +02:00
|
|
|
|
{
|
2017-02-28 17:53:41 +01:00
|
|
|
|
$("#page-content").html('<h3>'+$.i18n('info_404')+'</h3>');
|
2017-02-08 14:36:28 +01:00
|
|
|
|
removeOverlay();
|
2019-06-05 18:19:08 +02:00
|
|
|
|
}
|
2019-07-29 19:39:05 +02:00
|
|
|
|
updateUiOnInstance(window.currentHyperionInstance);
|
2017-02-08 14:36:28 +01:00
|
|
|
|
});
|
2016-09-03 15:54:33 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-05 17:26:29 +02:00
|
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
|
function getInstanceNameByIndex(index)
|
|
|
|
|
{
|
|
|
|
|
var instData = window.serverInfo.instance
|
|
|
|
|
for(var key in instData)
|
|
|
|
|
{
|
|
|
|
|
if(instData[key].instance == index)
|
|
|
|
|
return instData[key].friendly_name;
|
|
|
|
|
}
|
|
|
|
|
return "unknown"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateHyperionInstanceListing()
|
|
|
|
|
{
|
|
|
|
|
var data = window.serverInfo.instance.filter(entry => entry.running);
|
|
|
|
|
$('#hyp_inst_listing').html("");
|
|
|
|
|
for(var key in data)
|
|
|
|
|
{
|
|
|
|
|
var currInstMarker = (data[key].instance == window.currentHyperionInstance) ? "component-on" : "";
|
|
|
|
|
|
|
|
|
|
var html = '<li id="hyperioninstance_'+data[key].instance+'"> \
|
|
|
|
|
<a> \
|
|
|
|
|
<div> \
|
|
|
|
|
<i class="fa fa-circle fa-fw '+currInstMarker+'"></i> \
|
|
|
|
|
<span>'+data[key].friendly_name+'</span> \
|
|
|
|
|
</div> \
|
|
|
|
|
</a> \
|
|
|
|
|
</li> '
|
|
|
|
|
|
|
|
|
|
if(data.length-1 > key)
|
|
|
|
|
html += '<li class="divider"></li>'
|
|
|
|
|
|
|
|
|
|
$('#hyp_inst_listing').append(html);
|
|
|
|
|
|
|
|
|
|
$('#hyperioninstance_'+data[key].instance).off().on("click",function(e){
|
|
|
|
|
var inst = e.currentTarget.id.split("_")[1]
|
|
|
|
|
requestInstanceSwitch(inst)
|
|
|
|
|
window.currentHyperionInstance = inst;
|
|
|
|
|
window.currentHyperionInstanceName = getInstanceNameByIndex(inst);
|
|
|
|
|
updateHyperionInstanceListing()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-29 19:39:05 +02:00
|
|
|
|
function updateUiOnInstance(inst)
|
|
|
|
|
{
|
|
|
|
|
if(inst != 0)
|
|
|
|
|
{
|
|
|
|
|
var currentURL = $(location).attr("href");
|
|
|
|
|
if(currentURL.indexOf('#conf_network') != -1 || currentURL.indexOf('#update') != -1 || currentURL.indexOf('#conf_webconfig') != -1 || currentURL.indexOf('#conf_grabber') != -1 || currentURL.indexOf('#conf_logging') != -1)
|
|
|
|
|
$("#hyperion_global_setting_notify").fadeIn("fast");
|
|
|
|
|
else
|
|
|
|
|
$("#hyperion_global_setting_notify").attr("style", "display:none");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$("#hyperion_global_setting_notify").fadeOut("fast");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-06 10:14:54 +02:00
|
|
|
|
function loadContentTo(containerId, fileName)
|
|
|
|
|
{
|
|
|
|
|
$(containerId).load("/content/"+fileName+".html");
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-05 17:26:29 +02:00
|
|
|
|
function toggleClass(obj,class1,class2)
|
|
|
|
|
{
|
|
|
|
|
if ( $(obj).hasClass(class1))
|
|
|
|
|
{
|
|
|
|
|
$(obj).removeClass(class1);
|
|
|
|
|
$(obj).addClass(class2);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$(obj).removeClass(class2);
|
|
|
|
|
$(obj).addClass(class1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setClassByBool(obj,enable,class1,class2)
|
|
|
|
|
{
|
|
|
|
|
if (enable)
|
|
|
|
|
{
|
|
|
|
|
$(obj).removeClass(class1);
|
|
|
|
|
$(obj).addClass(class2);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$(obj).removeClass(class2);
|
|
|
|
|
$(obj).addClass(class1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
function showInfoDialog(type,header,message)
|
2018-12-27 23:11:32 +01:00
|
|
|
|
{
|
2019-08-04 20:19:33 +02:00
|
|
|
|
if (type=="success")
|
|
|
|
|
{
|
2017-01-17 21:53:35 +01:00
|
|
|
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-check modal-icon-check">');
|
|
|
|
|
if(header == "")
|
|
|
|
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_success_title')+'</h4>');
|
|
|
|
|
$('#id_footer').html('<button type="button" class="btn btn-success" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
2016-10-27 23:42:24 +02:00
|
|
|
|
}
|
2019-08-04 20:19:33 +02:00
|
|
|
|
else if (type=="warning")
|
|
|
|
|
{
|
2017-01-17 21:53:35 +01:00
|
|
|
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
|
|
|
|
|
if(header == "")
|
|
|
|
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_warning_title')+'</h4>');
|
|
|
|
|
$('#id_footer').html('<button type="button" class="btn btn-warning" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
2016-10-27 23:42:24 +02:00
|
|
|
|
}
|
2019-08-04 20:19:33 +02:00
|
|
|
|
else if (type=="error")
|
|
|
|
|
{
|
2017-01-17 21:53:35 +01:00
|
|
|
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-error">');
|
|
|
|
|
if(header == "")
|
|
|
|
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_error_title')+'</h4>');
|
|
|
|
|
$('#id_footer').html('<button type="button" class="btn btn-danger" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
2018-12-27 23:11:32 +01:00
|
|
|
|
}
|
2019-08-04 20:19:33 +02:00
|
|
|
|
else if (type == "select")
|
|
|
|
|
{
|
2017-01-17 21:53:35 +01:00
|
|
|
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
2017-02-08 14:36:28 +01:00
|
|
|
|
$('#id_footer').html('<button type="button" id="id_btn_saveset" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_saveandreload')+'</button>');
|
2017-01-17 21:53:35 +01:00
|
|
|
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
2016-12-08 23:39:41 +01:00
|
|
|
|
}
|
2019-08-04 20:19:33 +02:00
|
|
|
|
else if (type == "iswitch")
|
|
|
|
|
{
|
2017-03-24 10:17:36 +01:00
|
|
|
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
|
|
|
|
$('#id_footer').html('<button type="button" id="id_btn_saveset" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-fw fa-exchange"></i>'+$.i18n('general_btn_iswitch')+'</button>');
|
|
|
|
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
|
|
|
|
}
|
2019-08-04 20:19:33 +02:00
|
|
|
|
else if (type == "uilock")
|
|
|
|
|
{
|
2017-01-17 21:53:35 +01:00
|
|
|
|
$('#id_body').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
|
|
|
|
$('#id_footer').html('<b>'+$.i18n('InfoDialog_nowrite_foottext')+'</b>');
|
|
|
|
|
}
|
2019-08-04 20:19:33 +02:00
|
|
|
|
else if (type == "import")
|
|
|
|
|
{
|
2017-01-17 21:53:35 +01:00
|
|
|
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
|
|
|
|
|
$('#id_footer').html('<button type="button" id="id_btn_import" class="btn btn-warning" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_saverestart')+'</button>');
|
|
|
|
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
2019-07-14 22:43:22 +02:00
|
|
|
|
}
|
2019-08-04 20:19:33 +02:00
|
|
|
|
else if (type == "delInst")
|
|
|
|
|
{
|
|
|
|
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-remove modal-icon-warning">');
|
2019-07-14 22:43:22 +02:00
|
|
|
|
$('#id_footer').html('<button type="button" id="id_btn_yes" class="btn btn-warning" data-dismiss="modal"><i class="fa fa-fw fa-trash"></i>'+$.i18n('general_btn_yes')+'</button>');
|
|
|
|
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
2016-12-21 18:24:03 +01:00
|
|
|
|
}
|
2019-08-04 20:19:33 +02:00
|
|
|
|
else if (type == "renInst")
|
|
|
|
|
{
|
2019-08-05 20:44:44 +02:00
|
|
|
|
$('#id_body_rename').html('<i style="margin-bottom:20px" class="fa fa-pencil modal-icon-edit"><br>');
|
|
|
|
|
$('#id_body_rename').append('<h4>'+header+'</h4>');
|
|
|
|
|
$('#id_body_rename').append('<input class="form-control" id="renInst_name" type="text" value="'+message+'">');
|
|
|
|
|
$('#id_footer_rename').html('<button type="button" id="id_btn_ok" class="btn btn-success" data-dismiss-modal="#modal_dialog_rename" disabled><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_ok')+'</button>');
|
|
|
|
|
$('#id_footer_rename').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
2019-08-04 20:19:33 +02:00
|
|
|
|
}
|
2017-02-08 14:36:28 +01:00
|
|
|
|
else if (type == "checklist")
|
|
|
|
|
{
|
|
|
|
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
|
|
|
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_checklist_title')+'</h4>');
|
2019-08-04 20:19:33 +02:00
|
|
|
|
$('#id_body').append(header);
|
2017-02-08 14:36:28 +01:00
|
|
|
|
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
|
|
|
|
}
|
2019-07-12 16:54:26 +02:00
|
|
|
|
else if (type == "newToken")
|
|
|
|
|
{
|
|
|
|
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
|
|
|
|
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
|
|
|
|
}
|
|
|
|
|
else if (type == "grantToken")
|
|
|
|
|
{
|
|
|
|
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
|
|
|
|
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal" id="tok_grant_acc">'+$.i18n('general_btn_grantAccess')+'</button>');
|
|
|
|
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal" id="tok_deny_acc">'+$.i18n('general_btn_denyAccess')+'</button>');
|
|
|
|
|
}
|
2019-06-26 18:17:39 +02:00
|
|
|
|
|
2019-08-04 20:19:33 +02:00
|
|
|
|
if(type != "renInst")
|
|
|
|
|
{
|
|
|
|
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+header+'</h4>');
|
|
|
|
|
$('#id_body').append(message);
|
|
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-03-24 10:17:36 +01:00
|
|
|
|
if(type == "select" || type == "iswitch")
|
2017-01-17 21:53:35 +01:00
|
|
|
|
$('#id_body').append('<select id="id_select" class="form-control" style="margin-top:10px;width:auto;"></select>');
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2019-08-05 20:44:44 +02:00
|
|
|
|
|
|
|
|
|
$(type == "renInst" ? "#modal_dialog_rename" : "#modal_dialog").modal({
|
2016-12-08 23:39:41 +01:00
|
|
|
|
backdrop : "static",
|
|
|
|
|
keyboard: false,
|
|
|
|
|
show: true
|
|
|
|
|
});
|
2019-08-05 20:44:44 +02:00
|
|
|
|
|
|
|
|
|
$(document).on('click', '[data-dismiss-modal]', function () {
|
|
|
|
|
var target = $(this).attr('data-dismiss-modal');
|
|
|
|
|
$(target).modal('hide');
|
|
|
|
|
});
|
2016-09-06 10:14:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
function createHintH(type, text, container)
|
|
|
|
|
{
|
2019-06-05 18:19:08 +02:00
|
|
|
|
type = String(type);
|
|
|
|
|
if(type == "intro")
|
2017-02-08 14:36:28 +01:00
|
|
|
|
tclass = "introd";
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
$('#'+container).prepend('<div class="'+tclass+'"><h4 style="font-size:16px">'+text+'</h4><hr/></div>');
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 21:33:40 +02:00
|
|
|
|
function createHint(type, text, container, buttonid, buttontxt)
|
2017-02-08 14:36:28 +01:00
|
|
|
|
{
|
|
|
|
|
var fe, tclass;
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
if(type == "intro")
|
|
|
|
|
{
|
|
|
|
|
fe = '';
|
|
|
|
|
tclass = "intro-hint";
|
|
|
|
|
}
|
|
|
|
|
else if(type == "info")
|
|
|
|
|
{
|
|
|
|
|
fe = '<div style="font-size:25px;text-align:center"><i class="fa fa-info"></i></div><div style="text-align:center;font-size:13px">Information</div>';
|
|
|
|
|
tclass = "info-hint";
|
|
|
|
|
}
|
|
|
|
|
else if(type == "wizard")
|
2018-12-27 23:11:32 +01:00
|
|
|
|
{
|
2017-02-08 14:36:28 +01:00
|
|
|
|
fe = '<div style="font-size:25px;text-align:center"><i class="fa fa-magic"></i></div><div style="text-align:center;font-size:13px">Information</div>';
|
|
|
|
|
tclass = "wizard-hint";
|
|
|
|
|
}
|
|
|
|
|
else if(type == "warning")
|
2018-12-27 23:11:32 +01:00
|
|
|
|
{
|
2017-02-08 14:36:28 +01:00
|
|
|
|
fe = '<div style="font-size:25px;text-align:center"><i class="fa fa-info"></i></div><div style="text-align:center;font-size:13px">Information</div>';
|
|
|
|
|
tclass = "warning-hint";
|
|
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-04-07 21:33:40 +02:00
|
|
|
|
if(buttonid)
|
|
|
|
|
buttonid = '<p><button id="'+buttonid+'" class="btn btn-wizard" style="margin-top:15px;">'+text+'</button></p>';
|
|
|
|
|
else
|
|
|
|
|
buttonid = "";
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-04-07 21:33:40 +02:00
|
|
|
|
if(type == "intro")
|
|
|
|
|
$('#'+container).prepend('<div class="bs-callout bs-callout-primary" style="margin-top:0px"><h4>'+$.i18n("conf_helptable_expl")+'</h4>'+text+'</div>');
|
|
|
|
|
else if(type == "wizard")
|
|
|
|
|
$('#'+container).prepend('<div class="bs-callout bs-callout-wizard" style="margin-top:0px"><h4>'+$.i18n("wiz_wizavail")+'</h4>'+$.i18n('wiz_guideyou',text)+buttonid+'</div>');
|
2017-02-08 14:36:28 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
createTable('','htb',container, true, tclass);
|
|
|
|
|
$('#'+container+' .htb').append(createTableRow([fe ,text],false,true));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 14:36:23 +02:00
|
|
|
|
function createEffHint(title, text)
|
|
|
|
|
{
|
|
|
|
|
return '<div class="bs-callout bs-callout-primary" style="margin-top:0px"><h4>'+title+'</h4>'+text+'</div>';
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-28 17:53:41 +01:00
|
|
|
|
function valValue(id,value,min,max)
|
|
|
|
|
{
|
2017-03-24 10:17:36 +01:00
|
|
|
|
if(typeof max === 'undefined' || max == "")
|
|
|
|
|
max = 999999;
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
|
|
|
|
if(Number(value) > Number(max))
|
2017-02-28 17:53:41 +01:00
|
|
|
|
{
|
2017-03-24 10:17:36 +01:00
|
|
|
|
$('#'+id).val(max);
|
|
|
|
|
showInfoDialog("warning","",$.i18n('edt_msg_error_maximum_incl',max));
|
|
|
|
|
return max;
|
|
|
|
|
}
|
2017-04-03 05:19:05 +02:00
|
|
|
|
else if(Number(value) < Number(min))
|
2017-03-24 10:17:36 +01:00
|
|
|
|
{
|
|
|
|
|
$('#'+id).val(min);
|
|
|
|
|
showInfoDialog("warning","",$.i18n('edt_msg_error_minimum_incl',min));
|
|
|
|
|
return min;
|
|
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
return value;
|
2017-02-28 17:53:41 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function readImg(input,cb)
|
|
|
|
|
{
|
|
|
|
|
if (input.files && input.files[0]) {
|
|
|
|
|
var reader = new FileReader();
|
2019-08-21 16:10:35 +02:00
|
|
|
|
// inject fileName property
|
|
|
|
|
reader.fileName = input.files[0].name
|
2017-02-28 17:53:41 +01:00
|
|
|
|
|
|
|
|
|
reader.onload = function (e) {
|
2019-08-21 16:10:35 +02:00
|
|
|
|
cb(e.target.result, e.target.fileName);
|
2017-02-28 17:53:41 +01:00
|
|
|
|
}
|
|
|
|
|
reader.readAsDataURL(input.files[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-09 10:23:04 +02:00
|
|
|
|
function isJsonString(str)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2016-09-06 10:14:54 +02:00
|
|
|
|
JSON.parse(str);
|
2016-10-09 10:23:04 +02:00
|
|
|
|
}
|
|
|
|
|
catch (e)
|
|
|
|
|
{
|
2016-09-06 10:14:54 +02:00
|
|
|
|
return e;
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2016-10-09 10:23:04 +02:00
|
|
|
|
|
2017-07-30 14:36:23 +02:00
|
|
|
|
function createJsonEditor(container,schema,setconfig,usePanel,arrayre)
|
2016-10-09 10:23:04 +02:00
|
|
|
|
{
|
|
|
|
|
$('#'+container).off();
|
|
|
|
|
$('#'+container).html("");
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-07-30 14:36:23 +02:00
|
|
|
|
if (typeof arrayre === 'undefined')
|
|
|
|
|
arrayre = true;
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2016-10-10 23:15:50 +02:00
|
|
|
|
var editor = new JSONEditor(document.getElementById(container),
|
2016-10-09 10:23:04 +02:00
|
|
|
|
{
|
|
|
|
|
theme: 'bootstrap3',
|
|
|
|
|
iconlib: "fontawesome4",
|
|
|
|
|
disable_collapse: 'true',
|
|
|
|
|
form_name_root: 'sa',
|
2017-07-30 14:36:23 +02:00
|
|
|
|
disable_edit_json: true,
|
|
|
|
|
disable_properties: true,
|
|
|
|
|
disable_array_reorder: arrayre,
|
|
|
|
|
no_additional_properties: true,
|
|
|
|
|
disable_array_delete_all_rows: true,
|
|
|
|
|
disable_array_delete_last_row: true,
|
2017-01-17 21:53:35 +01:00
|
|
|
|
access: storedAccess,
|
2016-10-10 23:15:50 +02:00
|
|
|
|
schema: {
|
|
|
|
|
title:'',
|
|
|
|
|
properties: schema
|
|
|
|
|
}
|
2016-10-09 10:23:04 +02:00
|
|
|
|
});
|
2017-07-30 14:36:23 +02:00
|
|
|
|
|
2016-12-21 18:24:03 +01:00
|
|
|
|
if(usePanel)
|
|
|
|
|
{
|
|
|
|
|
$('#'+container+' .well').first().removeClass('well well-sm');
|
2017-07-30 14:36:23 +02:00
|
|
|
|
$('#'+container+' h4').first().remove();
|
2016-12-21 18:24:03 +01:00
|
|
|
|
$('#'+container+' .well').first().removeClass('well well-sm');
|
|
|
|
|
}
|
2016-10-10 23:15:50 +02:00
|
|
|
|
|
|
|
|
|
if (setconfig)
|
|
|
|
|
{
|
|
|
|
|
for(var key in editor.root.editors)
|
|
|
|
|
{
|
2019-06-05 18:19:08 +02:00
|
|
|
|
editor.getEditor("root."+key).setValue( window.serverConfig[key] );
|
2016-10-10 23:15:50 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return editor;
|
2016-10-09 10:23:04 +02:00
|
|
|
|
}
|
2016-11-30 17:32:12 +01:00
|
|
|
|
|
2017-04-07 21:33:40 +02:00
|
|
|
|
function buildWL(link,linkt,cl)
|
2018-12-27 23:11:32 +01:00
|
|
|
|
{
|
2017-04-07 21:33:40 +02:00
|
|
|
|
var baseLink = "https://docs.hyperion-project.org/";
|
|
|
|
|
var lang;
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-04-07 21:33:40 +02:00
|
|
|
|
if(typeof linkt == "undefined")
|
|
|
|
|
linkt = "Placeholder";
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-04-07 21:33:40 +02:00
|
|
|
|
if(storedLang == "de" || navigator.locale == "de")
|
|
|
|
|
lang = "de";
|
|
|
|
|
else
|
|
|
|
|
lang = "en";
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-04-07 21:33:40 +02:00
|
|
|
|
if(cl === true)
|
|
|
|
|
{
|
|
|
|
|
linkt = $.i18n(linkt);
|
|
|
|
|
return '<div class="bs-callout bs-callout-primary"><h4>'+linkt+'</h4>'+$.i18n('general_wiki_moreto',linkt)+': <a href="'+baseLink+lang+'/'+link+'" target="_blank">'+linkt+'<a></div>'
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return ': <a href="'+baseLink+lang+'/'+link+'" target="_blank">'+linkt+'<a>';
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
function rgbToHex(rgb)
|
|
|
|
|
{
|
|
|
|
|
if(rgb.length == 3)
|
|
|
|
|
{
|
|
|
|
|
return "#" +
|
|
|
|
|
("0" + parseInt(rgb[0],10).toString(16)).slice(-2) +
|
|
|
|
|
("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
|
2018-12-27 23:11:32 +01:00
|
|
|
|
("0" + parseInt(rgb[2],10).toString(16)).slice(-2);
|
2017-02-08 14:36:28 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
debugMessage('rgbToHex: Given rgb is no array or has wrong length');
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 21:33:40 +02:00
|
|
|
|
function hexToRgb(hex) {
|
|
|
|
|
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
|
|
|
return result ? {
|
|
|
|
|
r: parseInt(result[1], 16),
|
|
|
|
|
g: parseInt(result[2], 16),
|
|
|
|
|
b: parseInt(result[3], 16)
|
|
|
|
|
} : null;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
|
/*
|
|
|
|
|
Show a notification
|
|
|
|
|
@param type Valid types are "info","success","warning","danger"
|
|
|
|
|
@param message The message to show
|
|
|
|
|
@param title A title (optional)
|
|
|
|
|
*/
|
|
|
|
|
function showNotification(type, message, title="")
|
|
|
|
|
{
|
|
|
|
|
if(title == "")
|
|
|
|
|
{
|
|
|
|
|
switch(type)
|
|
|
|
|
{
|
|
|
|
|
case "info":
|
|
|
|
|
title = $.i18n('infoDialog_general_info_title');
|
|
|
|
|
break;
|
|
|
|
|
case "success":
|
|
|
|
|
title = $.i18n('infoDialog_general_success_title');
|
|
|
|
|
break;
|
|
|
|
|
case "warning":
|
|
|
|
|
title = $.i18n('infoDialog_general_warning_title');
|
|
|
|
|
break;
|
|
|
|
|
case "danger":
|
|
|
|
|
title = $.i18n('infoDialog_general_error_title');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.notify({
|
|
|
|
|
// options
|
|
|
|
|
title: title,
|
|
|
|
|
message: message
|
|
|
|
|
},{
|
|
|
|
|
// settings
|
|
|
|
|
type: type,
|
|
|
|
|
animate: {
|
|
|
|
|
enter: 'animated fadeInRight',
|
|
|
|
|
exit: 'animated fadeOutRight'
|
|
|
|
|
},
|
|
|
|
|
mouse_over : 'pause',
|
|
|
|
|
template: '<div data-notify="container" class="bg-w col-xs-11 col-sm-3 bs-callout bs-callout-{0}" role="alert">' +
|
|
|
|
|
'<button type="button" aria-hidden="true" class="close" data-notify="dismiss">×</button>' +
|
|
|
|
|
'<span data-notify="icon"></span> ' +
|
|
|
|
|
'<h4 data-notify="title">{1}</h4> ' +
|
|
|
|
|
'<span data-notify="message">{2}</span>' +
|
|
|
|
|
'<div class="progress" data-notify="progressbar">' +
|
|
|
|
|
'<div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' +
|
|
|
|
|
'</div>' +
|
|
|
|
|
'<a href="{3}" target="{4}" data-notify="url"></a>' +
|
|
|
|
|
'</div>'
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-04-07 21:33:40 +02:00
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
function createCP(id, color, cb)
|
|
|
|
|
{
|
|
|
|
|
if(Array.isArray(color))
|
|
|
|
|
color = rgbToHex(color);
|
|
|
|
|
else if(color == "undefined")
|
|
|
|
|
color = "#AA3399";
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
if(color.startsWith("#"))
|
|
|
|
|
{
|
|
|
|
|
$('#'+id).colorpicker({
|
|
|
|
|
format: 'rgb',
|
|
|
|
|
customClass: 'colorpicker-2x',
|
|
|
|
|
color: color,
|
|
|
|
|
sliders: {
|
|
|
|
|
saturation: {
|
|
|
|
|
maxLeft: 200,
|
|
|
|
|
maxTop: 200
|
|
|
|
|
},
|
|
|
|
|
hue: {
|
|
|
|
|
maxTop: 200
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$('#'+id).colorpicker().on('changeColor', function(e) {
|
2019-06-05 18:19:08 +02:00
|
|
|
|
var rgb = e.color.toRGB();
|
|
|
|
|
var hex = e.color.toHex();
|
2017-02-08 14:36:28 +01:00
|
|
|
|
cb(rgb,hex,e);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
debugMessage('createCP: Given color is not legit');
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
// Creates a table with thead and tbody ids
|
2017-02-08 14:36:28 +01:00
|
|
|
|
// @param string hid : a class for thead
|
|
|
|
|
// @param string bid : a class for tbody
|
2017-01-17 21:53:35 +01:00
|
|
|
|
// @param string cont : a container id to html() the table
|
2017-02-08 14:36:28 +01:00
|
|
|
|
// @param string bless: if true the table is borderless
|
|
|
|
|
function createTable(hid, bid, cont, bless, tclass)
|
2017-01-17 21:53:35 +01:00
|
|
|
|
{
|
|
|
|
|
var table = document.createElement('table');
|
|
|
|
|
var thead = document.createElement('thead');
|
|
|
|
|
var tbody = document.createElement('tbody');
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
table.className = "table";
|
2017-02-08 14:36:28 +01:00
|
|
|
|
if(bless === true)
|
|
|
|
|
table.className += " borderless";
|
|
|
|
|
if(typeof tclass !== "undefined")
|
|
|
|
|
table.className += " "+tclass;
|
2017-01-17 21:53:35 +01:00
|
|
|
|
table.style.marginBottom = "0px";
|
2017-02-08 14:36:28 +01:00
|
|
|
|
if(hid != "")
|
|
|
|
|
thead.className = hid;
|
|
|
|
|
tbody.className = bid;
|
|
|
|
|
if(hid != "")
|
|
|
|
|
table.appendChild(thead);
|
2017-01-17 21:53:35 +01:00
|
|
|
|
table.appendChild(tbody);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
$('#'+cont).append(table);
|
2017-01-17 21:53:35 +01:00
|
|
|
|
}
|
2016-12-21 18:24:03 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
// Creates a table row <tr>
|
|
|
|
|
// @param array list :innerHTML content for <td>/<th>
|
|
|
|
|
// @param bool head :if null or false it's body
|
2018-12-27 23:11:32 +01:00
|
|
|
|
// @param bool align :if null or false no alignment
|
2017-01-17 21:53:35 +01:00
|
|
|
|
//
|
|
|
|
|
// @return : <tr> with <td> or <th> as child(s)
|
|
|
|
|
function createTableRow(list, head, align)
|
|
|
|
|
{
|
|
|
|
|
var row = document.createElement('tr');
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
for(var i = 0; i < list.length; i++)
|
|
|
|
|
{
|
|
|
|
|
if(head === true)
|
|
|
|
|
var el = document.createElement('th');
|
|
|
|
|
else
|
|
|
|
|
var el = document.createElement('td');
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
if(align)
|
|
|
|
|
el.style.verticalAlign = "middle";
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
el.innerHTML = list[i];
|
|
|
|
|
row.appendChild(el);
|
|
|
|
|
}
|
|
|
|
|
return row;
|
|
|
|
|
}
|
2016-12-21 18:24:03 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
function createRow(id)
|
|
|
|
|
{
|
|
|
|
|
var el = document.createElement('div');
|
|
|
|
|
el.className = "row";
|
|
|
|
|
el.setAttribute('id', id);
|
|
|
|
|
return el;
|
2016-12-21 18:24:03 +01:00
|
|
|
|
}
|
2017-01-17 21:53:35 +01:00
|
|
|
|
|
|
|
|
|
function createOptPanel(phicon, phead, bodyid, footerid)
|
|
|
|
|
{
|
|
|
|
|
phead = '<i class="fa '+phicon+' fa-fw"></i>'+phead;
|
2019-06-05 18:19:08 +02:00
|
|
|
|
var pfooter = document.createElement('button');
|
2017-02-08 14:36:28 +01:00
|
|
|
|
pfooter.className = "btn btn-primary";
|
2017-01-17 21:53:35 +01:00
|
|
|
|
pfooter.setAttribute("id", footerid);
|
|
|
|
|
pfooter.innerHTML = '<i class="fa fa-fw fa-save"></i>'+$.i18n('general_button_savesettings');
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
return createPanel(phead, "", pfooter, "panel-default", bodyid);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
function sortProperties(list)
|
|
|
|
|
{
|
2019-06-05 18:19:08 +02:00
|
|
|
|
for(var key in list)
|
2017-02-08 14:36:28 +01:00
|
|
|
|
{
|
|
|
|
|
list[key].key = key;
|
|
|
|
|
}
|
|
|
|
|
list = $.map(list, function(value, index) {
|
|
|
|
|
return [value];
|
|
|
|
|
});
|
|
|
|
|
return list.sort(function(a,b) {
|
|
|
|
|
return a.propertyOrder - b.propertyOrder;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-21 18:24:03 +01:00
|
|
|
|
function createHelpTable(list, phead){
|
|
|
|
|
var table = document.createElement('table');
|
|
|
|
|
var thead = document.createElement('thead');
|
|
|
|
|
var tbody = document.createElement('tbody');
|
2017-02-08 14:36:28 +01:00
|
|
|
|
list = sortProperties(list);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
phead = '<i class="fa fa-fw fa-info-circle"></i>'+phead+' '+$.i18n("conf_helptable_expl");
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2016-12-21 18:24:03 +01:00
|
|
|
|
table.className = 'table table-hover borderless';
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
thead.appendChild(createTableRow([$.i18n('conf_helptable_option'), $.i18n('conf_helptable_expl')], true, false));
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
|
for (var key in list)
|
2017-02-08 14:36:28 +01:00
|
|
|
|
{
|
|
|
|
|
if(list[key].access != 'system')
|
2017-01-17 21:53:35 +01:00
|
|
|
|
{
|
2019-02-03 14:36:57 +01:00
|
|
|
|
// break one iteration (in the loop), if the schema has the entry hidden=true
|
|
|
|
|
if ("options" in list[key] && "hidden" in list[key].options && (list[key].options.hidden))
|
|
|
|
|
continue;
|
2019-08-04 20:19:33 +02:00
|
|
|
|
if ("access" in list[key] && ((list[key].access == "advanced" && storedAccess == "default") || (list[key].access == "expert" && storedAccess != "expert")))
|
|
|
|
|
continue;
|
2017-02-08 14:36:28 +01:00
|
|
|
|
var text = list[key].title.replace('title', 'expl');
|
|
|
|
|
tbody.appendChild(createTableRow([$.i18n(list[key].title), $.i18n(text)], false, false));
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
|
if(list[key].items && list[key].items.properties)
|
2017-01-17 21:53:35 +01:00
|
|
|
|
{
|
2017-02-08 14:36:28 +01:00
|
|
|
|
var ilist = sortProperties(list[key].items.properties);
|
2019-06-05 18:19:08 +02:00
|
|
|
|
for (var ikey in ilist)
|
2017-01-17 21:53:35 +01:00
|
|
|
|
{
|
2019-02-03 14:36:57 +01:00
|
|
|
|
// break one iteration (in the loop), if the schema has the entry hidden=true
|
|
|
|
|
if ("options" in ilist[ikey] && "hidden" in ilist[ikey].options && (ilist[ikey].options.hidden))
|
|
|
|
|
continue;
|
2019-08-04 20:19:33 +02:00
|
|
|
|
if ("access" in ilist[ikey] && ((ilist[ikey].access == "advanced" && storedAccess == "default") || (ilist[ikey].access == "expert" && storedAccess != "expert")))
|
|
|
|
|
continue;
|
2017-02-08 14:36:28 +01:00
|
|
|
|
var itext = ilist[ikey].title.replace('title', 'expl');
|
|
|
|
|
tbody.appendChild(createTableRow([$.i18n(ilist[ikey].title), $.i18n(itext)], false, false));
|
|
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
}
|
2016-12-21 18:24:03 +01:00
|
|
|
|
}
|
2017-02-08 14:36:28 +01:00
|
|
|
|
}
|
2016-12-21 18:24:03 +01:00
|
|
|
|
table.appendChild(thead);
|
|
|
|
|
table.appendChild(tbody);
|
|
|
|
|
|
|
|
|
|
return createPanel(phead, table);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
function createPanel(head, body, footer, type, bodyid){
|
|
|
|
|
var cont = document.createElement('div');
|
2016-12-21 18:24:03 +01:00
|
|
|
|
var p = document.createElement('div');
|
|
|
|
|
var phead = document.createElement('div');
|
|
|
|
|
var pbody = document.createElement('div');
|
|
|
|
|
var pfooter = document.createElement('div');
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
cont.className = "col-lg-6";
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2016-12-21 18:24:03 +01:00
|
|
|
|
if(typeof type == 'undefined')
|
|
|
|
|
type = 'panel-default';
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2016-12-21 18:24:03 +01:00
|
|
|
|
p.className = 'panel '+type;
|
|
|
|
|
phead.className = 'panel-heading';
|
|
|
|
|
pbody.className = 'panel-body';
|
|
|
|
|
pfooter.className = 'panel-footer';
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2016-12-21 18:24:03 +01:00
|
|
|
|
phead.innerHTML = head;
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
if(typeof bodyid != 'undefined')
|
|
|
|
|
{
|
|
|
|
|
pfooter.style.textAlign = 'right';
|
2019-06-05 18:19:08 +02:00
|
|
|
|
pbody.setAttribute("id", bodyid);
|
2017-01-17 21:53:35 +01:00
|
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
if(typeof body != 'undefined' && body != "")
|
2016-12-21 18:24:03 +01:00
|
|
|
|
pbody.appendChild(body);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
if(typeof footer != 'undefined')
|
|
|
|
|
pfooter.appendChild(footer);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2016-12-21 18:24:03 +01:00
|
|
|
|
p.appendChild(phead);
|
|
|
|
|
p.appendChild(pbody);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2016-12-21 18:24:03 +01:00
|
|
|
|
if(typeof footer != 'undefined')
|
2017-01-17 21:53:35 +01:00
|
|
|
|
{
|
|
|
|
|
pfooter.style.textAlign = "right";
|
2016-12-21 18:24:03 +01:00
|
|
|
|
p.appendChild(pfooter);
|
2017-01-17 21:53:35 +01:00
|
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
cont.appendChild(p);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
|
return cont;
|
2016-12-21 18:24:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-05 11:10:44 +01:00
|
|
|
|
function createSelGroup(group)
|
|
|
|
|
{
|
2016-11-30 17:32:12 +01:00
|
|
|
|
var el = document.createElement('optgroup');
|
|
|
|
|
el.setAttribute('label', group);
|
2016-12-05 11:10:44 +01:00
|
|
|
|
return el;
|
2016-11-30 17:32:12 +01:00
|
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
|
2016-12-08 23:39:41 +01:00
|
|
|
|
function createSelOpt(opt, title)
|
2016-12-05 11:10:44 +01:00
|
|
|
|
{
|
2016-11-30 17:32:12 +01:00
|
|
|
|
var el = document.createElement('option');
|
|
|
|
|
el.setAttribute('value', opt);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
if (typeof title == 'undefined')
|
2016-12-08 23:39:41 +01:00
|
|
|
|
el.innerHTML = opt;
|
|
|
|
|
else
|
|
|
|
|
el.innerHTML = title;
|
2016-12-05 11:10:44 +01:00
|
|
|
|
return el;
|
2016-11-30 17:32:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 14:36:23 +02:00
|
|
|
|
function createSel(array, group, split)
|
2016-12-05 11:10:44 +01:00
|
|
|
|
{
|
2017-07-30 14:36:23 +02:00
|
|
|
|
if (array.length != 0)
|
2016-12-05 11:10:44 +01:00
|
|
|
|
{
|
|
|
|
|
var el = createSelGroup(group);
|
|
|
|
|
for(var i=0; i<array.length; i++)
|
|
|
|
|
{
|
2017-07-30 14:36:23 +02:00
|
|
|
|
var opt;
|
|
|
|
|
if(split)
|
|
|
|
|
{
|
|
|
|
|
opt = array[i].split(":")
|
|
|
|
|
opt = createSelOpt(opt[0],opt[1])
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
opt = createSelOpt(array[i])
|
2016-11-30 17:32:12 +01:00
|
|
|
|
el.appendChild(opt);
|
|
|
|
|
}
|
2016-12-05 11:10:44 +01:00
|
|
|
|
return el;
|
2016-11-30 17:32:12 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-04 19:32:23 +01:00
|
|
|
|
|
2016-12-05 11:10:44 +01:00
|
|
|
|
function performTranslation()
|
|
|
|
|
{
|
2016-12-21 18:24:03 +01:00
|
|
|
|
$('[data-i18n]').i18n();
|
2016-12-04 19:32:23 +01:00
|
|
|
|
}
|
2016-12-05 11:10:44 +01:00
|
|
|
|
|
|
|
|
|
function encode_utf8(s)
|
|
|
|
|
{
|
|
|
|
|
return unescape(encodeURIComponent(s));
|
|
|
|
|
}
|
2019-06-26 18:17:39 +02:00
|
|
|
|
|
|
|
|
|
function getReleases(callback)
|
|
|
|
|
{
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: window.gitHubReleaseApiUrl,
|
|
|
|
|
method: 'get',
|
|
|
|
|
error: function(XMLHttpRequest, textStatus, errorThrown)
|
|
|
|
|
{
|
|
|
|
|
callback(false);
|
|
|
|
|
},
|
|
|
|
|
success: function(releases)
|
|
|
|
|
{
|
|
|
|
|
window.gitHubVersionList = releases;
|
|
|
|
|
|
|
|
|
|
for(var i in releases)
|
|
|
|
|
{
|
|
|
|
|
if(releases[i].prerelease == true)
|
|
|
|
|
{
|
|
|
|
|
window.latestBetaVersion = releases[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: window.gitHubReleaseApiUrl + "/latest",
|
|
|
|
|
method: 'get',
|
|
|
|
|
error: function(XMLHttpRequest, textStatus, errorThrown)
|
|
|
|
|
{
|
|
|
|
|
callback(false);
|
|
|
|
|
},
|
|
|
|
|
success: function(latest)
|
|
|
|
|
{
|
|
|
|
|
window.latestStableVersion = latest;
|
|
|
|
|
|
2019-07-13 00:06:58 +02:00
|
|
|
|
if(window.serverConfig.general.watchedVersionBranch == "Beta" && window.latestStableVersion.tag_name.replace(/\./g, '') <= window.latestBetaVersion.tag_name.replace(/\./g, ''))
|
2019-06-26 18:17:39 +02:00
|
|
|
|
{
|
|
|
|
|
window.latestVersion = window.latestBetaVersion;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
window.latestVersion = window.latestStableVersion;
|
|
|
|
|
}
|
|
|
|
|
callback(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|