Added size formater

This commit is contained in:
Kenneth Skovhede
2014-03-19 12:51:49 +01:00
parent e59159b284
commit 080baa2aea
+13
View File
@@ -188,6 +188,19 @@ $(document).ready(function() {
}
};
var formatSizes = ['TB', 'GB', 'MB', 'KB'];
$.formatSizeString = function(val) {
val = parseInt(val || 0);
var max = formatSizes.length;
for(var i = 0; i < formatSizes.length; i++) {
var m = Math.pow(1024, max - i);
if (val > m)
return (val / m).toFixed(2) + ' ' + formatSizes[i];
}
return val + ' ' + bytes;
};
var serverWithCallback = function(data, callback, errorhandler, refreshMethod) {
if (typeof(data) == typeof(''))
data = { action: data };