]> zoso.dev Git - nemo-wallet.git/commitdiff
Move barcode scanner into loading function.
authorChris Duncan <chris@zoso.dev>
Thu, 31 Oct 2024 01:48:16 +0000 (18:48 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 31 Oct 2024 01:48:16 +0000 (18:48 -0700)
app/pages/nemo-wallet.html

index 8d311950cd7aabfd69ec3eeccaef4adfe5422f87..5f614c330003134c8be7b3291104a380422ce055 100644 (file)
@@ -9,21 +9,6 @@
                src="https://fastly.jsdelivr.net/npm/barcode-detector@2/dist/es/side-effects.min.js"></script>
        <script>
                let libnemo, css
-               const barcodeDetector = new BarcodeDetector({
-                       formats: ["qr_code"],
-               })
-               const imageFile = await fetch(
-                       "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=Hello%20world!",
-               ).then(resp => resp.blob())
-               barcodeDetector.detect(imageFile).then(console.log)
-
-               const observer = new MutationObserver((mutations) => {
-                       for (const mutation of mutations) {
-                               if (mutation.type === "attributes") {
-                                       mutation.target.dispatchEvent(new Event('attributeschanged'))
-                               }
-                       }
-               })
 
                window.addEventListener('load', async (event) => {
                        try {
                async function loadNemo () {
                        console.log('loading libnemo')
                        libnemo = await import('https://cdn.jsdelivr.net/npm/libnemo@0.0.14/dist/main.min.js')
+                       const barcodeDetector = new BarcodeDetector({
+                               formats: ["qr_code"],
+                       })
+                       const imageFile = await fetch(
+                               "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=Hello%20world!",
+                       ).then(resp => resp.blob())
+                       barcodeDetector.detect(imageFile).then(console.log)
+
+                       const observer = new MutationObserver((mutations) => {
+                               for (const mutation of mutations) {
+                                       if (mutation.type === "attributes") {
+                                               mutation.target.dispatchEvent(new Event('attributeschanged'))
+                                       }
+                               }
+                       })
                        console.log('loaded libnemo')
                }