diff --git a/src/main/resources/static/qr-scanner.html b/src/main/resources/static/qr-scanner.html index 0a21dda5ff3bd1ed5d7cea32a1d216628d5c21a0..165972551b8360239977baed4cc7e3202e6eabe3 100644 --- a/src/main/resources/static/qr-scanner.html +++ b/src/main/resources/static/qr-scanner.html @@ -6,7 +6,7 @@ <meta name="viewpoint" content="width-device-width, initial-scale=1.0"> <link rel="stylesheet" href="css/qrstyle.css"> <script src="https://unpkg.com/html5-qrcode"></script> - <script type="module" src="scripts/qr-script.js"></script> + <script type="module" src="scripts/qr-script.mjs"></script> <title>QR Code</title> </head> diff --git a/src/main/resources/static/scripts/qr-script.js b/src/main/resources/static/scripts/qr-script.js index d75d9513e291ee39af4526a9b82dc1cdb31917fc..92ab7ddc54227f40a4130eb54e689e02feb3f61b 100644 --- a/src/main/resources/static/scripts/qr-script.js +++ b/src/main/resources/static/scripts/qr-script.js @@ -1,5 +1,4 @@ //qr-script file - R Nute -import {Html5QrcodeScanner} from "html5-qrcode"; function domReady(fn){ if ( diff --git a/src/main/resources/static/scripts/qr-script.mjs b/src/main/resources/static/scripts/qr-script.mjs new file mode 100644 index 0000000000000000000000000000000000000000..d75d9513e291ee39af4526a9b82dc1cdb31917fc --- /dev/null +++ b/src/main/resources/static/scripts/qr-script.mjs @@ -0,0 +1,25 @@ +//qr-script file - R Nute +import {Html5QrcodeScanner} from "html5-qrcode"; + +function domReady(fn){ + if ( + document.readyState === "complete" || + document.readyState === "interactive" + ){ + setTimeout(fn, 1000); + } else { + document.addEventListener("DOMContentLoaded", fn); + } +} +domReady(function (message){ + //if QR code found + function onScanSuccess(decodeText, decodeResult){ + alert("You have collected: " + decodeText, decodeResult); + } + let htmlscanner = new Html5QrcodeScanner( + "qr-code-reader", + { fps: 20, qrbos: 250} + ); + htmlscanner.render(onScanSuccess); +}); +