mirror of
https://codeberg.org/metamuffin/abrechenbarkeit.git
synced 2024-12-26 23:24:36 +00:00
return to start page after 30s idle
This commit is contained in:
parent
dc4a5d1fe1
commit
d190f228f5
1 changed files with 18 additions and 0 deletions
18
script.js
18
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())
|
||||
|
|
Loading…
Reference in a new issue