sdk: byte formatting
This commit is contained in:
parent
97b00b7143
commit
030c270e77
@ -5,8 +5,15 @@ var contented = (function ($, currentScriptPath) {
|
||||
var baseURL = currentScriptPath.replace('sdk.js', '');
|
||||
|
||||
var formatBytes = function(bytes) {
|
||||
// FIXME
|
||||
return Math.floor(bytes / (1024 * 1024)) + " MiB";
|
||||
if (bytes < 1024) {
|
||||
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";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user