mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
toFixed is busted, workaround
This commit is contained in:
parent
6452e927ea
commit
71096182be
|
@ -236,7 +236,7 @@ function U2pvis(act, btns) {
|
||||||
p = r.perc(nb, 0, fobj.size, fobj.t_hashing);
|
p = r.perc(nb, 0, fobj.size, fobj.t_hashing);
|
||||||
|
|
||||||
fo.hp = '{0}%, {1}, {2} MB/s'.format(
|
fo.hp = '{0}%, {1}, {2} MB/s'.format(
|
||||||
p[0].toFixed(2), p[1], p[2].toFixed(2)
|
f2f(p[0], 2), p[1], f2f(p[2], 2)
|
||||||
);
|
);
|
||||||
if (!r.is_act(fo.in))
|
if (!r.is_act(fo.in))
|
||||||
return;
|
return;
|
||||||
|
@ -258,7 +258,7 @@ function U2pvis(act, btns) {
|
||||||
|
|
||||||
var p = r.perc(fo.bd, fo.bd0, fo.bt, fobj.t_uploading);
|
var p = r.perc(fo.bd, fo.bd0, fo.bt, fobj.t_uploading);
|
||||||
fo.hp = '{0}%, {1}, {2} MB/s'.format(
|
fo.hp = '{0}%, {1}, {2} MB/s'.format(
|
||||||
p[0].toFixed(2), p[1], p[2].toFixed(2)
|
f2f(p[0], 2), p[1], f2f(p[2], 2)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!r.is_act(fo.in))
|
if (!r.is_act(fo.in))
|
||||||
|
@ -903,7 +903,7 @@ function up2k_init(subtle) {
|
||||||
td = (now - (etaref || now)) / 1000.0;
|
td = (now - (etaref || now)) / 1000.0;
|
||||||
|
|
||||||
etaref = now;
|
etaref = now;
|
||||||
ebi('acc_info').innerHTML = st.time.busy.toFixed(1) + ' ' + (now / 1000).toFixed(1);
|
ebi('acc_info').innerHTML = f2f(st.time.busy, 1) + ' ' + f2f(now / 1000, 1);
|
||||||
|
|
||||||
if (!nhash)
|
if (!nhash)
|
||||||
ebi('u2etah').innerHTML = 'Done ({0}, {1} files)'.format(humansize(st.bytes.hashed), pvis.ctr["ok"] + pvis.ctr["ng"]);
|
ebi('u2etah').innerHTML = 'Done ({0}, {1} files)'.format(humansize(st.bytes.hashed), pvis.ctr["ok"] + pvis.ctr["ng"]);
|
||||||
|
|
|
@ -401,16 +401,20 @@ function s2ms(s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function f2f(val, nd) {
|
||||||
|
// 10.toFixed(1) returns 10.00 for certain values of 10
|
||||||
|
val = (val * Math.pow(10, nd)).toFixed(0).split('.')[0];
|
||||||
|
return nd ? (val.slice(0, -nd) || '0') + '.' + val.slice(-nd) : val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function humansize(b, terse) {
|
function humansize(b, terse) {
|
||||||
var i = 0, u = terse ? ['B', 'K', 'M', 'G'] : ['B', 'KB', 'MB', 'GB'];
|
var i = 0, u = terse ? ['B', 'K', 'M', 'G'] : ['B', 'KB', 'MB', 'GB'];
|
||||||
while (b >= 1000 && i < u.length) {
|
while (b >= 1000 && i < u.length) {
|
||||||
b /= 1024;
|
b /= 1024;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
u = ' ' + u[i];
|
return f2f(b, b >= 100 ? 0 : b >= 10 ? 1 : 2) + ' ' + u[i];
|
||||||
if (b>=100) return Math.floor(b) + u;
|
|
||||||
if (b>=10) return b.toFixed(1) + u;
|
|
||||||
return b.toFixed(2) + u;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue