From caa8f92d659b1829bba418c4083505194367e2c1 Mon Sep 17 00:00:00 2001 From: AKP Date: Wed, 9 Nov 2022 00:13:22 +0000 Subject: [PATCH] Alter 4 files Update `selectSite.js` Update `submit.js` Update `index.html` Update `web.py` --- circuit-laundry-notifier/static/selectSite.js | 16 ++++++++++++++++ circuit-laundry-notifier/static/submit.js | 16 ++++++++++++++++ circuit-laundry-notifier/templates/index.html | 1 + circuit-laundry-notifier/web.py | 10 ++++++++-- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/circuit-laundry-notifier/static/selectSite.js b/circuit-laundry-notifier/static/selectSite.js index a6e0bf9..2536c54 100644 --- a/circuit-laundry-notifier/static/selectSite.js +++ b/circuit-laundry-notifier/static/selectSite.js @@ -4,6 +4,22 @@ const selectSiteBlock = document.getElementById("select_site"); const nextButton = document.getElementById("select_site__next_button") const siteIDInput = document.getElementById("select_site__site_id_input") + siteIDInput.addEventListener("change", () => { + if (siteIDInput.value.trim() === "") { + localStorage.removeItem("site") + } else { + localStorage.setItem("site", siteIDInput.value.trim()) + } + }) + + document.addEventListener("load", () => { + const x = localStorage.getItem("site") + if (x === undefined) { + return + } + siteIDInput.value = x + }) + nextButton.addEventListener("click", () => { hide(errorIndicator) hide(selectSiteBlock) diff --git a/circuit-laundry-notifier/static/submit.js b/circuit-laundry-notifier/static/submit.js index 7f0121a..d4d4a49 100644 --- a/circuit-laundry-notifier/static/submit.js +++ b/circuit-laundry-notifier/static/submit.js @@ -4,6 +4,22 @@ const submitBlock = document.getElementById("submit") const nextButton = document.getElementById("submit__next_button") const ntfyTopicInput = document.getElementById("submit__ntfy_topic") + ntfyTopicInput.addEventListener("change", () => { + if (ntfyTopicInput.value.trim() === "") { + localStorage.removeItem("ntfy_topic") + } else { + localStorage.setItem("ntfy_topic", ntfyTopicInput.value.trim()) + } + }) + + document.addEventListener("load", () => { + const x = localStorage.getItem("ntfy_topic") + if (x === undefined) { + return + } + ntfyTopicInput.value = x + }) + nextButton.addEventListener("click", () => { hide(errorIndicator) hide(submitBlock) diff --git a/circuit-laundry-notifier/templates/index.html b/circuit-laundry-notifier/templates/index.html index fb54cb3..2b15376 100644 --- a/circuit-laundry-notifier/templates/index.html +++ b/circuit-laundry-notifier/templates/index.html @@ -27,6 +27,7 @@ +

You can find the Circuit site ID by going to this page, and selecting your accommodation. The site ID is the four digit number at the end of the URL.