From 85afbb89dd1ab32583b77a530f14c338fff0b29d Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Fri, 9 Jan 2026 22:11:10 +0800 Subject: ajkhfsdjhkfdsa --- frontend/.DS_Store | Bin 6148 -> 6148 bytes frontend/assets/.DS_Store | Bin 6148 -> 6148 bytes frontend/assets/img/step1.png | Bin 0 -> 57109 bytes frontend/assets/img/step2.png | Bin 0 -> 81687 bytes frontend/assets/img/step3.png | Bin 0 -> 63661 bytes frontend/assets/img/step4.png | Bin 0 -> 17508 bytes frontend/index.html | 11 +-------- frontend/index.js | 8 +++++++ frontend/ios_popup.js | 9 ++++++++ frontend/main.js | 28 ++++++++++++++++------- frontend/manifest.json | 2 +- frontend/permissionrequest.js | 9 ++++++-- frontend/popup.js | 12 ++++++++++ frontend/start.js | 13 ++++++----- frontend/start/index.html | 18 +++++++++++++++ frontend/status/index.html | 18 +++++++++++++++ frontend/style.css | 52 ++++++++++++++++++++++++++++++++++++++++++ 17 files changed, 153 insertions(+), 27 deletions(-) create mode 100644 frontend/assets/img/step1.png create mode 100644 frontend/assets/img/step2.png create mode 100644 frontend/assets/img/step3.png create mode 100644 frontend/assets/img/step4.png create mode 100644 frontend/index.js create mode 100644 frontend/ios_popup.js create mode 100644 frontend/popup.js diff --git a/frontend/.DS_Store b/frontend/.DS_Store index 49fe6a7..6e268de 100644 Binary files a/frontend/.DS_Store and b/frontend/.DS_Store differ diff --git a/frontend/assets/.DS_Store b/frontend/assets/.DS_Store index 320d9b9..d7e3230 100644 Binary files a/frontend/assets/.DS_Store and b/frontend/assets/.DS_Store differ diff --git a/frontend/assets/img/step1.png b/frontend/assets/img/step1.png new file mode 100644 index 0000000..4277a06 Binary files /dev/null and b/frontend/assets/img/step1.png differ diff --git a/frontend/assets/img/step2.png b/frontend/assets/img/step2.png new file mode 100644 index 0000000..7e24b63 Binary files /dev/null and b/frontend/assets/img/step2.png differ diff --git a/frontend/assets/img/step3.png b/frontend/assets/img/step3.png new file mode 100644 index 0000000..cbf88e8 Binary files /dev/null and b/frontend/assets/img/step3.png differ diff --git a/frontend/assets/img/step4.png b/frontend/assets/img/step4.png new file mode 100644 index 0000000..4a6801a Binary files /dev/null and b/frontend/assets/img/step4.png differ 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 @@ ✉️ Bugs? Feedback? - + 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 @@ +
Developed by Athaalaa Altaf Hafidz, a fellow resident • Source Code
@@ -78,5 +94,7 @@ + + 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 @@ +
Developed by Athaalaa Altaf Hafidz, a fellow resident • Source Code
@@ -106,5 +122,7 @@ + + 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; +} -- cgit v1.2.3