atpsoul 2012-05-10
http://codeaid.net/javascript/convert-size-in-bytes-to-human-readable-format-(javascript)
function bytesToSize (bytes) {
varsizes=['Bytes','KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB'];
if(bytes==0)return'n/a';
vari=parseInt(Math.floor(Math.log(bytes)/Math.log(1024)));
return((i==0)?(bytes/Math.pow(1024,i)):(bytes/Math.pow(1024,i)).toFixed(1))+''+sizes[i];
};