diff --git a/assets/webconfig/js/ui_utils.js b/assets/webconfig/js/ui_utils.js index 0ca62db9..01f7a0a7 100644 --- a/assets/webconfig/js/ui_utils.js +++ b/assets/webconfig/js/ui_utils.js @@ -1,27 +1,22 @@ var prevTag; -function removeOverlay() -{ +function removeOverlay() { $("#loading_overlay").removeClass("overlay"); } -function reload() -{ +function reload() { location.reload(); } -function storageComp() -{ - if (typeof(Storage) !== "undefined") +function storageComp() { + if (typeof (Storage) !== "undefined") return true; return false; } -function getStorage(item, session) -{ - if(storageComp()) - { - if(session === true) +function getStorage(item, session) { + if (storageComp()) { + if (session === true) return sessionStorage.getItem(item); else return localStorage.getItem(item); @@ -29,46 +24,36 @@ function getStorage(item, session) return null; } -function setStorage(item, value, session) -{ - if(storageComp()) - { - if(session === true) +function setStorage(item, value, session) { + if (storageComp()) { + if (session === true) sessionStorage.setItem(item, value); else localStorage.setItem(item, value); } } -function removeStorage(item, session) -{ - if(storageComp()) - { - if(session === true) +function removeStorage(item, session) { + if (storageComp()) { + if (session === true) sessionStorage.removeItem(item); else localStorage.removeItem(item); } } -function debugMessage(msg) -{ - if (window.debugMessagesActive) - { +function debugMessage(msg) { + if (window.debugMessagesActive) { console.log(msg); } } -function updateSessions() -{ +function updateSessions() { var sess = window.serverInfo.sessions; - if (sess && sess.length) - { + if (sess && sess.length) { window.wSess = []; - for(var i = 0; i'+$.i18n('info_404')+''); + $("#page-content").load("/content/" + tag + ".html", function (response, status, xhr) { + if (status == "error") { + $("#page-content").html('

' + $.i18n('info_404') + '

'); removeOverlay(); } updateUiOnInstance(window.currentHyperionInstance); @@ -138,60 +116,53 @@ function loadContent(event, forceRefresh) } } -function getInstanceNameByIndex(index) -{ +function getInstanceNameByIndex(index) { var instData = window.serverInfo.instance - for(var key in instData) - { - if(instData[key].instance == index) + for (var key in instData) { + if (instData[key].instance == index) return instData[key].friendly_name; } return "unknown" } -function updateHyperionInstanceListing() -{ +function updateHyperionInstanceListing() { var data = window.serverInfo.instance.filter(entry => entry.running); $('#hyp_inst_listing').html(""); - for(var key in data) - { + for (var key in data) { var currInstMarker = (data[key].instance == window.currentHyperionInstance) ? "component-on" : ""; - var html = '
  • \ + var html = '
  • \ \
    \ - \ - '+data[key].friendly_name+' \ + \ + '+ data[key].friendly_name + ' \
    \
    \
  • ' - if(data.length-1 > key) + if (data.length - 1 > key) html += '
  • ' $('#hyp_inst_listing').append(html); - $('#hyperioninstance_'+data[key].instance).off().on("click",function(e){ + $('#hyperioninstance_' + data[key].instance).off().on("click", function (e) { var inst = e.currentTarget.id.split("_")[1] instanceSwitch(inst) }); } } -function initLanguageSelection() -{ +function initLanguageSelection() { // Initialise language selection list with languages supported - for (var i = 0; i < availLang.length; i++) - { - $("#language-select").append(''); + for (var i = 0; i < availLang.length; i++) { + $("#language-select").append(''); } var langLocale = storedLang; // If no language has been set, resolve browser locale - if ( langLocale === 'auto' ) - { - langLocale = $.i18n().locale.substring(0,2); + if (langLocale === 'auto') { + langLocale = $.i18n().locale.substring(0, 2); } // Resolve text for language code @@ -199,17 +170,14 @@ function initLanguageSelection() //Test, if language is supported by hyperion var langIdx = availLang.indexOf(langLocale); - if ( langIdx > -1 ) - { + if (langIdx > -1) { langText = availLangText[langIdx]; } - else - { + else { // If language is not supported by hyperion, try fallback language - langLocale = $.i18n().options.fallbackLocale.substring(0,2); + langLocale = $.i18n().options.fallbackLocale.substring(0, 2); langIdx = availLang.indexOf(langLocale); - if ( langIdx > -1 ) - { + if (langIdx > -1) { langText = availLangText[langIdx]; } } @@ -219,12 +187,10 @@ function initLanguageSelection() $("#language-select").selectpicker("refresh"); } -function updateUiOnInstance(inst) -{ - if(inst != 0) - { +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) + 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"); @@ -232,15 +198,13 @@ function updateUiOnInstance(inst) $("#dashboard_active_instance_friendly_name").html($.i18n('dashboard_active_instance') + ': ' + window.serverInfo.instance[inst].friendly_name); $("#dashboard_active_instance").removeAttr("style"); } - else - { + else { $("#hyperion_global_setting_notify").fadeOut("fast"); $("#dashboard_active_instance").attr("style", "display:none"); } } -function instanceSwitch(inst) -{ +function instanceSwitch(inst) { requestInstanceSwitch(inst) window.currentHyperionInstance = inst; window.currentHyperionInstanceName = getInstanceNameByIndex(inst); @@ -248,140 +212,116 @@ function instanceSwitch(inst) updateHyperionInstanceListing() } -function loadContentTo(containerId, fileName) -{ - $(containerId).load("/content/"+fileName+".html"); +function loadContentTo(containerId, fileName) { + $(containerId).load("/content/" + fileName + ".html"); } -function toggleClass(obj,class1,class2) -{ - if ( $(obj).hasClass(class1)) - { +function toggleClass(obj, class1, class2) { + if ($(obj).hasClass(class1)) { $(obj).removeClass(class1); $(obj).addClass(class2); } - else - { + else { $(obj).removeClass(class2); $(obj).addClass(class1); } } - -function setClassByBool(obj,enable,class1,class2) -{ - if (enable) - { +function setClassByBool(obj, enable, class1, class2) { + if (enable) { $(obj).removeClass(class1); $(obj).addClass(class2); } - else - { + else { $(obj).removeClass(class2); $(obj).addClass(class1); } } -function showInfoDialog(type,header,message) -{ - if (type=="success") - { +function showInfoDialog(type, header, message) { + if (type == "success") { $('#id_body').html(''); - if(header == "") - $('#id_body').append('

    '+$.i18n('infoDialog_general_success_title')+'

    '); - $('#id_footer').html(''); + if (header == "") + $('#id_body').append('

    ' + $.i18n('infoDialog_general_success_title') + '

    '); + $('#id_footer').html(''); } - else if (type=="warning") - { + else if (type == "warning") { $('#id_body').html(''); - if(header == "") - $('#id_body').append('

    '+$.i18n('infoDialog_general_warning_title')+'

    '); - $('#id_footer').html(''); + if (header == "") + $('#id_body').append('

    ' + $.i18n('infoDialog_general_warning_title') + '

    '); + $('#id_footer').html(''); } - else if (type=="error") - { + else if (type == "error") { $('#id_body').html(''); - if(header == "") - $('#id_body').append('

    '+$.i18n('infoDialog_general_error_title')+'

    '); - $('#id_footer').html(''); + if (header == "") + $('#id_body').append('

    ' + $.i18n('infoDialog_general_error_title') + '

    '); + $('#id_footer').html(''); } - else if (type == "select") - { + else if (type == "select") { $('#id_body').html('Redefine ambient light!'); - $('#id_footer').html(''); - $('#id_footer').append(''); + $('#id_footer').html(''); + $('#id_footer').append(''); } - else if (type == "iswitch") - { + else if (type == "iswitch") { $('#id_body').html('Redefine ambient light!'); - $('#id_footer').html(''); - $('#id_footer').append(''); + $('#id_footer').html(''); + $('#id_footer').append(''); } - else if (type == "uilock") - { + else if (type == "uilock") { $('#id_body').html('Redefine ambient light!'); - $('#id_footer').html(''+$.i18n('InfoDialog_nowrite_foottext')+''); + $('#id_footer').html('' + $.i18n('InfoDialog_nowrite_foottext') + ''); } - else if (type == "import") - { + else if (type == "import") { $('#id_body').html(''); - $('#id_footer').html(''); - $('#id_footer').append(''); + $('#id_footer').html(''); + $('#id_footer').append(''); } - else if (type == "delInst") - { + else if (type == "delInst") { $('#id_body').html(''); - $('#id_footer').html(''); - $('#id_footer').append(''); + $('#id_footer').html(''); + $('#id_footer').append(''); } - else if (type == "renInst") - { + else if (type == "renInst") { $('#id_body_rename').html('
    '); - $('#id_body_rename').append('

    '+header+'

    '); - $('#id_body_rename').append(''); - $('#id_footer_rename').html(''); - $('#id_footer_rename').append(''); + $('#id_body_rename').append('

    ' + header + '

    '); + $('#id_body_rename').append(''); + $('#id_footer_rename').html(''); + $('#id_footer_rename').append(''); } - else if (type == "changePassword") - { + else if (type == "changePassword") { $('#id_body_rename').html('
    '); - $('#id_body_rename').append('

    '+header+'

    '); + $('#id_body_rename').append('

    ' + header + '

    '); $('#id_body_rename').append('
    '); $('#id_body_rename').append(''); - $('#id_footer_rename').html(''); - $('#id_footer_rename').append(''); + $('#id_footer_rename').html(''); + $('#id_footer_rename').append(''); } - else if (type == "checklist") - { + else if (type == "checklist") { $('#id_body').html('Redefine ambient light!'); - $('#id_body').append('

    '+$.i18n('infoDialog_checklist_title')+'

    '); + $('#id_body').append('

    ' + $.i18n('infoDialog_checklist_title') + '

    '); $('#id_body').append(header); - $('#id_footer').html(''); + $('#id_footer').html(''); } - else if (type == "newToken") - { + else if (type == "newToken") { $('#id_body').html('Redefine ambient light!'); - $('#id_footer').html(''); + $('#id_footer').html(''); } - else if (type == "grantToken") - { + else if (type == "grantToken") { $('#id_body').html('Redefine ambient light!'); - $('#id_footer').html(''); - $('#id_footer').append(''); + $('#id_footer').html(''); + $('#id_footer').append(''); } - if(type != "renInst") - { - $('#id_body').append('

    '+header+'

    '); + if (type != "renInst") { + $('#id_body').append('

    ' + header + '

    '); $('#id_body').append(message); } - if(type == "select" || type == "iswitch") + if (type == "select" || type == "iswitch") $('#id_body').append(''); - $(type == "renInst" || type == "changePassword" ? "#modal_dialog_rename" : "#modal_dialog").modal({ - backdrop : "static", + backdrop: "static", keyboard: false, show: true }); @@ -392,147 +332,128 @@ function showInfoDialog(type,header,message) }); } -function createHintH(type, text, container) -{ +function createHintH(type, text, container) { type = String(type); - if(type == "intro") + if (type == "intro") tclass = "introd"; - $('#'+container).prepend('

    '+text+'


    '); + $('#' + container).prepend('

    ' + text + '


    '); } -function createHint(type, text, container, buttonid, buttontxt) -{ +function createHint(type, text, container, buttonid, buttontxt) { var fe, tclass; - if(type == "intro") - { + if (type == "intro") { fe = ''; tclass = "intro-hint"; } - else if(type == "info") - { + else if (type == "info") { fe = '
    Information
    '; tclass = "info-hint"; } - else if(type == "wizard") - { + else if (type == "wizard") { fe = '
    Information
    '; tclass = "wizard-hint"; } - else if(type == "warning") - { + else if (type == "warning") { fe = '
    Information
    '; tclass = "warning-hint"; } - if(buttonid) - buttonid = '

    '; + if (buttonid) + buttonid = '

    '; else buttonid = ""; - if(type == "intro") - $('#'+container).prepend('

    '+$.i18n("conf_helptable_expl")+'

    '+text+'
    '); - else if(type == "wizard") - $('#'+container).prepend('

    '+$.i18n("wiz_wizavail")+'

    '+$.i18n('wiz_guideyou',text)+buttonid+'
    '); - else - { - createTable('','htb',container, true, tclass); - $('#'+container+' .htb').append(createTableRow([fe ,text],false,true)); + if (type == "intro") + $('#' + container).prepend('

    ' + $.i18n("conf_helptable_expl") + '

    ' + text + '
    '); + else if (type == "wizard") + $('#' + container).prepend('

    ' + $.i18n("wiz_wizavail") + '

    ' + $.i18n('wiz_guideyou', text) + buttonid + '
    '); + else { + createTable('', 'htb', container, true, tclass); + $('#' + container + ' .htb').append(createTableRow([fe, text], false, true)); } } -function createEffHint(title, text) -{ - return '

    '+title+'

    '+text+'
    '; +function createEffHint(title, text) { + return '

    ' + title + '

    ' + text + '
    '; } -function valValue(id,value,min,max) -{ - if(typeof max === 'undefined' || max == "") +function valValue(id, value, min, max) { + if (typeof max === 'undefined' || max == "") max = 999999; - if(Number(value) > Number(max)) - { - $('#'+id).val(max); - showInfoDialog("warning","",$.i18n('edt_msg_error_maximum_incl',max)); + if (Number(value) > Number(max)) { + $('#' + id).val(max); + showInfoDialog("warning", "", $.i18n('edt_msg_error_maximum_incl', max)); return max; } - else if(Number(value) < Number(min)) - { - $('#'+id).val(min); - showInfoDialog("warning","",$.i18n('edt_msg_error_minimum_incl',min)); + else if (Number(value) < Number(min)) { + $('#' + id).val(min); + showInfoDialog("warning", "", $.i18n('edt_msg_error_minimum_incl', min)); return min; } return value; } -function readImg(input,cb) -{ - if (input.files && input.files[0]) { - var reader = new FileReader(); +function readImg(input, cb) { + if (input.files && input.files[0]) { + var reader = new FileReader(); // inject fileName property reader.fileName = input.files[0].name - reader.onload = function (e) { + reader.onload = function (e) { cb(e.target.result, e.target.fileName); - } - reader.readAsDataURL(input.files[0]); } + reader.readAsDataURL(input.files[0]); + } } -function isJsonString(str) -{ - try - { +function isJsonString(str) { + try { JSON.parse(str); } - catch (e) - { + catch (e) { return e; } return ""; } -function createJsonEditor(container,schema,setconfig,usePanel,arrayre) -{ - $('#'+container).off(); - $('#'+container).html(""); +function createJsonEditor(container, schema, setconfig, usePanel, arrayre) { + $('#' + container).off(); + $('#' + container).html(""); if (typeof arrayre === 'undefined') arrayre = true; var editor = new JSONEditor(document.getElementById(container), - { - theme: 'bootstrap3', - iconlib: "fontawesome4", - disable_collapse: 'true', - form_name_root: 'sa', - 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, - access: storedAccess, - schema: { - title:'', - properties: schema - } - }); + { + theme: 'bootstrap3', + iconlib: "fontawesome4", + disable_collapse: 'true', + form_name_root: 'sa', + 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, + access: storedAccess, + schema: { + title: '', + properties: schema + } + }); - if(usePanel) - { - $('#'+container+' .well').first().removeClass('well well-sm'); - $('#'+container+' h4').first().remove(); - $('#'+container+' .well').first().removeClass('well well-sm'); + if (usePanel) { + $('#' + container + ' .well').first().removeClass('well well-sm'); + $('#' + container + ' h4').first().remove(); + $('#' + container + ' .well').first().removeClass('well well-sm'); } - if (setconfig) - { - for(var key in editor.root.editors) - { - editor.getEditor("root."+key).setValue(Object.assign({}, editor.getEditor("root."+key).value, window.serverConfig[key] )); + if (setconfig) { + for (var key in editor.root.editors) { + editor.getEditor("root." + key).setValue(Object.assign({}, editor.getEditor("root." + key).value, window.serverConfig[key])); } } @@ -540,7 +461,6 @@ function createJsonEditor(container,schema,setconfig,usePanel,arrayre) } function updateJsonEditorSelection(editor, key, addElements, newEnumVals, newTitelVals, newDefaultVal, addCustom) { - var orginalProperties = editor.schema.properties[key]; var newSchema = []; @@ -559,7 +479,6 @@ function updateJsonEditorSelection(editor, key, addElements, newEnumVals, newTit } if (orginalProperties) { - if (orginalProperties["title"]) { newSchema[key]["title"] = orginalProperties["title"]; } @@ -603,7 +522,6 @@ function updateJsonEditorSelection(editor, key, addElements, newEnumVals, newTit } function updateJsonEditorMultiSelection(editor, key, addElements, newEnumVals, newTitelVals, newDefaultVal) { - var orginalProperties = editor.schema.properties[key]; var newSchema = []; @@ -661,7 +579,6 @@ function updateJsonEditorMultiSelection(editor, key, addElements, newEnumVals, n } function updateJsonEditorRange(editor, key, minimum, maximum, defaultValue, step) { - var orginalProperties = editor.schema.properties[key]; var newSchema = []; newSchema[key] = orginalProperties; @@ -681,54 +598,50 @@ function updateJsonEditorRange(editor, key, minimum, maximum, defaultValue, step editor.original_schema.properties[key] = orginalProperties; editor.schema.properties[key] = newSchema[key]; - + editor.removeObjectProperty(key); delete editor.cached_editors[key]; editor.addObjectProperty(key); } -function buildWL(link,linkt,cl) -{ +function buildWL(link, linkt, cl) { var baseLink = "https://docs.hyperion-project.org/"; var lang; - if(typeof linkt == "undefined") + if (typeof linkt == "undefined") linkt = "Placeholder"; - if(storedLang == "de" || navigator.locale == "de") + if (storedLang == "de" || navigator.locale == "de") lang = "de"; else lang = "en"; - if(cl === true) - { + if (cl === true) { linkt = $.i18n(linkt); - return '

    '+linkt+'

    '+$.i18n('general_wiki_moreto',linkt)+': '+linkt+'
    ' + return '' } else - return ': '+linkt+''; + return ': ' + linkt + ''; } -function rgbToHex(rgb) -{ - if(rgb.length == 3) - { +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) + - ("0" + parseInt(rgb[2],10).toString(16)).slice(-2); + ("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); } else debugMessage('rgbToHex: Given rgb is no array or has wrong length'); } 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; + 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; } /* @@ -738,24 +651,21 @@ function hexToRgb(hex) { @param title A title (optional) @param addhtml Add custom html to the notification end */ -function showNotification(type, message, title="", addhtml="") -{ - if(title == "") - { - switch(type) - { +function showNotification(type, message, title = "", addhtml = "") { + if (title == "") { + switch (type) { case "info": - title = $.i18n('infoDialog_general_info_title'); - break; + title = $.i18n('infoDialog_general_info_title'); + break; case "success": - title = $.i18n('infoDialog_general_success_title'); - break; + title = $.i18n('infoDialog_general_success_title'); + break; case "warning": - title = $.i18n('infoDialog_general_warning_title'); - break; + title = $.i18n('infoDialog_general_warning_title'); + break; case "danger": - title = $.i18n('infoDialog_general_error_title'); - break; + title = $.i18n('infoDialog_general_error_title'); + break; } } @@ -763,41 +673,39 @@ function showNotification(type, message, title="", addhtml="") // options title: title, message: message - },{ + }, { // settings type: type, animate: { enter: 'animated fadeInDown', exit: 'animated fadeOutUp' }, - placement:{ - align:'center' + placement: { + align: 'center' }, - mouse_over : 'pause', + mouse_over: 'pause', template: '' + + '' + + '' }); } -function createCP(id, color, cb) -{ - if(Array.isArray(color)) +function createCP(id, color, cb) { + if (Array.isArray(color)) color = rgbToHex(color); - else if(color == "undefined") + else if (color == "undefined") color = "#AA3399"; - if(color.startsWith("#")) - { - $('#'+id).colorpicker({ + if (color.startsWith("#")) { + $('#' + id).colorpicker({ format: 'rgb', customClass: 'colorpicker-2x', color: color, @@ -811,10 +719,10 @@ function createCP(id, color, cb) }, } }); - $('#'+id).colorpicker().on('changeColor', function(e) { + $('#' + id).colorpicker().on('changeColor', function (e) { var rgb = e.color.toRGB(); var hex = e.color.toHex(); - cb(rgb,hex,e); + cb(rgb, hex, e); }); } else @@ -826,26 +734,25 @@ function createCP(id, color, cb) // @param string bid : a class for tbody // @param string cont : a container id to html() the table // @param string bless: if true the table is borderless -function createTable(hid, bid, cont, bless, tclass) -{ +function createTable(hid, bid, cont, bless, tclass) { var table = document.createElement('table'); var thead = document.createElement('thead'); var tbody = document.createElement('tbody'); table.className = "table"; - if(bless === true) + if (bless === true) table.className += " borderless"; - if(typeof tclass !== "undefined") - table.className += " "+tclass; + if (typeof tclass !== "undefined") + table.className += " " + tclass; table.style.marginBottom = "0px"; - if(hid != "") + if (hid != "") thead.className = hid; tbody.className = bid; - if(hid != "") + if (hid != "") table.appendChild(thead); table.appendChild(tbody); - $('#'+cont).append(table); + $('#' + cont).append(table); } // Creates a table row @@ -854,18 +761,16 @@ function createTable(hid, bid, cont, bless, tclass) // @param bool align :if null or false no alignment // // @return : with or as child(s) -function createTableRow(list, head, align) -{ +function createTableRow(list, head, align) { var row = document.createElement('tr'); - for(var i = 0; i < list.length; i++) - { - if(head === true) + for (var i = 0; i < list.length; i++) { + if (head === true) var el = document.createElement('th'); else var el = document.createElement('td'); - if(align) + if (align) el.style.verticalAlign = "middle"; el.innerHTML = list[i]; @@ -874,27 +779,24 @@ function createTableRow(list, head, align) return row; } -function createRow(id) -{ +function createRow(id) { var el = document.createElement('div'); el.className = "row"; el.setAttribute('id', id); return el; } -function createOptPanel(phicon, phead, bodyid, footerid) -{ - phead = ''+phead; +function createOptPanel(phicon, phead, bodyid, footerid) { + phead = '' + phead; var pfooter = document.createElement('button'); pfooter.className = "btn btn-primary"; pfooter.setAttribute("id", footerid); - pfooter.innerHTML = ''+$.i18n('general_button_savesettings'); + pfooter.innerHTML = '' + $.i18n('general_button_savesettings'); return createPanel(phead, "", pfooter, "panel-default", bodyid); } function compareTwoValues(key1, key2, order = 'asc') { - return function innerSort(a, b) { if (!a.hasOwnProperty(key1) || !b.hasOwnProperty(key1)) { // property key1 doesn't exist on either object @@ -936,36 +838,32 @@ function compareTwoValues(key1, key2, order = 'asc') { }; } -function sortProperties(list) -{ - for(var key in list) - { +function sortProperties(list) { + for (var key in list) { list[key].key = key; } - list = $.map(list, function(value, index) { - return [value]; - }); - return list.sort(function(a,b) { - return a.propertyOrder - b.propertyOrder; - }); + list = $.map(list, function (value, index) { + return [value]; + }); + return list.sort(function (a, b) { + return a.propertyOrder - b.propertyOrder; + }); } -function createHelpTable(list, phead){ +function createHelpTable(list, phead) { var table = document.createElement('table'); var thead = document.createElement('thead'); var tbody = document.createElement('tbody'); list = sortProperties(list); - phead = ''+phead+' '+$.i18n("conf_helptable_expl"); + phead = '' + phead + ' ' + $.i18n("conf_helptable_expl"); table.className = 'table table-hover borderless'; thead.appendChild(createTableRow([$.i18n('conf_helptable_option'), $.i18n('conf_helptable_expl')], true, false)); - for (var key in list) - { - if(list[key].access != 'system') - { + for (var key in list) { + if (list[key].access != 'system') { // 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; @@ -974,11 +872,9 @@ function createHelpTable(list, phead){ 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) - { + if (list[key].items && list[key].items.properties) { var ilist = sortProperties(list[key].items.properties); - for (var ikey in ilist) - { + for (var ikey in ilist) { // 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; @@ -996,7 +892,7 @@ function createHelpTable(list, phead){ return createPanel(phead, table); } -function createPanel(head, body, footer, type, bodyid){ +function createPanel(head, body, footer, type, bodyid) { var cont = document.createElement('div'); var p = document.createElement('div'); var phead = document.createElement('div'); @@ -1005,33 +901,31 @@ function createPanel(head, body, footer, type, bodyid){ cont.className = "col-lg-6"; - if(typeof type == 'undefined') + if (typeof type == 'undefined') type = 'panel-default'; - p.className = 'panel '+type; + p.className = 'panel ' + type; phead.className = 'panel-heading'; pbody.className = 'panel-body'; pfooter.className = 'panel-footer'; phead.innerHTML = head; - if(typeof bodyid != 'undefined') - { + if (typeof bodyid != 'undefined') { pfooter.style.textAlign = 'right'; pbody.setAttribute("id", bodyid); } - if(typeof body != 'undefined' && body != "") + if (typeof body != 'undefined' && body != "") pbody.appendChild(body); - if(typeof footer != 'undefined') + if (typeof footer != 'undefined') pfooter.appendChild(footer); p.appendChild(phead); p.appendChild(pbody); - if(typeof footer != 'undefined') - { + if (typeof footer != 'undefined') { pfooter.style.textAlign = "right"; p.appendChild(pfooter); } @@ -1041,15 +935,13 @@ function createPanel(head, body, footer, type, bodyid){ return cont; } -function createSelGroup(group) -{ +function createSelGroup(group) { var el = document.createElement('optgroup'); el.setAttribute('label', group); return el; } -function createSelOpt(opt, title) -{ +function createSelOpt(opt, title) { var el = document.createElement('option'); el.setAttribute('value', opt); if (typeof title == 'undefined') @@ -1059,18 +951,14 @@ function createSelOpt(opt, title) return el; } -function createSel(array, group, split) -{ - if (array.length != 0) - { +function createSel(array, group, split) { + if (array.length != 0) { var el = createSelGroup(group); - for(var i=0; i", { - rel: "stylesheet", - type: "text/css", - href: "../css/darkMode.css" - }).appendTo("head"); +function handleDarkMode() { + $("", { + rel: "stylesheet", + type: "text/css", + href: "../css/darkMode.css" + }).appendTo("head"); - setStorage("darkMode", "on", false); - $('#btn_darkmode_icon').removeClass('fa fa-moon-o'); - $('#btn_darkmode_icon').addClass('fa fa-sun-o'); + setStorage("darkMode", "on", false); + $('#btn_darkmode_icon').removeClass('fa fa-moon-o'); + $('#btn_darkmode_icon').addClass('fa fa-sun-o'); }