diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
| commit | 8eff962cab608341a6f2fedc640a0e32d96f26e2 (patch) | |
| tree | 05534d1a720ddc3691d346c69b4972555820a061 /frontend/main.js | |
pain
Diffstat (limited to 'frontend/main.js')
| -rw-r--r-- | frontend/main.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/frontend/main.js b/frontend/main.js new file mode 100644 index 0000000..e2a8a27 --- /dev/null +++ b/frontend/main.js @@ -0,0 +1,34 @@ +const btn = document.getElementById("notbtn") +btn.addEventListener("click", () => requestPermission()) +function requestPermission() { + console.log("Requesting permission..."); + Notification.requestPermission().then((permission) => { + if (permission === "granted") { + console.log("Notification permission granted."); + } + }); +} + +if ("serviceWorker" in navigator) { + navigator.serviceWorker + .register("OneSignalSDKWorker.js") + .then((reg) => console.log("SW registered:", reg)) + .catch((err) => console.error("SW failed:", err)); +} + +document.cookie = "session_key=0" + +const data = { + duration: 2, + block: 1, + machine: 2, +} + +fetch("http://localhost:8000/start", { + credentials: "include", + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(data) +}); |
