mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
up2k: show realtime speeds
This commit is contained in:
parent
acc1d2e9e3
commit
171e93c201
|
@ -185,27 +185,29 @@ function U2pvis(act, btns) {
|
||||||
this.tab[nfile].pa = t;
|
this.tab[nfile].pa = t;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.perc = function (n, t, e, t0) {
|
this.perc = function (n, t, e, sz, t0) {
|
||||||
var p = (n + e) * 100.0 / t,
|
var p = (n + e) * 100.0 / t,
|
||||||
td = new Date().getTime() - t0,
|
td = new Date().getTime() - t0,
|
||||||
eta = ((td / 1000) / p) * (100 - p);
|
pp = (td / 1000) / p,
|
||||||
|
spd = (sz / 100) / pp,
|
||||||
|
eta = pp * (100 - p);
|
||||||
|
|
||||||
return [p, s2ms(eta)];
|
return [p, s2ms(eta), spd / (1024 * 1024)];
|
||||||
};
|
};
|
||||||
|
|
||||||
this.hashed = function (nfile, t0) {
|
this.hashed = function (fobj) {
|
||||||
var fo = this.tab[nfile];
|
var fo = this.tab[fobj.n];
|
||||||
fo.nh++;
|
fo.nh++;
|
||||||
var p = this.perc(fo.nh, fo.pa.length, 0, t0);
|
var p = this.perc(fo.nh, fo.pa.length, 0, fobj.size, fobj.t1);
|
||||||
fo.hp = '{0}% ({1})'.format(
|
fo.hp = '{0}% ({1}, {2} MB/s)'.format(
|
||||||
p[0].toFixed(2), p[1]
|
p[0].toFixed(2), p[1], p[2].toFixed(2)
|
||||||
);
|
);
|
||||||
if (this.is_act(fo.in))
|
if (this.is_act(fo.in))
|
||||||
ebi('f{0}p'.format(nfile)).innerHTML = fo.hp;
|
ebi('f{0}p'.format(fobj.n)).innerHTML = fo.hp;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.prog = function (nfile, nchunk, percent, t0) {
|
this.prog = function (fobj, nchunk, percent) {
|
||||||
var fo = this.tab[nfile], pb = fo.pb;
|
var fo = this.tab[fobj.n], pb = fo.pb;
|
||||||
var i = pb.indexOf(nchunk);
|
var i = pb.indexOf(nchunk);
|
||||||
fo.pa[nchunk] = percent;
|
fo.pa[nchunk] = percent;
|
||||||
if (percent == 101) {
|
if (percent == 101) {
|
||||||
|
@ -223,13 +225,13 @@ function U2pvis(act, btns) {
|
||||||
|
|
||||||
extra /= fo.pa.length;
|
extra /= fo.pa.length;
|
||||||
|
|
||||||
var perc = this.perc(fo.nd, fo.pa.length, extra, t0);
|
var perc = this.perc(fo.nd, fo.pa.length, extra, fobj.size, fobj.t3);
|
||||||
fo.hp = '{0}% ({1})'.format(
|
fo.hp = '{0}% ({1}, {2} MB/s)'.format(
|
||||||
perc[0].toFixed(2), perc[1]
|
perc[0].toFixed(2), perc[1], perc[2].toFixed(2)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.is_act(fo.in))
|
if (this.is_act(fo.in))
|
||||||
ebi('f{0}p'.format(nfile)).innerHTML = fo.hp;
|
ebi('f{0}p'.format(fobj.n)).innerHTML = fo.hp;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.move = function (nfile, newcat) {
|
this.move = function (nfile, newcat) {
|
||||||
|
@ -1011,7 +1013,7 @@ function up2k_init(have_crypto) {
|
||||||
var b64str = buf2b64(hslice).replace(/=$/, '');
|
var b64str = buf2b64(hslice).replace(/=$/, '');
|
||||||
t.hash.push(b64str);
|
t.hash.push(b64str);
|
||||||
|
|
||||||
pvis.hashed(t.n, t.t1);
|
pvis.hashed(t);
|
||||||
if (++nchunk < nchunks) {
|
if (++nchunk < nchunks) {
|
||||||
return segm_next();
|
return segm_next();
|
||||||
}
|
}
|
||||||
|
@ -1205,11 +1207,11 @@ function up2k_init(have_crypto) {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.upload.onprogress = function (xev) {
|
xhr.upload.onprogress = function (xev) {
|
||||||
var perc = xev.loaded / (cdr - car) * 100;
|
var perc = xev.loaded / (cdr - car) * 100;
|
||||||
pvis.prog(t.n, npart, perc, t.t3);
|
pvis.prog(t, npart, perc, t);
|
||||||
};
|
};
|
||||||
xhr.onload = function (xev) {
|
xhr.onload = function (xev) {
|
||||||
if (xhr.status == 200) {
|
if (xhr.status == 200) {
|
||||||
pvis.prog(t.n, npart, 101, t.t3);
|
pvis.prog(t, npart, 101, t);
|
||||||
st.bytes.uploaded += cdr - car;
|
st.bytes.uploaded += cdr - car;
|
||||||
t.bytes_uploaded += cdr - car;
|
t.bytes_uploaded += cdr - car;
|
||||||
st.busy.upload.splice(st.busy.upload.indexOf(upt), 1);
|
st.busy.upload.splice(st.busy.upload.indexOf(upt), 1);
|
||||||
|
|
Loading…
Reference in a new issue