//**************************** // Wizard RGB byte order //**************************** const rgbByteOrderWizard = (() => { let wIntveralId; let new_rgb_order; function changeColor() { let color = $("#wiz_canv_color").css('background-color'); if (color == 'rgb(255, 0, 0)') { $("#wiz_canv_color").css('background-color', 'rgb(0, 255, 0)'); requestSetColor('0', '255', '0'); } else { $("#wiz_canv_color").css('background-color', 'rgb(255, 0, 0)'); requestSetColor('255', '0', '0'); } } function stopWizardRGB(reload) { console.log("stopWizardRGB - reload: ", reload); clearInterval(wIntveralId); resetWizard(reload); } function beginWizardRGB() { $("#wiz_switchtime_select").off().on('change', function () { clearInterval(wIntveralId); const time = $("#wiz_switchtime_select").val(); wIntveralId = setInterval(function () { changeColor(); }, time * 1000); }); $('.wselect').on("change", function () { let rgb_order = window.serverConfig.device.colorOrder.split(""); const redS = $("#wiz_r_select").val(); const greenS = $("#wiz_g_select").val(); const blueS = rgb_order.toString().replace(/,/g, "").replace(redS, "").replace(greenS, ""); for (const color of rgb_order) { if (redS == color) $('#wiz_g_select option[value=' + color + ']').prop('disabled', true); else $('#wiz_g_select option[value=' + color + ']').prop('disabled', false); if (greenS == color) $('#wiz_r_select option[value=' + color + ']').prop('disabled', true); else $('#wiz_r_select option[value=' + color + ']').prop('disabled', false); } if (redS != 'null' && greenS != 'null') { $('#btn_wiz_save').prop('disabled', false); for (let i = 0; i < rgb_order.length; i++) { if (rgb_order[i] == "r") rgb_order[i] = redS; else if (rgb_order[i] == "g") rgb_order[i] = greenS; else rgb_order[i] = blueS; } rgb_order = rgb_order.toString().replace(/,/g, ""); if (redS == "r" && greenS == "g") { $('#btn_wiz_save').toggle(false); $('#btn_wiz_checkok').toggle(true); window.readOnlyMode ? $('#btn_wiz_checkok').prop('disabled', true) : $('#btn_wiz_checkok').prop('disabled', false); } else { $('#btn_wiz_save').toggle(true); window.readOnlyMode ? $('#btn_wiz_save').prop('disabled', true) : $('#btn_wiz_save').prop('disabled', false); $('#btn_wiz_checkok').toggle(false); } new_rgb_order = rgb_order; } else $('#btn_wiz_save').prop('disabled', true); }); $("#wiz_switchtime_select").append(createSelOpt('5', '5'), createSelOpt('10', '10'), createSelOpt('15', '15'), createSelOpt('30', '30')); $("#wiz_switchtime_select").trigger('change'); $("#wiz_r_select").append(createSelOpt("null", ""), createSelOpt('r', $.i18n('general_col_red')), createSelOpt('g', $.i18n('general_col_green')), createSelOpt('b', $.i18n('general_col_blue'))); $("#wiz_g_select").html($("#wiz_r_select").html()); $("#wiz_r_select").trigger('change'); requestSetColor('255', '0', '0'); setTimeout(requestSetSource, 100, 'auto'); setStorage("wizardactive", true); $('#btn_wiz_abort').off().on('click', function () { stopWizardRGB(true); }); $('#btn_wiz_checkok').off().on('click', function () { showInfoDialog('success', "", $.i18n('infoDialog_wizrgb_text')); stopWizardRGB(); }); $('#btn_wiz_save').off().on('click', function () { stopWizardRGB(); window.serverConfig.device.colorOrder = new_rgb_order; requestWriteConfig({ "device": window.serverConfig.device }); }); } return { start: function () { //create html $('#wiz_header').html('' + $.i18n('wiz_rgb_title')); $('#wizp1_body').html('

' + $.i18n('wiz_rgb_title') + '

' + $.i18n('wiz_rgb_intro1') + '

' + $.i18n('wiz_rgb_intro2') + '

'); $('#wizp1_footer').html(''); $('#wizp2_body').html('

' + $.i18n('wiz_rgb_expl') + '

'); $('#wizp2_body').append('
' + $.i18n('edt_append_s') + '
'); $('#wizp2_body').append(''); $('#wizp2_body').append('
'); $('#wizp2_footer').html(''); if (getStorage("darkMode") == "on") $('#wizard_logo').attr("src", 'img/hyperion/logo_negativ.png'); //open modal $("#wizard_modal").modal({ backdrop: "static", keyboard: false, show: true }); //listen for continue $('#btn_wiz_cont').off().on('click', function () { beginWizardRGB(); $('#wizp1').toggle(false); $('#wizp2').toggle(true); }); } }; })(); export { rgbByteOrderWizard };