An attempt at improving readability.

This commit is contained in:
Herbert Wolverson 2024-07-19 12:32:59 -05:00
parent 3c2139be6a
commit aeae94cfcc
2 changed files with 9 additions and 35 deletions

View File

@ -62,20 +62,9 @@ export function formatThroughput(throughput, limitInMbps) {
if (limitBits > 0) {
percent = (throughput / limitBits) * 100;
}
let blob = "<span class='overlayThroughputWrapper'>";
blob += "<span class='overlayThroughputBar'>";
for (let i=0; i<100; i+=10) {
let color = lerpGreenToRedViaOrange(100-i, 100);
if (percent < i) {
blob += "░";
} else {
blob += "<span style='color: " + color + "'>█</span>";
}
}
blob += "</span>";
blob += "<span class='overlayThroughputNumber' style='color: white; font-weight: bold;'>" + scaleNumber(throughput, 1) + "bps</span>";
blob += "</span>";
let color = lerpGreenToRedViaOrange(100-percent, 100);
let blob = "<span style='color: " + color + "'>■</span>";
blob += "<span>" + scaleNumber(throughput, 1) + "bps</span>";
return blob;
}
@ -88,30 +77,16 @@ export function formatRtt(rtt) {
if (limit > 0) {
percent = (rtt / limit) * 100;
}
let blob = "<span class='overlayThroughputWrapper'>";
blob += "<span class='overlayThroughputBar'>";
for (let i=0; i<100; i+=10) {
let color = lerpGreenToRedViaOrange(100-i, 100);
if (percent < i) {
blob += "░";
} else {
blob += "<span style='color: " + color + "'>█</span>";
}
}
blob += "</span>";
blob += "<span class='overlayThroughputNumber' style='color: white; font-weight: bold;'>" + parseFloat(rtt).toFixed(0) + " ms</span>";
blob += "</span>";
let color = lerpGreenToRedViaOrange(100-percent, 100);
let blob = "<span style='color: " + color + "'>■</span>";
blob += "<span>" + parseFloat(rtt).toFixed(0) + "ms</span>";
return blob;
}
export function formatRetransmit(retransmits) {
let percent = Math.min(100, retransmits) / 100;
let color = lerpColor([0, 255, 0], [255, 0, 0], percent);
let html = "<span class='retransmits' style='color: " + color + "'>";
html += retransmits;
html += "</span>";
return html;
return "<span color=" + color + ">■</span>" + retransmits + "</span>";
}
export function formatCakeStat(n) {

View File

@ -4,7 +4,6 @@ import {
formatRetransmit,
formatRtt,
formatThroughput,
lerpGreenToRedViaOrange,
scaleNumber
} from "./helpers/scaling";
import {subscribeWS} from "./pubsub/ws";
@ -250,7 +249,7 @@ function treeUpdate(msg) {
col = document.getElementById("re-xmit-down-" + nodeId);
if (col !== null) {
if (node.current_retransmits[0] !== undefined) {
col.textContent = node.current_retransmits[0];
col.innerHTML = formatRetransmit(node.current_retransmits[0]);
} else {
col.textContent = "-";
}
@ -258,7 +257,7 @@ function treeUpdate(msg) {
col = document.getElementById("re-xmit-up-" + nodeId);
if (col !== null) {
if (node.current_retransmits[1] !== undefined) {
col.textContent = node.current_retransmits[1];
col.innerHTML = formatRetransmit(node.current_retransmits[1]);
} else {
col.textContent = "-";
}