From 4b4c3fcbd59cb306481330c433b47eccda36121b Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Mon, 5 Sep 2022 10:53:10 -0500 Subject: [PATCH] Introduce delay before displaying QR code... --- Client/index.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Client/index.html b/Client/index.html index 5789611..1c8da10 100644 --- a/Client/index.html +++ b/Client/index.html @@ -7,6 +7,7 @@ let fileData, chunkSize, segmentPosition, + timoutHandle, activeCanvas = 0; // double buffering. const $ = (ele) => document.getElementById(ele); @@ -25,7 +26,7 @@ segmentPosition += chunkSize; if (segmentPosition < fileData.length) { - window.setTimeout(serveCodes, delay); + timoutHandle = window.setTimeout(serveCodes, delay); } }; const displayQR = (data, size, ecc) => { @@ -38,6 +39,8 @@ chunkSize = Number($("chunkSize").value); segmentPosition = Number($("startChunk").value * chunkSize); + timoutHandle && window.clearTimeout(timoutHandle); + var xhr = new XMLHttpRequest(); xhr.open("GET", fileName, true); xhr.responseType = "arraybuffer"; @@ -50,7 +53,7 @@ // it seems that the qr library doesn't support binary data - converting to base64 fileData = window.btoa(binaryString.join("")); window.scrollTo(0, 0); - serveCodes(); + timoutHandle = window.setTimeout(serveCodes, 3000); } }; xhr.send(); @@ -65,7 +68,7 @@
Status:...
- Filename: + Filename:
ECC (1-4):