diff options
| author | altaf-creator <dev@altafcreator.com> | 2026-01-09 22:11:10 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2026-01-09 22:11:10 +0800 |
| commit | 85afbb89dd1ab32583b77a530f14c338fff0b29d (patch) | |
| tree | 21c75713c6ef9b0cc8d8591d5686e8a97fb949c6 /frontend | |
| parent | 36a1e21e3d85fd1faa70a60b1515826a551d2e28 (diff) | |
ajkhfsdjhkfdsa
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/.DS_Store | bin | 6148 -> 6148 bytes | |||
| -rw-r--r-- | frontend/assets/.DS_Store | bin | 6148 -> 6148 bytes | |||
| -rw-r--r-- | frontend/assets/img/step1.png | bin | 0 -> 57109 bytes | |||
| -rw-r--r-- | frontend/assets/img/step2.png | bin | 0 -> 81687 bytes | |||
| -rw-r--r-- | frontend/assets/img/step3.png | bin | 0 -> 63661 bytes | |||
| -rw-r--r-- | frontend/assets/img/step4.png | bin | 0 -> 17508 bytes | |||
| -rw-r--r-- | frontend/index.html | 11 | ||||
| -rw-r--r-- | frontend/index.js | 8 | ||||
| -rw-r--r-- | frontend/ios_popup.js | 9 | ||||
| -rw-r--r-- | frontend/main.js | 28 | ||||
| -rw-r--r-- | frontend/manifest.json | 2 | ||||
| -rw-r--r-- | frontend/permissionrequest.js | 9 | ||||
| -rw-r--r-- | frontend/popup.js | 12 | ||||
| -rw-r--r-- | frontend/start.js | 13 | ||||
| -rw-r--r-- | frontend/start/index.html | 18 | ||||
| -rw-r--r-- | frontend/status/index.html | 18 | ||||
| -rw-r--r-- | frontend/style.css | 52 |
17 files changed, 153 insertions, 27 deletions
diff --git a/frontend/.DS_Store b/frontend/.DS_Store Binary files differindex 49fe6a7..6e268de 100644 --- a/frontend/.DS_Store +++ b/frontend/.DS_Store diff --git a/frontend/assets/.DS_Store b/frontend/assets/.DS_Store Binary files differindex 320d9b9..d7e3230 100644 --- a/frontend/assets/.DS_Store +++ b/frontend/assets/.DS_Store diff --git a/frontend/assets/img/step1.png b/frontend/assets/img/step1.png Binary files differnew file mode 100644 index 0000000..4277a06 --- /dev/null +++ b/frontend/assets/img/step1.png diff --git a/frontend/assets/img/step2.png b/frontend/assets/img/step2.png Binary files differnew file mode 100644 index 0000000..7e24b63 --- /dev/null +++ b/frontend/assets/img/step2.png diff --git a/frontend/assets/img/step3.png b/frontend/assets/img/step3.png Binary files differnew file mode 100644 index 0000000..cbf88e8 --- /dev/null +++ b/frontend/assets/img/step3.png diff --git a/frontend/assets/img/step4.png b/frontend/assets/img/step4.png Binary files differnew file mode 100644 index 0000000..4a6801a --- /dev/null +++ b/frontend/assets/img/step4.png diff --git a/frontend/index.html b/frontend/index.html index f4768c2..f40c70c 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -24,15 +24,6 @@ </div> <a href="mailto:dev@altafcreator.com" class="feedback"><span>✉️ Bugs? Feedback?</span></a> <script src="/main.js"></script> - <script> - (async () => { - const timers = await fetchTimers(); - if (Array.isArray(timers[1]) && timers[1].length > 0) { - window.location.href = './timer/'; - } else { - window.location.href = './status/'; - } - })(); - </script> + <script src="/index.js"></script> </body> </html> diff --git a/frontend/index.js b/frontend/index.js new file mode 100644 index 0000000..a392eb8 --- /dev/null +++ b/frontend/index.js @@ -0,0 +1,8 @@ +(async () => { + const timers = await fetchTimers(); + if (Array.isArray(timers[1]) && timers[1].length > 0) { + window.location.href = './timer/'; + } else { + window.location.href = './status/'; + } +})(); diff --git a/frontend/ios_popup.js b/frontend/ios_popup.js new file mode 100644 index 0000000..0b700ed --- /dev/null +++ b/frontend/ios_popup.js @@ -0,0 +1,9 @@ +(async () => { +const cookie = await cookieStore.get("subscription_endpoint"); + +if (navigator.userAgent.match(/iPhone|iPad|iPod/i) + && !window.matchMedia('(display-mode: standalone)').matches + && !cookie) { + openPopup(); +} +})(); diff --git a/frontend/main.js b/frontend/main.js index d92d4ad..3f5c4c4 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -22,23 +22,33 @@ async function subscribe() { return; } + console.log(await Notification.requestPermission()); + const registration = await navigator.serviceWorker.ready; - const subscription = await registration.pushManager.subscribe({ - userVisibleOnly: true, - applicationServerKey: urlBase64ToUint8Array(PUBLIC_VAPID_KEY), - }); - console.log(subscription); - alert(subscription); + try { + const subscription = await registration.pushManager.subscribe({ + userVisibleOnly: true, + applicationServerKey: urlBase64ToUint8Array(PUBLIC_VAPID_KEY), + }); + console.log(subscription); + } catch (e) { + console.log("ERR in regis, ", e); + return false; + } - await fetch(`${API_URL}/notifsubscribe`, { + console.log("sw regis pass, write to db"); + + const db_reply = await fetch(`${API_URL}/notifsubscribe`, { method: 'POST', credentials: "include", body: JSON.stringify(subscription), headers: { "Content-Type": "application/json", }, - }) + }); + + return db_reply.status == 2000; } /// copied from somewhere @@ -108,6 +118,8 @@ async function start() { // --- information loading + cookie setting (from server) async function information(urlParam = null) { + const urlCookie = await cookieStore.get("last_used_url"); + const response = await fetch(`${API_URL}/info`, { credentials: "include", method: "POST", diff --git a/frontend/manifest.json b/frontend/manifest.json index d8aded6..4bbf313 100644 --- a/frontend/manifest.json +++ b/frontend/manifest.json @@ -1,6 +1,6 @@ { "$schema": "https://json.schemastore.org/web-manifest-combined.json", - "name": "Victoria Hall LaundryWeb", + "name": "LaundryWeb", "icons": [ { "src": "/assets/icons/512.png", diff --git a/frontend/permissionrequest.js b/frontend/permissionrequest.js index c6dbd88..1a90109 100644 --- a/frontend/permissionrequest.js +++ b/frontend/permissionrequest.js @@ -8,9 +8,14 @@ const notbtn = document.getElementById("notbtn"); } })(); -notbtn.addEventListener("click", () => requestPermission()) +notbtn.addEventListener("click", () => requestPermission()); async function requestPermission() { - subscribe(); + const sub_result = await subscribe(); + + if (!sub_result) { + return; + } + notif.style.display = "none"; // this is disgusting diff --git a/frontend/popup.js b/frontend/popup.js new file mode 100644 index 0000000..b7adf0a --- /dev/null +++ b/frontend/popup.js @@ -0,0 +1,12 @@ +const popupCloseBtn = document.getElementById("close-popup"); +const popupMaster = document.getElementById("popup-master") + +popupCloseBtn.addEventListener("mousedown", () => closePopup()); + +function closePopup() { + popupMaster.style.display = "none"; +} + +function openPopup() { + popupMaster.style.display = "flex"; +} diff --git a/frontend/start.js b/frontend/start.js index 2e71655..9208206 100644 --- a/frontend/start.js +++ b/frontend/start.js @@ -1,5 +1,12 @@ const startbtn = document.getElementById("startbtn"); +const urlParams = new URLSearchParams(window.location.search); +data.machine_id = urlParams.get('machine'); +remember +console.log(urlParams); + +startUpdateMachines(); + (async () => { const timers = await fetchTimers(); @@ -42,9 +49,3 @@ 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(); diff --git a/frontend/start/index.html b/frontend/start/index.html index 16bb433..3b43e40 100644 --- a/frontend/start/index.html +++ b/frontend/start/index.html @@ -71,6 +71,22 @@ </div> <button class="button bg-1" id="startbtn" disabled>Start</button> </div> + <div class="master-popup-container" id="popup-master"> + <div class="popup-container"> + <h1 style="text-align: center;">Initial Setup for iOS</h1> + <p>To allow notifications on your iOS device, you’ll need to install this website as a web app.</p> + <hr> + <p><b>Step 1:</b> Press ... (if using iOS 26) → <b>Share</b></p> + <img src="/assets/img/step1.png" alt=""> + <p><b>Step 2:</b> Scroll down → Select <b>Add to Home Screen</b></p> + <img src="/assets/img/step2.png" alt=""> + <p><b>Step 3:</b> Press <b>Add</b>. If you're using iOS 26+, ensure Open as Web App is enabled.</p> + <img src="/assets/img/step3.png" alt=""> + <p><b>Step 4:</b> Go to your home screen → Reopen this page by <b>pressing</b> the <b>LaundryWeb app</b>.</p> + <img src="/assets/img/step4.png" alt="" style="height: 72px; margin-bottom: 32px;"> + </div> + <button id="close-popup"></button> + </div> <div class="section-container credits-container"> <span>Developed by <a href="https://altafcreator.com">Athaalaa Altaf Hafidz</a>, a fellow resident • <a href="https://git.altafcreator.com/victoriahall-laundryweb.git/">Source Code</a></span> </div> @@ -78,5 +94,7 @@ <script src="/main.js"></script> <script src="/start.js"></script> <script src="/permissionrequest.js"></script> + <script src="/popup.js"></script> + <script src="/ios_popup.js"></script> </body> </html> diff --git a/frontend/status/index.html b/frontend/status/index.html index 2c1e7af..97c5504 100644 --- a/frontend/status/index.html +++ b/frontend/status/index.html @@ -99,6 +99,22 @@ </div> </div> </div> + <div class="master-popup-container" id="popup-master"> + <div class="popup-container"> + <h1 style="text-align: center;">Initial Setup for iOS</h1> + <p>To allow notifications on your iOS device, you’ll need to install this website as a web app.</p> + <hr> + <p><b>Step 1:</b> Press ... (if using iOS 26) → <b>Share</b></p> + <img src="/assets/img/step1.png" alt=""> + <p><b>Step 2:</b> Scroll down → Select <b>Add to Home Screen</b></p> + <img src="/assets/img/step2.png" alt=""> + <p><b>Step 3:</b> Press <b>Add</b>. If you're using iOS 26+, ensure Open as Web App is enabled.</p> + <img src="/assets/img/step3.png" alt=""> + <p><b>Step 4:</b> Go to your home screen → Reopen this page by <b>pressing</b> the <b>LaundryWeb app</b>.</p> + <img src="/assets/img/step4.png" alt="" style="height: 72px; margin-bottom: 32px;"> + </div> + <button id="close-popup"></button> + </div> <div class="section-container credits-container"> <span>Developed by <a href="https://altafcreator.com">Athaalaa Altaf Hafidz</a>, a fellow resident • <a href="https://git.altafcreator.com/victoriahall-laundryweb.git/">Source Code</a></span> </div> @@ -106,5 +122,7 @@ <script src="/main.js"></script> <script src="/status.js"></script> <script src="/permissionrequest.js"></script> + <script src="/popup.js"></script> + <script src="/ios_popup.js"></script> </body> </html> diff --git a/frontend/style.css b/frontend/style.css index a2a9041..6973278 100644 --- a/frontend/style.css +++ b/frontend/style.css @@ -25,6 +25,7 @@ body { gap: 16px; padding: 16px; font-family: "Interesting", sans-serif; + padding-bottom: 64px; } .section-container { @@ -293,6 +294,53 @@ a { font-size: 1.5rem; } +.master-popup-container { + z-index: 1234567; + background-color: rgba(0, 0, 0, 0.25); + width: 100%; + height: 100%; + position: fixed; + top: 0; + left: 0; + backdrop-filter: blur(6px); + padding: 16px; + padding-top: 64px; + padding-bottom: 64px; + box-sizing: border-box; + display: flex; + align-items: center; + display: none; +} + +.master-popup-container > button { + z-index: 1; + width: 100%; + height: 100%; + position: fixed; + left: 0; + top: 0; + opacity: 0; +} + +.popup-container { + z-index: 2; + background-color: white; + width: 100%; + max-height: 100%; + overflow-y: auto; + position: relative; + padding: 24px; + border-radius: 32px; + box-shadow: 0 0 16px rgba(0, 0, 0, 0.25); +} + +.popup-container > img { + margin-left: auto; + margin-right: auto; + display: block; + height: 192px; +} + #logo-id { font-size: 4rem; margin: 0; @@ -307,3 +355,7 @@ button { font-family: "Interesting", sans-serif; font-size: 1rem; } + +hr { + opacity: .25; +} |
