Here you can find the source of formatSize(bytes)
function formatSize(bytes) { if (bytes > 1024*1024*1024) { return Math.round(bytes/1024/1024/1024*100)/100+"GB"; }/*ww w . ja v a 2s .com*/ if (bytes > 1024*1024) { return Math.round(bytes/1024/1024*10)/10+"MB"; } if (bytes > 1024) { return Math.round(bytes/1024)+"KB"; } }
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);};