aboutsummaryrefslogtreecommitdiff
path: root/script.js
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-11-13 14:02:15 +0100
committermetamuffin <metamuffin@disroot.org>2024-11-13 14:02:15 +0100
commitd190f228f5472e283a75b83802447c1acaf1832c (patch)
tree19e517e37ea113ead01b6f6c14f79edb38620e1d /script.js
parentdc4a5d1fe1d8b1f7eadd0b315ff9f7c4fe0dce31 (diff)
downloadabrechenbarkeit-d190f228f5472e283a75b83802447c1acaf1832c.tar
abrechenbarkeit-d190f228f5472e283a75b83802447c1acaf1832c.tar.bz2
abrechenbarkeit-d190f228f5472e283a75b83802447c1acaf1832c.tar.zst
return to start page after 30s idle
Diffstat (limited to 'script.js')
-rw-r--r--script.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/script.js b/script.js
index 2c23133..920b639 100644
--- a/script.js
+++ b/script.js
@@ -1,7 +1,23 @@
/// <reference lib="dom" />
+let idle_timer
+function reset_idle() {
+ if (idle_timer) clearTimeout(idle_timer)
+ idle_timer = setTimeout(() => {
+ if (window.location.pathname != "/" || window.location.search != "")
+ window.location.href = "/"
+ idle_timer = undefined
+ }, 30 * 1000)
+}
+
+document.addEventListener("DOMContentLoaded", () => {
+ reset_idle()
+})
document.addEventListener("keydown", ev => {
+ reset_idle()
if (ev.ctrlKey || ev.altKey) return
+ if (ev.code == "F5" || (ev.ctrlKey && ev.code == "KeyR"))
+ return window.location.reload() // reimplement reload for electron usage
if (!(document.activeElement instanceof HTMLInputElement)) {
if (ev.code.startsWith("Digit")) {
if (document.forms.buy_product)
@@ -23,3 +39,5 @@ document.addEventListener("keydown", ev => {
}
}
})
+document.addEventListener("mousemove", () => reset_idle())
+document.addEventListener("mousedown", () => reset_idle())