add test payloads and clean up client
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
Decoder/a.png
|
||||
Decoder/chunks/
|
||||
Decoder/output.dat
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>QRTransfer</title>
|
||||
<script src="qrenc-4.0.0.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
let $ = (ele) => document.getElementById(ele);
|
||||
|
||||
let fileData,
|
||||
chunkSize,
|
||||
segmentPosition = 0,
|
||||
activeCanvas = 0;
|
||||
segmentPosition,
|
||||
activeCanvas = 0; // double buffering.
|
||||
|
||||
let serveCodes = () => {
|
||||
let numChunks = fileData.length / chunkSize;
|
||||
@@ -17,14 +18,18 @@
|
||||
let minLeft = ((numChunks - currChunk) * delay) / 1000 / 60;
|
||||
|
||||
$("status").innerText = `${currChunk}/${Math.ceil(numChunks)}/${(currChunk / numChunks).toFixed(2)}% (${minLeft.toFixed(2)} minutes left.)`;
|
||||
doqr(currChunk + "|" + fileData.substring(segmentPosition, segmentPosition + chunkSize), Number($("qrSize").value), Number($("ecc").value));
|
||||
displayQR(
|
||||
currChunk + 1 + "|" + fileData.substring(segmentPosition, segmentPosition + chunkSize),
|
||||
Number($("qrSize").value),
|
||||
Number($("ecc").value)
|
||||
);
|
||||
segmentPosition += chunkSize;
|
||||
|
||||
if (segmentPosition < fileData.length) {
|
||||
window.setTimeout(serveCodes, delay);
|
||||
}
|
||||
};
|
||||
let doqr = (data, size, ecc) => {
|
||||
let displayQR = (data, size, ecc) => {
|
||||
var qr = new QR($("qrcanv" + activeCanvas), data, size, size, ecc);
|
||||
$("qrcanv" + (activeCanvas === 0 ? 1 : 0)).style.display = "none";
|
||||
$("qrcanv" + activeCanvas).style.display = "block";
|
||||
@@ -45,6 +50,7 @@
|
||||
uInt8Array.map((x, idx) => (binaryString[idx] = String.fromCharCode(x)));
|
||||
// it seems that the qr library doesn't support binary data - converting to base64
|
||||
fileData = window.btoa(binaryString.join(""));
|
||||
window.scrollTo(0, 0);
|
||||
serveCodes();
|
||||
}
|
||||
};
|
||||
@@ -60,7 +66,7 @@
|
||||
<hr />
|
||||
Status:<span id="status">...</span>
|
||||
<hr />
|
||||
Filename:<input type="text" value="input.dat" id="inputFileName" />
|
||||
Filename:<input type="text" id="inputFileName" value="input.dat" />
|
||||
<br />
|
||||
ECC (1-4):<input type="number" value="4" id="ecc" />
|
||||
<br />
|
||||
|
||||
BIN
Client/testInput/5K.dat
Normal file
BIN
Client/testInput/5K.dat
Normal file
Binary file not shown.
Reference in New Issue
Block a user