diff --git a/index.html b/index.html
index c498a67..c5b6993 100644
--- a/index.html
+++ b/index.html
@@ -70,6 +70,9 @@
Decoded
Bytes: N/A
Length CRC-8: N/A
+
Text:
diff --git a/index.js b/index.js
index aa75126..bffe6d1 100644
--- a/index.js
+++ b/index.js
@@ -1169,6 +1169,7 @@ function updateReceivedData() {
), CRC_BIT_COUNT
);
const trustedLength = transmissionByteCountCrc === transmissionByteCountActualCrc;
+ const totalBitsTransferring = parseTotalBitsTransferring(allDecodedBits);
// reduce all decoded bits based on original data sent
allDecodedBits = removeDecodedHeadersAndPadding(allDecodedBits);
@@ -1184,6 +1185,10 @@ function updateReceivedData() {
const correctEncodedBits = allEncodedBits.filter((b, i) => i < encodedBitCount && b === SENT_ENCODED_BITS[i]).length;
const correctedDecodedBits = allDecodedBits.filter((b, i) => i < decodedBitCount && b === SENT_ORIGINAL_BITS[i]).length;
+ const receivedProgess = document.getElementById('received-progress');
+ let percentReceived = allRawBits.length / totalBitsTransferring;
+ receivedProgess.style.width = `${Math.floor(Math.min(1, percentReceived) * 100)}%`;
+
document.getElementById('received-raw-bits').innerHTML = allRawBits
.reduce(
bitExpectorReducer(
@@ -1235,14 +1240,25 @@ function updateReceivedData() {
function asHex(length) {
return (number) => number.toString(16).padStart(length, '0').toUpperCase();
}
-function parseTransmissionByteCountCrc(bits) {
- const offset = MAXIMUM_PACKETIZATION_SIZE_BITS;
- bits = bits.slice(offset, offset+8);
- return bitsToInt(bits, 8);
+function parseTotalBitsTransferring(decodedBits) {
+ const dataByteCount = parseTransmissionByteCount(decodedBits);
+ const bitCount = getPacketizationBitCount(dataByteCount * 8);
+ const segments = getTotalSegmentCount(bitCount);
+ return segments * getChannels().length;
}
-function parseTransmissionByteCount(bits) {
- bits = bits.slice(0, MAXIMUM_PACKETIZATION_SIZE_BITS);
- return bitsToInt(bits, MAXIMUM_PACKETIZATION_SIZE_BITS);
+function parseTransmissionByteCountCrc(decodedBits) {
+ const offset = MAXIMUM_PACKETIZATION_SIZE_BITS;
+ decodedBits = decodedBits.slice(offset, offset + CRC_BIT_COUNT);
+ return bitsToInt(decodedBits, CRC_BIT_COUNT);
+}
+function parseTransmissionByteCount(decodedBits) {
+ decodedBits = decodedBits.slice(0, MAXIMUM_PACKETIZATION_SIZE_BITS);
+ while(decodedBits.length < MAXIMUM_PACKETIZATION_SIZE_BITS) {
+ // assume maximum value possible
+ // until we have enough bits to find the real size
+ decodedBits.push(1);
+ }
+ return bitsToInt(decodedBits, MAXIMUM_PACKETIZATION_SIZE_BITS);
}
function removeEncodedPadding(bits) {
const sizeBits = MAXIMUM_PACKETIZATION_SIZE_BITS;
diff --git a/style.css b/style.css
index 4443a17..3f19aca 100644
--- a/style.css
+++ b/style.css
@@ -21,6 +21,29 @@ body {
canvas {
background-color: black;
}
+.progress-container {
+ width: 100%;
+ height: 20px;
+ border: 1px solid black;
+ background-color: darkslategray;
+}
+.progress-bar {
+ height: 100%;
+ min-height: 14px;
+ background-color: yellow;
+ position: relative;
+ z-index: 2;
+ left: 0;
+ /* transition: width 0.3s ease; */
+}
+.xprogress-container::after {
+ content: attr(data-percent) '%';
+ position: relative;
+ z-index: 2;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+}
.raw-data {
background-color: rgb(41, 59, 10);
color: rgb(75, 185, 75);