much simpler, less robust approach, fixes E+

pull/3/head
cTn 10 years ago
parent e19705e4f4
commit 9e15e55e3f

@ -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…
Cancel
Save