mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +03:00
much simpler, less robust approach, fixes E+
This commit is contained in:
parent
e19705e4f4
commit
9e15e55e3f
1 changed files with 4 additions and 7 deletions
11
main.js
11
main.js
|
@ -237,13 +237,10 @@ function millitime() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bytesToSize(bytes) {
|
function bytesToSize(bytes) {
|
||||||
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
if (bytes < 1024) return bytes + ' Bytes';
|
||||||
var k = 1024;
|
else if (bytes < 1048576) return(bytes / 1024).toFixed(3) + ' KB';
|
||||||
|
else if (bytes < 1073741824) return(bytes / 1048576).toFixed(3) + ' MB';
|
||||||
if (bytes == 0) return '0 Bytes';
|
else return (bytes / 1073741824).toFixed(3) + ' GB';
|
||||||
|
|
||||||
var i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
||||||
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue