mirror of
https://codeberg.org/metamuffin/abrechenbarkeit.git
synced 2025-01-30 18:51:41 +00:00
allow keys when redirecting barcode to buy product
This commit is contained in:
parent
86fe733e31
commit
f76fe6fa90
1 changed files with 6 additions and 4 deletions
10
script.js
10
script.js
|
@ -4,8 +4,8 @@ let idle_timer
|
||||||
function reset_idle() {
|
function reset_idle() {
|
||||||
if (idle_timer) clearTimeout(idle_timer)
|
if (idle_timer) clearTimeout(idle_timer)
|
||||||
idle_timer = setTimeout(() => {
|
idle_timer = setTimeout(() => {
|
||||||
if (window.location.pathname != "/" || window.location.search != "")
|
if (globalThis.location.pathname != "/" || globalThis.location.search != "")
|
||||||
window.location.href = "/"
|
globalThis.location.href = "/"
|
||||||
idle_timer = undefined
|
idle_timer = undefined
|
||||||
}, 30 * 1000)
|
}, 30 * 1000)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ document.addEventListener("keydown", ev => {
|
||||||
reset_idle()
|
reset_idle()
|
||||||
if (ev.ctrlKey || ev.altKey) return
|
if (ev.ctrlKey || ev.altKey) return
|
||||||
if (ev.code == "F5" || (ev.ctrlKey && ev.code == "KeyR"))
|
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 (!(document.activeElement instanceof HTMLInputElement)) {
|
||||||
if (ev.code.startsWith("Digit")) {
|
if (ev.code.startsWith("Digit")) {
|
||||||
if (document.forms.buy_product)
|
if (document.forms.buy_product)
|
||||||
|
@ -30,11 +30,13 @@ document.addEventListener("keydown", ev => {
|
||||||
} else if (ev.code.startsWith("Key") || ev.code == "Space") {
|
} else if (ev.code.startsWith("Key") || ev.code == "Space") {
|
||||||
if (document.forms.user_creation)
|
if (document.forms.user_creation)
|
||||||
return document.forms.user_creation.create_user.value += ev.key
|
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") {
|
} else if (ev.code == "Backspace") {
|
||||||
if (document.forms.user_creation)
|
if (document.forms.user_creation)
|
||||||
return document.forms.user_creation.create_user.value = ""
|
return document.forms.user_creation.create_user.value = ""
|
||||||
} else if (ev.code == "Escape") {
|
} else if (ev.code == "Escape") {
|
||||||
window.location.href = "/"
|
globalThis.location.href = "/"
|
||||||
ev.preventDefault()
|
ev.preventDefault()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue