diff --git a/apps/qrcode/custom.html b/apps/qrcode/custom.html index 6c753d294..a92b46338 100644 --- a/apps/qrcode/custom.html +++ b/apps/qrcode/custom.html @@ -47,7 +47,9 @@
Try your QR Code:
+Click
@@ -95,6 +97,7 @@ return qrstring; } function refreshQRCode(){ + document.getElementById("errors").innerText=""; qrcode.clear(); // clear the code. var qrText = ""; if(document.getElementById("useWIFI").checked){ @@ -109,10 +112,17 @@ } qrcode._htOption.text = qrText; qrcode._htOption.correctLevel = parseInt(document.getElementById("correction").value); - qrcode.makeCode(qrText); + try { + qrcode.makeCode(qrText); + } catch (error) { + document.getElementById("errors").innerText="Error: QR could not be created."; + console.error(error); + } var integerScale = Math.max(Math.floor(targetSize / (qrcode._oQRCode.moduleCount + 1)),1); + if (integerScale == 1) document.getElementById("errors").innerText = "Warning, QR will probably be too small to properly scan. Try less data or less error correction."; + finalSizeQr = integerScale * (qrcode._oQRCode.moduleCount + 1); finalSizeCanvas = finalSizeQr - 1; @@ -121,8 +131,12 @@ document.getElementsByTagName("canvas")[0].width = finalSizeCanvas; document.getElementsByTagName("canvas")[0].height = finalSizeCanvas; - - qrcode.makeCode(qrText); + try { + qrcode.makeCode(qrText); + } catch (error) { + document.getElementById("errors").innerText="Error: QR could not be created."; + console.error(error); + } } var qrcode;