This commit is contained in:
Mihail Slobodyanuk 2022-12-20 19:04:22 +02:00
parent 3903fb6113
commit 4042cf3118
2 changed files with 10 additions and 8 deletions

View file

@ -232,8 +232,9 @@ function togglePrivKeyVisibility() {
} }
function humanReadableSpeed(speed) { function humanReadableSpeed(speed) {
var i = speed == 0 ? 0 : Math.floor(Math.log(speed) / Math.log(1024)); if (speed < 0) return "? B/s";
return (speed / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['Bps', 'kBps', 'MBps', 'GBps', 'TBps'][i]; var i = speed < 1 ? 0 : Math.floor(Math.log(speed) / Math.log(1024));
return (speed / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['bps', 'kbps', 'Mbps', 'Gbps', 'Tbps'][i];
} }
var ui = ui || { var ui = ui || {
@ -348,8 +349,8 @@ ui.updateSpeed = function (peers) {
ui._rsbytes = rsbytes; ui._rsbytes = rsbytes;
} else { } else {
delete ui._rsbytes; delete ui._rsbytes;
$("dn_speed").innerText = "? Bs"; $("dn_speed").innerText = humanReadableSpeed(-1);
$("up_speed").innerText = "? Bs"; $("up_speed").innerText = humanReadableSpeed(-1);
} }
}; };

View file

@ -225,8 +225,9 @@ function togglePrivKeyVisibility() {
} }
function humanReadableSpeed(speed) { function humanReadableSpeed(speed) {
var i = speed == 0 ? 0 : Math.floor(Math.log(speed) / Math.log(1024)); if (speed < 0) return "? B/s";
return (speed / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['Bps', 'kBps', 'MBps', 'GBps', 'TBps'][i]; var i = speed < 1 ? 0 : Math.floor(Math.log(speed) / Math.log(1024));
return (speed / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['bps', 'kbps', 'Mbps', 'Gbps', 'Tbps'][i];
} }
var ui = ui || { var ui = ui || {
@ -327,8 +328,8 @@ ui.updateSpeed = peers => {
ui._rsbytes = rsbytes; ui._rsbytes = rsbytes;
} else { } else {
delete ui._rsbytes; delete ui._rsbytes;
$("dn_speed").innerText = "? Bs"; $("dn_speed").innerText = humanReadableSpeed(-1);
$("up_speed").innerText = "? Bs"; $("up_speed").innerText = humanReadableSpeed(-1);
} }
} }