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/a.png
|
||||||
Decoder/chunks/
|
Decoder/chunks/
|
||||||
Decoder/output.dat
|
Decoder/output.dat
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<title>QRTransfer</title>
|
||||||
<script src="qrenc-4.0.0.js" type="text/javascript"></script>
|
<script src="qrenc-4.0.0.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
let $ = (ele) => document.getElementById(ele);
|
let $ = (ele) => document.getElementById(ele);
|
||||||
|
|
||||||
let fileData,
|
let fileData,
|
||||||
chunkSize,
|
chunkSize,
|
||||||
segmentPosition = 0,
|
segmentPosition,
|
||||||
activeCanvas = 0;
|
activeCanvas = 0; // double buffering.
|
||||||
|
|
||||||
let serveCodes = () => {
|
let serveCodes = () => {
|
||||||
let numChunks = fileData.length / chunkSize;
|
let numChunks = fileData.length / chunkSize;
|
||||||
@@ -17,14 +18,18 @@
|
|||||||
let minLeft = ((numChunks - currChunk) * delay) / 1000 / 60;
|
let minLeft = ((numChunks - currChunk) * delay) / 1000 / 60;
|
||||||
|
|
||||||
$("status").innerText = `${currChunk}/${Math.ceil(numChunks)}/${(currChunk / numChunks).toFixed(2)}% (${minLeft.toFixed(2)} minutes left.)`;
|
$("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;
|
segmentPosition += chunkSize;
|
||||||
|
|
||||||
if (segmentPosition < fileData.length) {
|
if (segmentPosition < fileData.length) {
|
||||||
window.setTimeout(serveCodes, delay);
|
window.setTimeout(serveCodes, delay);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let doqr = (data, size, ecc) => {
|
let displayQR = (data, size, ecc) => {
|
||||||
var qr = new QR($("qrcanv" + activeCanvas), data, size, size, ecc);
|
var qr = new QR($("qrcanv" + activeCanvas), data, size, size, ecc);
|
||||||
$("qrcanv" + (activeCanvas === 0 ? 1 : 0)).style.display = "none";
|
$("qrcanv" + (activeCanvas === 0 ? 1 : 0)).style.display = "none";
|
||||||
$("qrcanv" + activeCanvas).style.display = "block";
|
$("qrcanv" + activeCanvas).style.display = "block";
|
||||||
@@ -45,6 +50,7 @@
|
|||||||
uInt8Array.map((x, idx) => (binaryString[idx] = String.fromCharCode(x)));
|
uInt8Array.map((x, idx) => (binaryString[idx] = String.fromCharCode(x)));
|
||||||
// it seems that the qr library doesn't support binary data - converting to base64
|
// it seems that the qr library doesn't support binary data - converting to base64
|
||||||
fileData = window.btoa(binaryString.join(""));
|
fileData = window.btoa(binaryString.join(""));
|
||||||
|
window.scrollTo(0, 0);
|
||||||
serveCodes();
|
serveCodes();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -60,7 +66,7 @@
|
|||||||
<hr />
|
<hr />
|
||||||
Status:<span id="status">...</span>
|
Status:<span id="status">...</span>
|
||||||
<hr />
|
<hr />
|
||||||
Filename:<input type="text" value="input.dat" id="inputFileName" />
|
Filename:<input type="text" id="inputFileName" value="input.dat" />
|
||||||
<br />
|
<br />
|
||||||
ECC (1-4):<input type="number" value="4" id="ecc" />
|
ECC (1-4):<input type="number" value="4" id="ecc" />
|
||||||
<br />
|
<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