diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-12-01 18:06:09 +0700 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-12-01 18:06:09 +0700 |
| commit | 076791c52fc87b430e2bd0d36e5ef6fa11d6a782 (patch) | |
| tree | 53d4147d607980509844fa2792ff160bfe453135 /frontend | |
| parent | 182720dc2e9bcdc780194307629157efbb9d8578 (diff) | |
yay it works. changes to notification permission request
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/index.html | 2 | ||||
| -rw-r--r-- | frontend/start.js | 13 | ||||
| -rw-r--r-- | frontend/start/index.html | 2 |
3 files changed, 11 insertions, 6 deletions
diff --git a/frontend/index.html b/frontend/index.html index 0eeb0b0..c67b294 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -35,7 +35,7 @@ (async () => { const result = await checkUserStatus(); if (result != "you got laundry") { - window.location.href = './start/'; + window.location.href = './status/'; } else { window.location.href = './timer/'; } diff --git a/frontend/start.js b/frontend/start.js index 21c5a6d..5c9fc5d 100644 --- a/frontend/start.js +++ b/frontend/start.js @@ -8,14 +8,19 @@ console.log(urlParams); startUpdateMachines(); -const notbtn = document.getElementById("notbtn") +const notbtn = document.getElementById("notbtn"); +const startbtn = document.getElementById("startbtn"); notbtn.addEventListener("click", () => requestPermission()) async function requestPermission() { console.log("Requesting permission..."); - const onesig_res = await OneSignal.Notifications.requestPermission(); - alert(onesig_res); + const onesignal_result = await OneSignal.Notifications.requestPermission(); + if (onesignal_result) { + notif.remove(); + startbtn.disabled = false; + } } const notif = document.getElementById("notif-panel"); -if (Notification.permission == 'granted') { +if (OneSignal.Notifications.permission) { notif.remove(); + startbtn.disabled = false; } diff --git a/frontend/start/index.html b/frontend/start/index.html index bd7e407..0f8a0cf 100644 --- a/frontend/start/index.html +++ b/frontend/start/index.html @@ -71,7 +71,7 @@ <button id="notbtn" class="button bg-redder">Enable Required Permissions</button> </div> </div> - <button class="button bg-1" id="startbtn">Start</button> + <button class="button bg-1" id="startbtn" disabled>Start</button> </div> <script src="/main.js"></script> <script src="/start.js"></script> |
