sdk: byte formatting

This commit is contained in:
mappu 2017-10-08 15:07:04 +13:00
parent 97b00b7143
commit 030c270e77

View File

@ -5,8 +5,15 @@ var contented = (function ($, currentScriptPath) {
var baseURL = currentScriptPath.replace('sdk.js', ''); var baseURL = currentScriptPath.replace('sdk.js', '');
var formatBytes = function(bytes) { var formatBytes = function(bytes) {
// FIXME if (bytes < 1024) {
return Math.floor(bytes / (1024 * 1024)) + " MiB"; return bytes + " B";
} else if (bytes < (1024*1024)) {
return (bytes / 1024).toFixed(1) + " KiB";
} else if (bytes < (1024*1024*1024)) {
return (bytes / (1024*1024)).toFixed(1) + " MiB";
} else {
return (bytes / (1024*1024*1024)).toFixed(1) + " GiB";
}
}; };
/** /**