mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-08-24 16:05:07 +03:00
Fix speed meterRIVM-47
This commit is contained in:
parent
0dfd7e6d0e
commit
e651b8c641
1 changed files with 7 additions and 1 deletions
|
@ -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 || {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue