X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=roojs-core-debug.js;h=cb3923e5362d7b613c04a7ee46dc9ba6f06058d0;hb=8946284bad10596673ce59afe8ef1ea49ba0b790;hp=02931daa5c88f509cf5f217c31e1936eb2bc1cd3;hpb=c3fae677247c171d616820f63a06609c27abacb3;p=roojs1 diff --git a/roojs-core-debug.js b/roojs-core-debug.js index 02931daa5c..cb3923e536 100644 --- a/roojs-core-debug.js +++ b/roojs-core-debug.js @@ -13990,7 +13990,26 @@ Roo.util.Format = function(){ */ stripTags : function(v){ return !v ? v : String(v).replace(this.stripTagsRE, ""); + }, + + /** + * Size in Mb,Gb etc. + * @param {Number} value The number to be formated + * @param {number} decimals how many decimal places + * @return {String} the formated string + */ + size : function(value, decimals) + { + var sizes = ['b', 'k', 'M', 'G', 'T']; + if (value == 0) { + return 0; + } + var i = parseInt(Math.floor(Math.log(value) / Math.log(1024))); + return Roo.util.Format.number(value/ Math.pow(1024, i) ,decimals) + sizes[i]; } + + + }; }(); Roo.util.Format.defaults = {