/
wizard.js
executable file
·73 lines (64 loc) · 2.03 KB
/
wizard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//clear priority and other tasks if people reload the page or lost connection while a wizard was active
$(window.hyperion).one("ready", function (event) {
if (getStorage("wizardactive") === 'true') {
requestPriorityClear();
setStorage("wizardactive", false);
}
});
$("#btn_wizard_colorcalibration").click(async function () {
const { colorCalibrationKodiWizard } = await import('./wizards/colorCalibrationKodiWizard.js');
colorCalibrationKodiWizard.start();
});
$('#btn_wizard_byteorder').on('click', async () => {
const { rgbByteOrderWizard } = await import('./wizards/rgbByteOrderWizard.js');
rgbByteOrderWizard.start();
});
function resetWizard(reload) {
$("#wizard_modal").modal('hide');
requestPriorityClear();
setStorage("wizardactive", false);
$('#wizp1').toggle(true);
$('#wizp2').toggle(false);
$('#wizp3').toggle(false);
if (!reload) {
location.reload();
}
}
function createLedDeviceWizards(ledType) {
let data = {};
let title;
$('#btn_wiz_holder').html("");
$('#btn_led_device_wiz').off();
if (ledType == "philipshue") {
$('#btn_wiz_holder').show();
data = { ledType };
title = 'wiz_hue_title';
}
else if (ledType == "nanoleaf") {
$('#btn_wiz_holder').hide();
data = { ledType };
title = 'wiz_nanoleaf_user_auth_title';
}
else if (ledType == "atmoorb") {
$('#btn_wiz_holder').show();
data = { ledType };
title = 'wiz_atmoorb_title';
}
else if (ledType == "yeelight") {
$('#btn_wiz_holder').show();
data = { ledType };
title = 'wiz_yeelight_title';
}
if (Object.keys(data).length !== 0) {
startLedDeviceWizard(data, title, ledType + "Wizard");
}
}
function startLedDeviceWizard(data, hint, wizardName) {
$('#btn_wiz_holder').html("")
createHint("wizard", $.i18n(hint), "btn_wiz_holder", "btn_led_device_wiz");
$('#btn_led_device_wiz').off();
$('#btn_led_device_wiz').on('click', async (e) => {
const { [wizardName]: winzardObject } = await import('./wizards/LedDevice_' + data.ledType + '.js');
winzardObject.start(e);
});
}