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) { if (OneSignal.Notifications.permission) { notif.remove(); startbtn.disabled = false; } data.onesignal_subscription_id = OneSignal.User.PushSubscription["id"] ; }); 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; } } (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 (timers[1].length > 0) { existingPanel.style.display = 'inherit'; if (timers.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."; } } })();