mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
priorities rework, webc update (#366)
* update * update * tabs test * update * test * ... * fix editor * update ui * fix visual glitch if help is off * fix fadecandy error and th [skip ci]
This commit is contained in:
@@ -1,3 +1,25 @@
|
||||
function reload()
|
||||
{
|
||||
location.reload();
|
||||
}
|
||||
|
||||
function storageComp()
|
||||
{
|
||||
if (typeof(Storage) !== "undefined")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function getStorage(item)
|
||||
{
|
||||
return localStorage.getItem(item);
|
||||
}
|
||||
|
||||
function setStorage(item, value)
|
||||
{
|
||||
localStorage.setItem(item, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
function debugMessage(msg)
|
||||
{
|
||||
@@ -24,8 +46,6 @@ function loadContentTo(containerId, fileName)
|
||||
$(containerId).load("/content/"+fileName+".html");
|
||||
}
|
||||
|
||||
|
||||
|
||||
function toggleClass(obj,class1,class2)
|
||||
{
|
||||
if ( $(obj).hasClass(class1))
|
||||
@@ -55,37 +75,46 @@ function setClassByBool(obj,enable,class1,class2)
|
||||
}
|
||||
}
|
||||
|
||||
function showInfoDialog(type,header,message,btnid)
|
||||
{
|
||||
if (type != 'select')
|
||||
$('#modal_select').toggle(false);
|
||||
else
|
||||
$('#modal_select').toggle(true);
|
||||
|
||||
$('#modal_dialog .modal-bodytitle').html(header);
|
||||
$('#modal_dialog .modal-bodycontent').html(message);
|
||||
|
||||
function showInfoDialog(type,header,message)
|
||||
{
|
||||
if (type=="success"){
|
||||
$('#modal_dialog .modal-bodyicon').html('<i class="fa fa-check modal-icon-check">');
|
||||
$('#modal_dialog .modal-footer-button').html('<button type="button" class="btn btn-success" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
||||
$('#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>');
|
||||
}
|
||||
else if (type=="warning"){
|
||||
$('#modal_dialog .modal-bodyicon').html('<i class="fa fa-warning modal-icon-warning">');
|
||||
$('#modal_dialog .modal-footer-button').html('<button type="button" class="btn btn-warning" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
||||
$('#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>');
|
||||
}
|
||||
else if (type=="error"){
|
||||
$('#modal_dialog .modal-bodyicon').html('<i class="fa fa-warning modal-icon-error">');
|
||||
$('#modal_dialog .modal-footer-button').html('<button type="button" class="btn btn-danger" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
||||
$('#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>');
|
||||
}
|
||||
else if (type == "select"){
|
||||
$('#modal_dialog .modal-bodyicon').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||
$('#modal_dialog .modal-footer-button').html('<button type="button" id="'+btnid+'" class="btn btn-success" data-dismiss="modal">'+$.i18n('general_btn_save')+'</button>');
|
||||
$('#modal_dialog .modal-footer-button').append('<button type="button" class="btn btn-danger" data-dismiss="modal">'+$.i18n('general_btn_cancel')+'</button>');
|
||||
$('#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-success" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_saveandreload')+'</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>');
|
||||
}
|
||||
else if (type == "uilock"){
|
||||
$('#modal_dialog .modal-bodyicon').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||
$('#modal_dialog .modal-footer-button').html('<b>'+$.i18n('InfoDialog_nowrite_foottext')+'</b>');
|
||||
$('#id_body').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||
$('#id_footer').html('<b>'+$.i18n('InfoDialog_nowrite_foottext')+'</b>');
|
||||
}
|
||||
else if (type == "import"){
|
||||
$('#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>');
|
||||
}
|
||||
|
||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+header+'</h4>');
|
||||
$('#id_body').append(message);
|
||||
|
||||
if(type == "select")
|
||||
$('#id_body').append('<select id="id_select" class="form-control" style="margin-top:10px;width:auto;"></select>');
|
||||
|
||||
$("#modal_dialog").modal({
|
||||
backdrop : "static",
|
||||
@@ -107,7 +136,6 @@ function isJsonString(str)
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
function createJsonEditor(container,schema,setconfig,usePanel)
|
||||
{
|
||||
$('#'+container).off();
|
||||
@@ -123,6 +151,9 @@ function createJsonEditor(container,schema,setconfig,usePanel)
|
||||
disable_properties: 'true',
|
||||
disable_array_reorder: 'true',
|
||||
no_additional_properties: 'true',
|
||||
disable_array_delete_all_rows: 'true',
|
||||
disable_array_delete_last_row: 'true',
|
||||
access: storedAccess,
|
||||
schema: {
|
||||
title:'',
|
||||
properties: schema
|
||||
@@ -147,44 +178,100 @@ function createJsonEditor(container,schema,setconfig,usePanel)
|
||||
return editor;
|
||||
}
|
||||
|
||||
function createTableTh(th1, th2){
|
||||
var elth1 = document.createElement('th');
|
||||
var elth2 = document.createElement('th');
|
||||
var tr = document.createElement('tr');
|
||||
|
||||
elth1.innerHTML = th1;
|
||||
elth2.innerHTML = th2;
|
||||
tr.appendChild(elth1);
|
||||
tr.appendChild(elth2);
|
||||
|
||||
return tr;
|
||||
}
|
||||
|
||||
function createTableTd(td1, td2){
|
||||
var eltd1 = document.createElement('td');
|
||||
var eltd2 = document.createElement('td');
|
||||
var tr = document.createElement('tr');
|
||||
|
||||
eltd1.innerHTML = td1;
|
||||
eltd2.innerHTML = td2;
|
||||
tr.appendChild(eltd1);
|
||||
tr.appendChild(eltd2);
|
||||
|
||||
return tr;
|
||||
}
|
||||
|
||||
function createHelpTable(list, phead){
|
||||
// Creates a table with thead and tbody ids
|
||||
// @param string hid : a id for thead
|
||||
// @param string bid : a id for tbody
|
||||
// @param string cont : a container id to html() the table
|
||||
function createTable(hid, bid, cont)
|
||||
{
|
||||
var table = document.createElement('table');
|
||||
var thead = document.createElement('thead');
|
||||
var tbody = document.createElement('tbody');
|
||||
|
||||
table.className = "table";
|
||||
table.style.marginBottom = "0px";
|
||||
thead.setAttribute("id", hid);
|
||||
tbody.setAttribute("id", bid);
|
||||
|
||||
table.appendChild(thead);
|
||||
table.appendChild(tbody);
|
||||
|
||||
$('#'+cont).html(table);
|
||||
}
|
||||
|
||||
// Creates a table row <tr>
|
||||
// @param array list :innerHTML content for <td>/<th>
|
||||
// @param bool head :if null or false it's body
|
||||
// @param bool align :if null or false no alignment
|
||||
//
|
||||
// @return : <tr> with <td> or <th> as child(s)
|
||||
function createTableRow(list, head, align)
|
||||
{
|
||||
var row = document.createElement('tr');
|
||||
|
||||
for(var i = 0; i < list.length; i++)
|
||||
{
|
||||
if(head === true)
|
||||
var el = document.createElement('th');
|
||||
else
|
||||
var el = document.createElement('td');
|
||||
|
||||
if(align)
|
||||
el.style.verticalAlign = "middle";
|
||||
|
||||
el.innerHTML = list[i];
|
||||
row.appendChild(el);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
function createRow(id)
|
||||
{
|
||||
var el = document.createElement('div');
|
||||
el.className = "row";
|
||||
el.setAttribute('id', id);
|
||||
return el;
|
||||
}
|
||||
|
||||
function createOptPanel(phicon, phead, bodyid, footerid)
|
||||
{
|
||||
phead = '<i class="fa '+phicon+' fa-fw"></i>'+phead;
|
||||
pfooter = document.createElement('button');
|
||||
pfooter.className = "btn btn-success";
|
||||
pfooter.setAttribute("id", footerid);
|
||||
pfooter.innerHTML = '<i class="fa fa-fw fa-save"></i>'+$.i18n('general_button_savesettings');
|
||||
|
||||
return createPanel(phead, "", pfooter, "panel-default", bodyid);
|
||||
}
|
||||
|
||||
function createHelpTable(list, phead){
|
||||
var table = document.createElement('table');
|
||||
var thead = document.createElement('thead');
|
||||
var tbody = document.createElement('tbody');
|
||||
//console.log(sortProperties(list));
|
||||
|
||||
phead = '<i class="fa fa-fw fa-info-circle"></i>'+phead+' '+$.i18n("conf_helptable_expl");
|
||||
|
||||
table.className = 'table table-hover borderless';
|
||||
|
||||
thead.appendChild(createTableTh($.i18n('conf_helptable_option'), $.i18n('conf_helptable_expl')));
|
||||
for (key in list){
|
||||
if(list[key].access != 'system'){
|
||||
text = list[key].title.replace('title', 'expl');
|
||||
tbody.appendChild(createTableTd($.i18n(list[key].title), $.i18n(text)));
|
||||
thead.appendChild(createTableRow([$.i18n('conf_helptable_option'), $.i18n('conf_helptable_expl')], true, false));
|
||||
for (key in list)
|
||||
{
|
||||
if(list[key].access != 'system')
|
||||
{
|
||||
var text = list[key].title.replace('title', 'expl');
|
||||
tbody.appendChild(createTableRow([$.i18n(list[key].title), $.i18n(text)], false, false));
|
||||
|
||||
if(list[key].items && list[key].items.properties)
|
||||
{
|
||||
var ilist = list[key].items.properties;
|
||||
for (ikey in ilist)
|
||||
{
|
||||
|
||||
var itext = ilist[ikey].title.replace('title', 'expl');
|
||||
tbody.appendChild(createTableRow([$.i18n(ilist[ikey].title), $.i18n(itext)], false, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
table.appendChild(thead);
|
||||
@@ -193,12 +280,15 @@ function createHelpTable(list, phead){
|
||||
return createPanel(phead, table);
|
||||
}
|
||||
|
||||
function createPanel(head, body, footer, type){
|
||||
function createPanel(head, body, footer, type, bodyid){
|
||||
var cont = document.createElement('div');
|
||||
var p = document.createElement('div');
|
||||
var phead = document.createElement('div');
|
||||
var pbody = document.createElement('div');
|
||||
var pfooter = document.createElement('div');
|
||||
|
||||
cont.className = "col-lg-6";
|
||||
|
||||
if(typeof type == 'undefined')
|
||||
type = 'panel-default';
|
||||
|
||||
@@ -209,18 +299,30 @@ function createPanel(head, body, footer, type){
|
||||
|
||||
phead.innerHTML = head;
|
||||
|
||||
if(typeof body != 'undefined')
|
||||
if(typeof bodyid != 'undefined')
|
||||
{
|
||||
pfooter.style.textAlign = 'right';
|
||||
pbody.setAttribute("id", bodyid)
|
||||
}
|
||||
|
||||
if(typeof body != 'undefined' && body != "")
|
||||
pbody.appendChild(body);
|
||||
|
||||
pfooter.innerHTML = footer;
|
||||
if(typeof footer != 'undefined')
|
||||
pfooter.appendChild(footer);
|
||||
|
||||
p.appendChild(phead);
|
||||
p.appendChild(pbody);
|
||||
|
||||
if(typeof footer != 'undefined')
|
||||
{
|
||||
pfooter.style.textAlign = "right";
|
||||
p.appendChild(pfooter);
|
||||
}
|
||||
|
||||
return p;
|
||||
cont.appendChild(p);
|
||||
|
||||
return cont;
|
||||
}
|
||||
|
||||
function createSelGroup(group)
|
||||
|
Reference in New Issue
Block a user