mirror of
https://github.com/wownero/diff-chart.git
synced 2026-11-10 09:53:56 +01:00
move formatBytes to util.js
This commit is contained in:
@@ -1,3 +1,14 @@
|
||||
// https://stackoverflow.com/a/18650828
|
||||
function formatBytes(bytes, decimal) {
|
||||
if (0 == bytes)
|
||||
return "0 bytes";
|
||||
var c = 1024;
|
||||
var d = decimal || 2;
|
||||
var e = ["bytes", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||
var f = Math.floor(Math.log(bytes) / Math.log(c));
|
||||
return "<b>" + parseFloat((bytes / Math.pow(c, f)).toFixed(d)) + "</b> " + e[f]
|
||||
}
|
||||
|
||||
function print_money(amount, decimal_point) {
|
||||
var s1 = String(amount);
|
||||
while (s1.length < decimal_point+1)
|
||||
|
||||
Reference in New Issue
Block a user