blob: e87798a7d453a000aca92071d23c103f6b944e9f (
plain)
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
|
(async () => {
const timers = await fetchTimers();
console.log("timers: (start.js) " + timers);
const existingPanel = document.getElementById("existing-laundry-panel");
const existingText = document.getElementById("existing-laundry-text");
if (Array.isArray(timers[1]) && timers[1].length > 0) {
existingPanel.style.display = 'inherit';
if (timers[1].length == 1) {
existingText.innerText = "You currently have another ongoing laundry. You are creating a new timer.";
} else {
existingText.innerText = "You currently have other ongoing laundries. You are creating a new timer.";
}
}
const info = await information(data.machine_id);
const machine = await info["machine"];
console.log(`machine is ${machine}`);
const divs = [
document.getElementById("dryer1"),
document.getElementById("washer1"),
document.getElementById("dryer2"),
document.getElementById("washer2"),
]
divs[machine - 1].classList.add("machine-selected");
})();
const notif = document.getElementById("notif-panel");
const notbtn = document.getElementById("notbtn");
const startbtn = document.getElementById("startbtn");
startbtn.addEventListener("click", () => {
start();
});
const urlParams = new URLSearchParams(window.location.search);
data.machine_id = urlParams.get('machine');
console.log(urlParams);
startUpdateMachines();
OneSignalDeferred.push(async function(OneSignal) {
try {
if (OneSignal.Notifications.permission) {
notif.remove();
startbtn.disabled = false;
}
data.onesignal_subscription_id = OneSignal.User.PushSubscription["id"];
}
catch (e) {
console.error("onesignal error ", e);
}
});
console.log("notbtn")
notbtn.addEventListener("click", () => requestPermission())
async function requestPermission() {
console.log("Requesting permission...");
const onesignal_result = await OneSignal.Notifications.requestPermission();
if (onesignal_result) {
notif.remove();
startbtn.disabled = false;
}
}
|