allow keys when redirecting barcode to buy product

This commit is contained in:
metamuffin 2025-01-21 19:06:43 +01:00
parent 86fe733e31
commit f76fe6fa90
No known key found for this signature in database
GPG key ID: 718F9749DCDBD654

View file

@ -4,8 +4,8 @@ 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 = "/"
if (globalThis.location.pathname != "/" || globalThis.location.search != "")
globalThis.location.href = "/"
idle_timer = undefined
}, 30 * 1000)
}
@ -17,7 +17,7 @@ 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
return globalThis.location.reload() // reimplement reload for electron usage
if (!(document.activeElement instanceof HTMLInputElement)) {
if (ev.code.startsWith("Digit")) {
if (document.forms.buy_product)
@ -30,11 +30,13 @@ document.addEventListener("keydown", ev => {
} else if (ev.code.startsWith("Key") || ev.code == "Space") {
if (document.forms.user_creation)
return document.forms.user_creation.create_user.value += ev.key
if (document.forms.buy_product)
return document.forms.buy_product.pcode.value += ev.key
} else if (ev.code == "Backspace") {
if (document.forms.user_creation)
return document.forms.user_creation.create_user.value = ""
} else if (ev.code == "Escape") {
window.location.href = "/"
globalThis.location.href = "/"
ev.preventDefault()
}
}