|
|
|
|
@ -1163,9 +1163,10 @@ $.fn.filterAttr = function(attr_name, attr_value) { |
|
|
|
|
/** |
|
|
|
|
* Returns a human readable file size |
|
|
|
|
* @param {number} size Size in bytes |
|
|
|
|
* @param {boolean} skipSmallSizes return '< 1 kB' for small files |
|
|
|
|
* @return {string} |
|
|
|
|
*/ |
|
|
|
|
function humanFileSize(size) { |
|
|
|
|
function humanFileSize(size, skipSmallSizes) { |
|
|
|
|
var humanList = ['B', 'kB', 'MB', 'GB', 'TB']; |
|
|
|
|
// Calculate Log with base 1024: size = 1024 ** order
|
|
|
|
|
var order = size?Math.floor(Math.log(size) / Math.log(1024)):0; |
|
|
|
|
@ -1173,6 +1174,13 @@ function humanFileSize(size) { |
|
|
|
|
order = Math.min(humanList.length - 1, order); |
|
|
|
|
var readableFormat = humanList[order]; |
|
|
|
|
var relativeSize = (size / Math.pow(1024, order)).toFixed(1); |
|
|
|
|
if(skipSmallSizes === true && order === 0) { |
|
|
|
|
if(relativeSize !== "0.0"){ |
|
|
|
|
return '< 1 kB'; |
|
|
|
|
} else { |
|
|
|
|
return '0 kB'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(order < 2){ |
|
|
|
|
relativeSize = parseFloat(relativeSize).toFixed(0); |
|
|
|
|
} |
|
|
|
|
|