var onLedLayoutTab = false; var nonBlacklistLedArray = []; var ledBlacklist = []; var finalLedArray = []; var conf_editor = null; var blacklist_editor = null; var aceEdt = null; var imageCanvasNodeCtx; var canvas_height; var canvas_width; var devRPiSPI = ['apa102', 'apa104', 'ws2801', 'lpd6803', 'lpd8806', 'p9813', 'sk6812spi', 'sk6822spi', 'sk9822', 'ws2812spi']; var devRPiPWM = ['ws281x']; var devRPiGPIO = ['piblaster']; var devNET = ['atmoorb', 'cololight', 'fadecandy', 'philipshue', 'nanoleaf', 'razer', 'tinkerforge', 'tpm2net', 'udpe131', 'udpartnet', 'udph801', 'udpraw', 'wled', 'yeelight']; var devSerial = ['adalight', 'dmx', 'atmo', 'sedu', 'tpm2', 'karate']; var devHID = ['hyperionusbasp', 'lightpack', 'paintpack', 'rawhid']; var infoTextDefault = '' + $.i18n("conf_leds_device_info_log") + ' ' + $.i18n("main_menu_logging_token") + ''; function round(number) { var factor = Math.pow(10, 4); var tempNumber = number * factor; var roundedTempNumber = Math.round(tempNumber); return roundedTempNumber / factor; }; function createLedPreview(leds, origin) { if (origin == "classic") { $('#previewcreator').html($.i18n('conf_leds_layout_preview_originCL')); $('#leds_preview').css("padding-top", "56.25%"); } else if (origin == "text") { $('#previewcreator').html($.i18n('conf_leds_layout_preview_originTEXT')); $('#leds_preview').css("padding-top", "56.25%"); } else if (origin == "matrix") { $('#previewcreator').html($.i18n('conf_leds_layout_preview_originMA')); $('#leds_preview').css("padding-top", "100%"); } $('#previewledcount').html($.i18n('conf_leds_layout_preview_totalleds', leds.length)); $('#previewledpower').html($.i18n('conf_leds_layout_preview_ledpower', ((leds.length * 0.06) * 1.1).toFixed(1))); $('.st_helper').css("border", "8px solid grey"); canvas_height = $('#leds_preview').innerHeight(); canvas_width = $('#leds_preview').innerWidth(); imageCanvasNodeCtx = document.getElementById("image_preview").getContext("2d"); $('#image_preview').css({ "width": canvas_width, "height": canvas_height }); var leds_html = ""; for (var idx = 0; idx < leds.length; idx++) { var led = leds[idx]; var led_id = 'ledc_' + [idx]; var bgcolor = "background-color:hsla(" + (idx * 360 / leds.length) + ",100%,50%,0.75);"; var pos = "left:" + (led.hmin * canvas_width) + "px;" + "top:" + (led.vmin * canvas_height) + "px;" + "width:" + ((led.hmax - led.hmin) * (canvas_width - 1)) + "px;" + "height:" + ((led.vmax - led.vmin) * (canvas_height - 1)) + "px;"; leds_html += '
' + $.i18n('general_wiki_moreto', $.i18n('conf_leds_nav_label_ledlayout')) + buildWL("user/advanced/Advanced.html#led-layout", "Wiki") + '
'); // bind change event to all inputs $('.ledCLconstr').bind("change", function () { //Ensure Values are in min/max ranges if ($(this).val() < $(this).attr('min') * 1) { $(this).val($(this).attr('min')); } if ($(this).val() > $(this).attr('max') * 1) { $(this).val($(this).attr('max')); } //top/bottom and left/right must not overlap switch (this.id) { case "ip_cl_ptlh": var ptrh = parseInt($("#ip_cl_ptrh").val()); if (this.value > ptrh) { $(this).val(ptrh); } break; case "ip_cl_ptrh": var ptlh = parseInt($("#ip_cl_ptlh").val()); if (this.value < ptlh) { $(this).val(ptlh); } break; case "ip_cl_pblh": var pbrh = parseInt($("#ip_cl_pbrh").val()); if (this.value > pbrh) { $(this).val(pbrh); } break; case "ip_cl_pbrh": var pblh = parseInt($("#ip_cl_pblh").val()); if (this.value < pblh) { $(this).val(pblh); } break; case "ip_cl_ptlv": var pblv = parseInt($("#ip_cl_pblv").val()); if (this.value > pblv) { $(this).val(pblv); } break; case "ip_cl_pblv": var ptlv = parseInt($("#ip_cl_ptlv").val()); if (this.value < ptlv) { $(this).val(ptlv); } break; case "ip_cl_ptrv": var pbrv = parseInt($("#ip_cl_pbrv").val()); if (this.value > pbrv) { $(this).val(pbrv); } break; case "ip_cl_pbrv": var ptrv = parseInt($("#ip_cl_ptrv").val()); if (this.value < ptrv) { $(this).val(ptrv); } default: } createClassicLeds(); }); $('.ledMAconstr').bind("change", function () { valValue(this.id, this.value, this.min, this.max); createMatrixLeds(); }); $(document).on('click', "#classic_panel", function (e) { createClassicLeds(); }); $(document).on('click', "#matrix_panel", function (e) { createMatrixLeds(); }); $(document).on('click', "#current_config_panel", function (e) { aceEdt.set(finalLedArray); }); // Initialise from config and apply blacklist rules nonBlacklistLedArray = window.serverConfig.leds; ledBlacklist = window.serverConfig.ledConfig.ledBlacklist; finalLedArray = blackListLeds(nonBlacklistLedArray, ledBlacklist); var blacklistOptions = window.serverSchema.properties.ledConfig.properties.ledBlacklist; blacklist_editor = createJsonEditor('editor_container_blacklist_conf', { ledBlacklist: blacklistOptions, }); blacklist_editor.getEditor("root.ledBlacklist").setValue(ledBlacklist); // v4 of json schema with diff required assignment - remove when hyperion schema moved to v4 var ledschema = { "items": { "additionalProperties": false, "required": ["hmin", "hmax", "vmin", "vmax"], "properties": { "name": { "type": "string" }, "colorOrder": { "enum": ["rgb", "bgr", "rbg", "brg", "gbr", "grb"], "type": "string" }, "hmin": { "maximum": 1, "minimum": 0, "type": "number" }, "hmax": { "maximum": 1, "minimum": 0, "type": "number" }, "vmin": { "maximum": 1, "minimum": 0, "type": "number" }, "vmax": { "maximum": 1, "minimum": 0, "type": "number" } }, "type": "object" }, "type": "array" }; //create jsonace editor aceEdt = new JSONACEEditor(document.getElementById("aceedit"), { mode: 'code', schema: ledschema, onChange: function () { var success = true; try { aceEdt.get(); } catch (err) { success = false; } if (success) { $('#leds_custom_updsim').attr("disabled", false); $('#leds_custom_save').attr("disabled", false); } else { $('#leds_custom_updsim').attr("disabled", true); $('#leds_custom_save').attr("disabled", true); } if (window.readOnlyMode) { $('#leds_custom_save').attr('disabled', true); } } }, finalLedArray); //TODO: HACK! No callback for schema validation - Add it! setInterval(function () { if ($('#aceedit table').hasClass('jsoneditor-text-errors')) { $('#leds_custom_updsim').attr("disabled", true); $('#leds_custom_save').attr("disabled", true); } }, 1000); $('.jsoneditor-menu').toggle(); // validate textfield and update preview $("#leds_custom_updsim").off().on("click", function () { nonBlacklistLedArray = aceEdt.get(); finalLedArray = blackListLeds(nonBlacklistLedArray, ledBlacklist); createLedPreview(finalLedArray, 'text'); }); // save led layout, the generated textfield configuration always represents the latest layout $("#btn_ma_save, #btn_cl_save, #btn_bl_save, #leds_custom_save").off().on("click", function () { var hardwareLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount").getValue(); var layoutLedCount = aceEdt.get().length; if (hardwareLedCount < layoutLedCount) { // Not enough hardware LEDs for configured layout showInfoDialog('error', $.i18n("conf_leds_config_error"), $.i18n('conf_leds_error_hwled_lt_layout', hardwareLedCount, layoutLedCount)); } else { saveLedConfig(false); } }); // toggle led numbers $('#leds_prev_toggle_num').off().on("click", function () { $('.led_prev_num').toggle(); toggleClass('#leds_prev_toggle_num', "btn-danger", "btn-success"); }); // toggle live video $('#leds_prev_toggle_live_video').off().on("click", function () { setClassByBool('#leds_prev_toggle_live_video', window.imageStreamActive, "btn-success", "btn-danger"); if (onLedLayoutTab && window.imageStreamActive) { imageCanvasNodeCtx.clear(); if (!$('#leds_toggle_live_video').hasClass("btn-success")) { requestLedImageStop(); } } else { requestLedImageStart(); } }); $(window.hyperion).on("cmd-ledcolors-imagestream-update", function (event) { //Only update Image, if LED Layout Tab is visible if (onLedLayoutTab && window.imageStreamActive) { setClassByBool('#leds_prev_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success"); var imageData = (event.response.result.image); var image = new Image(); image.onload = function () { imageCanvasNodeCtx.drawImage(image, 0, 0, imageCanvasNodeCtx.canvas.width, imageCanvasNodeCtx.canvas.height); }; image.src = imageData; } }); // open checklist $('#leds_prev_checklist').off().on("click", function () { var liList = [$.i18n('conf_leds_layout_checkp1'), $.i18n('conf_leds_layout_checkp3'), $.i18n('conf_leds_layout_checkp2'), $.i18n('conf_leds_layout_checkp4')]; var ul = document.createElement("ul"); ul.className = "checklist" for (var i = 0; i < liList.length; i++) { var li = document.createElement("li"); li.innerHTML = liList[i]; ul.appendChild(li); } showInfoDialog('checklist', "", ul); }); // nav $('#leds_cfg_nav a[data-toggle="tab"]').off().on('shown.bs.tab', function (e) { var target = $(e.target).attr("href") // activated tab if (target == "#menu_gencfg") { onLedLayoutTab = true; $('#leds_custom_updsim').trigger('click'); } else { onLedLayoutTab = false; } blacklist_editor.on('change', function () { // only update preview, if config is valid if (blacklist_editor.validate().length <= 0) { ledBlacklist = blacklist_editor.getEditor("root.ledBlacklist").getValue(); finalLedArray = blackListLeds(nonBlacklistLedArray, ledBlacklist); createLedPreview(finalLedArray); aceEdt.set(finalLedArray); } // change save button state based on validation result blacklist_editor.validate().length || window.readOnlyMode ? $('#btn_bl_save').attr('disabled', true) : $('#btn_bl_save').attr('disabled', false); }); }); //************************************************** // Handle LED-Device Configuration //************************************************** // External properties properties, 2-dimensional arry of [ledType][key] devicesProperties = {}; addJsonEditorHostValidation(); $("#leddevices").off().on("change", function () { var generalOptions = window.serverSchema.properties.device; var ledType = $(this).val(); // philipshueentertainment backward fix if (ledType == "philipshueentertainment") ledType = "philipshue"; var specificOptions = window.serverSchema.properties.alldevices[ledType]; conf_editor = createJsonEditor('editor_container_leddevice', { specificOptions: specificOptions, generalOptions: generalOptions, }); var values_general = {}; var values_specific = {}; var isCurrentDevice = (window.serverConfig.device.type == ledType); for (var key in window.serverConfig.device) { if (key != "type" && key in generalOptions.properties) values_general[key] = window.serverConfig.device[key]; }; conf_editor.getEditor("root.generalOptions").setValue(values_general); if (isCurrentDevice) { var specificOptions_val = conf_editor.getEditor("root.specificOptions").getValue(); for (var key in specificOptions_val) { values_specific[key] = (key in window.serverConfig.device) ? window.serverConfig.device[key] : specificOptions_val[key]; }; conf_editor.getEditor("root.specificOptions").setValue(values_specific); }; $("#info_container_text").html(infoTextDefault); // change save button state based on validation result conf_editor.validate().length || window.readOnlyMode ? $('#btn_submit_controller').attr('disabled', true) : $('#btn_submit_controller').attr('disabled', false); // led controller sepecific wizards $('#btn_wiz_holder').html(""); $('#btn_led_device_wiz').off(); if (ledType == "philipshue") { $('#root_specificOptions_useEntertainmentAPI').bind("change", function () { var ledWizardType = (this.checked) ? "philipshueentertainment" : ledType; var data = { type: ledWizardType }; var hue_title = (this.checked) ? 'wiz_hue_e_title' : 'wiz_hue_title'; changeWizard(data, hue_title, startWizardPhilipsHue); }); $("#root_specificOptions_useEntertainmentAPI").trigger("change"); } else if (ledType == "atmoorb") { var ledWizardType = (this.checked) ? "atmoorb" : ledType; var data = { type: ledWizardType }; var atmoorb_title = 'wiz_atmoorb_title'; changeWizard(data, atmoorb_title, startWizardAtmoOrb); } else if (ledType == "yeelight") { var ledWizardType = (this.checked) ? "yeelight" : ledType; var data = { type: ledWizardType }; var yeelight_title = 'wiz_yeelight_title'; changeWizard(data, yeelight_title, startWizardYeelight); } function changeWizard(data, hint, fn) { $('#btn_wiz_holder').html("") createHint("wizard", $.i18n(hint), "btn_wiz_holder", "btn_led_device_wiz"); $('#btn_led_device_wiz').off().on('click', data, fn); } conf_editor.on('ready', function () { var hwLedCountDefault = 1; var colorOrderDefault = "rgb"; $('#btn_test_controller').hide(); switch (ledType) { case "cololight": case "wled": case "nanoleaf": showAllDeviceInputOptions("hostList", false); case "adalight": case "atmo": case "dmx": case "karate": case "sedu": case "tpm2": case "apa102": case "apa104": case "ws2801": case "lpd6803": case "lpd8806": case "p9813": case "sk6812spi": case "sk6822spi": case "sk9822": case "ws2812spi": case "piblaster": case "ws281x": discover_device(ledType); hwLedCountDefault = 1; colorOrderDefault = "rgb"; break; case "philipshue": conf_editor.getEditor("root.generalOptions").disable(); var lights = conf_editor.getEditor("root.specificOptions.lightIds").getValue(); hwLedCountDefault = lights.length; colorOrderDefault = "rgb"; break; case "yeelight": conf_editor.getEditor("root.generalOptions").disable(); var lights = conf_editor.getEditor("root.specificOptions.lights").getValue(); hwLedCountDefault = lights.length; colorOrderDefault = "rgb"; break; case "atmoorb": conf_editor.getEditor("root.generalOptions").disable(); var configruedOrbIds = conf_editor.getEditor("root.specificOptions.orbIds").getValue().trim(); if (configruedOrbIds.length !== 0) { hwLedCountDefault = configruedOrbIds.split(",").map(Number).length; } else { hwLedCountDefault = 0; } colorOrderDefault = "rgb"; break; case "razer": conf_editor.getEditor("root.generalOptions").disable(); hwLedCountDefault = 1; colorOrderDefault = "bgr"; var subType = conf_editor.getEditor("root.specificOptions.subType").getValue(); let params = { subType: subType }; getProperties_device(ledType, subType, params); break; default: } if (ledType !== window.serverConfig.device.type) { var hwLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount"); if (hwLedCount) { hwLedCount.setValue(hwLedCountDefault); } var colorOrder = conf_editor.getEditor("root.generalOptions.colorOrder"); if (colorOrder) { colorOrder.setValue(colorOrderDefault); } } }); conf_editor.on('change', function () { // //Check, if device can be identified/tested and/or saved var canIdentify = false; var canSave = false; switch (ledType) { case "atmoorb": case "fadecandy": case "tinkerforge": case "tpm2net": case "udpe131": case "udpartnet": case "udph801": case "udpraw": var host = conf_editor.getEditor("root.specificOptions.host").getValue(); if (host !== "") { canSave = true; } break; case "philipshue": var host = conf_editor.getEditor("root.specificOptions.host").getValue(); var username = conf_editor.getEditor("root.specificOptions.username").getValue(); if (host !== "" && username != "") { var useEntertainmentAPI = conf_editor.getEditor("root.specificOptions.useEntertainmentAPI").getValue(); var clientkey = conf_editor.getEditor("root.specificOptions.clientkey").getValue(); if (!useEntertainmentAPI || clientkey !== "") { canSave = true; } } break; case "cololight": case "wled": var hostList = conf_editor.getEditor("root.specificOptions.hostList").getValue(); if (hostList !== "SELECT") { var host = conf_editor.getEditor("root.specificOptions.host").getValue(); if (host !== "") { canIdentify = true; canSave = true; } } break; case "nanoleaf": var hostList = conf_editor.getEditor("root.specificOptions.hostList").getValue(); if (hostList !== "SELECT") { var host = conf_editor.getEditor("root.specificOptions.host").getValue(); var token = conf_editor.getEditor("root.specificOptions.token").getValue(); if (host !== "" && token !== "") { canIdentify = true; canSave = true; } } break; default: canIdentify = false; canSave = true; } if (!conf_editor.validate().length) { if (canIdentify) { $("#btn_test_controller").show(); $('#btn_test_controller').attr('disabled', false); } else { $('#btn_test_controller').hide(); $('#btn_test_controller').attr('disabled', true); } } else { canSave = false; } if (canSave) { if (!window.readOnlyMode) { $('#btn_submit_controller').attr('disabled', false); } } else { $('#btn_submit_controller').attr('disabled', true); } window.readOnlyMode ? $('#btn_cl_save').attr('disabled', true) : $('#btn_submit').attr('disabled', false); window.readOnlyMode ? $('#btn_ma_save').attr('disabled', true) : $('#btn_submit').attr('disabled', false); window.readOnlyMode ? $('#leds_custom_save').attr('disabled', true) : $('#btn_submit').attr('disabled', false); }); conf_editor.watch('root.specificOptions.hostList', () => { var specOptPath = 'root.specificOptions.'; //Disable General Options, as LED count will be resolved from device itself conf_editor.getEditor("root.generalOptions").disable(); var hostList = conf_editor.getEditor("root.specificOptions.hostList"); if (hostList) { var val = hostList.getValue(); var showOptions = true; switch (val) { case 'CUSTOM': case '': conf_editor.getEditor(specOptPath + "host").enable(); conf_editor.getEditor(specOptPath + "host").setValue(""); break; case 'NONE': conf_editor.getEditor(specOptPath + "host").enable(); //Trigger getProperties via host value conf_editor.notifyWatchers(specOptPath + "host"); break; case 'SELECT': conf_editor.getEditor(specOptPath + "host").setValue(""); conf_editor.getEditor(specOptPath + "host").disable(); showOptions = false; break; default: conf_editor.getEditor(specOptPath + "host").disable(); conf_editor.getEditor(specOptPath + "host").setValue(val); //Trigger getProperties via host value conf_editor.notifyWatchers(specOptPath + "host"); break; } showAllDeviceInputOptions("hostList", showOptions); } }); conf_editor.watch('root.specificOptions.host', () => { var host = conf_editor.getEditor("root.specificOptions.host").getValue(); if (host === "") { conf_editor.getEditor("root.generalOptions.hardwareLedCount").setValue(1); } else { let params = {}; switch (ledType) { case "cololight": params = { host: host }; getProperties_device(ledType, host, params); break; case "nanoleaf": var token = conf_editor.getEditor("root.specificOptions.token").getValue(); if (token === "") { return; } params = { host: host, token: token }; getProperties_device(ledType, host, params); break; case "wled": params = { host: host, filter: "info" }; getProperties_device(ledType, host, params); break; case "udpraw": getProperties_device(ledType, host, params); break; default: } } }); conf_editor.watch('root.specificOptions.output', () => { var output = conf_editor.getEditor("root.specificOptions.output").getValue(); if (output === "NONE" || output === "SELECT" || output === "") { $('#btn_submit_controller').attr('disabled', true); $('#btn_test_controller').attr('disabled', true); $('#btn_test_controller').hide(); conf_editor.getEditor("root.generalOptions.hardwareLedCount").setValue(1); showAllDeviceInputOptions("output", false); } else { showAllDeviceInputOptions("output", true); let params = {}; var canIdentify = false; switch (ledType) { case "adalight": canIdentify = true; break; case "atmo": case "karate": params = { serialPort: output }; getProperties_device(ledType, output, params); break; case "dmx": case "sedu": case "tpm2": case "apa102": case "apa104": case "ws2801": case "lpd6803": case "lpd8806": case "p9813": case "sk6812spi": case "sk6822spi": case "sk9822": case "ws2812spi": case "piblaster": default: } if (!conf_editor.validate().length) { if (canIdentify) { $("#btn_test_controller").show(); $('#btn_test_controller').attr('disabled', false); } else { $('#btn_test_controller').hide(); $('#btn_test_controller').attr('disabled', true); } if (!window.readOnlyMode) { $('#btn_submit_controller').attr('disabled', false); } } } }); conf_editor.watch('root.specificOptions.subType', () => { var subType = conf_editor.getEditor("root.specificOptions.subType").getValue(); let params = {}; switch (ledType) { case "razer": params = { subType: subType }; getProperties_device(ledType, subType, params); break; default: } }); conf_editor.watch('root.specificOptions.token', () => { var token = conf_editor.getEditor("root.specificOptions.token").getValue(); if (token !== "") { let params = {}; var host = ""; switch (ledType) { case "nanoleaf": host = conf_editor.getEditor("root.specificOptions.host").getValue(); if (host === "") { return } params = { host: host, token: token }; break; default: } getProperties_device(ledType, host, params); } }); //Yeelight conf_editor.watch('root.specificOptions.lights', () => { //Disable General Options, as LED count will be resolved from number of lights configured conf_editor.getEditor("root.generalOptions").disable(); var hwLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount") if (hwLedCount) { var lights = conf_editor.getEditor("root.specificOptions.lights").getValue(); hwLedCount.setValue(lights.length); } }); //Philips Hue conf_editor.watch('root.specificOptions.lightIds', () => { //Disable General Options, as LED count will be resolved from number of lights configured conf_editor.getEditor("root.generalOptions").disable(); var hwLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount") if (hwLedCount) { var lights = conf_editor.getEditor("root.specificOptions.lightIds").getValue(); hwLedCount.setValue(lights.length); } }); //Atmo Orb conf_editor.watch('root.specificOptions.orbIds', () => { //Disable General Options, as LED count will be resolved from number of lights configured conf_editor.getEditor("root.generalOptions").disable(); var hwLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount") if (hwLedCount) { var lights = 0; var configruedOrbIds = conf_editor.getEditor("root.specificOptions.orbIds").getValue().trim(); if (configruedOrbIds.length !== 0) { lights = configruedOrbIds.split(",").map(Number); } hwLedCount.setValue(lights.length); } }); //Handle Hardware Led Count constraint list conf_editor.watch('root.generalOptions.hardwareLedCountList', () => { var hwLedCountSelected = conf_editor.getEditor("root.generalOptions.hardwareLedCountList").getValue(); conf_editor.getEditor("root.generalOptions.hardwareLedCount").setValue(Number(hwLedCountSelected)); }); }); //philipshueentertainment backward fix if (window.serverConfig.device.type == "philipshueentertainment") window.serverConfig.device.type = "philipshue"; // create led device selection var ledDevices = window.serverInfo.ledDevices.available; var optArr = [[]]; optArr[1] = []; optArr[2] = []; optArr[3] = []; optArr[4] = []; optArr[5] = []; for (var idx = 0; idx < ledDevices.length; idx++) { if ($.inArray(ledDevices[idx], devRPiSPI) != -1) optArr[0].push(ledDevices[idx]); else if ($.inArray(ledDevices[idx], devRPiPWM) != -1) optArr[1].push(ledDevices[idx]); else if ($.inArray(ledDevices[idx], devRPiGPIO) != -1) optArr[2].push(ledDevices[idx]); else if ($.inArray(ledDevices[idx], devNET) != -1) optArr[3].push(ledDevices[idx]); else if ($.inArray(ledDevices[idx], devSerial) != -1) optArr[4].push(ledDevices[idx]); else if ($.inArray(ledDevices[idx], devHID) != -1) optArr[4].push(ledDevices[idx]); else optArr[5].push(ledDevices[idx]); } $("#leddevices").append(createSel(optArr[0], $.i18n('conf_leds_optgroup_RPiSPI'))); $("#leddevices").append(createSel(optArr[1], $.i18n('conf_leds_optgroup_RPiPWM'))); $("#leddevices").append(createSel(optArr[2], $.i18n('conf_leds_optgroup_RPiGPIO'))); $("#leddevices").append(createSel(optArr[3], $.i18n('conf_leds_optgroup_network'))); $("#leddevices").append(createSel(optArr[4], $.i18n('conf_leds_optgroup_usb'))); if (storedAccess === 'expert' || window.serverConfig.device.type === "file") { $("#leddevices").append(createSel(optArr[5], $.i18n('conf_leds_optgroup_other'))); } $("#leddevices").val(window.serverConfig.device.type); $("#leddevices").trigger("change"); // Identify/ Test LED-Device $("#btn_test_controller").off().on("click", function () { var ledType = $("#leddevices").val(); let params = {}; switch (ledType) { case "cololight": case "wled": var host = conf_editor.getEditor("root.specificOptions.host").getValue(); params = { host: host }; break; case "nanoleaf": var host = conf_editor.getEditor("root.specificOptions.host").getValue(); var token = conf_editor.getEditor("root.specificOptions.token").getValue(); params = { host: host, token: token }; break; case "adalight": var currentLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount").getValue(); params = Object.assign(conf_editor.getEditor("root.generalOptions").getValue(), conf_editor.getEditor("root.specificOptions").getValue(), { currentLedCount } ); default: } identify_device(ledType, params); }); // Save LED device config $("#btn_submit_controller").off().on("click", function (event) { var hardwareLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount").getValue(); var layoutLedCount = aceEdt.get().length; if (hardwareLedCount === layoutLedCount) { saveLedConfig(false); } else { if (hardwareLedCount > layoutLedCount) { // More Hardware LEDs than on layout $('#id_body').html(''); $('#id_body').append('