mirror of
https://gitplac.si/aljaxus/upn-qr.git
synced 2025-12-17 04:00:59 +00:00
change image to "invalid" on error
This commit is contained in:
@@ -105,6 +105,7 @@ function updateQRdeb () {
|
|||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
function updateQR (e) {
|
function updateQR (e) {
|
||||||
|
try {
|
||||||
const qstring = [
|
const qstring = [
|
||||||
["client_name", val("client-name")],
|
["client_name", val("client-name")],
|
||||||
["client_address", val("client-address")],
|
["client_address", val("client-address")],
|
||||||
@@ -121,7 +122,11 @@ function updateQR (e) {
|
|||||||
const newurl = `/api/qrcode?${qstring}`
|
const newurl = `/api/qrcode?${qstring}`
|
||||||
const preloadImg = new Image();
|
const preloadImg = new Image();
|
||||||
preloadImg.addEventListener("load", () => qrcode.style.setProperty('background-image', `url("${newurl}"), url("/public/invalid-content.png")`))
|
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;
|
preloadImg.src=newurl;
|
||||||
|
} catch (error) {
|
||||||
|
setImgUrl(`url("/public/invalid-content.png")`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (el of inputs) {
|
for (el of inputs) {
|
||||||
el.addEventListener("input", updateQRdeb)
|
el.addEventListener("input", updateQRdeb)
|
||||||
|
|||||||
Reference in New Issue
Block a user