Fix speed meterRIVM-47

This commit is contained in:
Mihail Slobodyanuk 2022-12-23 16:37:21 +02:00
parent 0dfd7e6d0e
commit e651b8c641

View file

@ -227,7 +227,13 @@ function togglePrivKeyVisibility() {
function humanReadableSpeed(speed) {
if (speed < 0) return "? B/s";
var i = speed < 1 ? 0 : Math.floor(Math.log(speed) / Math.log(1024));
return (speed / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B/s', 'kB/s', 'MB/s', 'GB/s', 'TB/s'][i];
var val = speed / Math.pow(1024, i);
var fixed = 2;
if((val.toFixed() * 1) > 9) {
fixed = 1;
val = val / 10
}
return val.toFixed(fixed) * 1 + ' ' + ['B/s', 'kB/s', 'MB/s', 'GB/s', 'TB/s'][i];
}
var ui = ui || {