change image to "invalid" on error

This commit is contained in:
Aljaz S
2021-11-25 12:37:09 +01:00
parent 4c2885855f
commit 432367d91b

View File

@@ -105,6 +105,7 @@ function updateQRdeb () {
}, 500);
}
function updateQR (e) {
try {
const qstring = [
["client_name", val("client-name")],
["client_address", val("client-address")],
@@ -121,7 +122,11 @@ function updateQR (e) {
const newurl = `/api/qrcode?${qstring}`
const preloadImg = new Image();
preloadImg.addEventListener("load", () => qrcode.style.setProperty('background-image', `url("${newurl}"), url("/public/invalid-content.png")`))
preloadImg.addEventListener("error", () => qrcode.style.setProperty('background-image', `url("/public/invalid-content.png")`))
preloadImg.src=newurl;
} catch (error) {
setImgUrl(`url("/public/invalid-content.png")`)
}
}
for (el of inputs) {
el.addEventListener("input", updateQRdeb)