Here you can find the source of formatSizeUnits(bytes)
/* Utilities *///from w w w . ja va 2s .c o m function formatSizeUnits(bytes){ if(bytes == 0) return '0 Bytes'; var k = 1000,dm = 2,sizes = ['B', 'kB', 'MB', 'GB', 'TB'], i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; }; String.prototype.UCFirst = function() {return this.charAt(0).toUpperCase() + this.slice(1);};
function formatSize(bytes) { if (bytes > 1024*1024*1024) { return Math.round(bytes/1024/1024/1024*100)/100+"GB"; if (bytes > 1024*1024) { return Math.round(bytes/1024/1024*10)/10+"MB"; if (bytes > 1024) { return Math.round(bytes/1024)+"KB"; ...