diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 737978a9..9cfb24e3 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -986,6 +986,8 @@ function apply_perms(perms) { goto(); } + document.body.setAttribute('perms', perms.join(' ')); + var have_write = has(perms, "write"); var tds = document.querySelectorAll('#u2conf td'); for (var a = 0; a < tds.length; a++) { @@ -993,7 +995,7 @@ function apply_perms(perms) { (have_write || tds[a].getAttribute('data-perm') == 'read') ? 'table-cell' : 'none'; } - if (!have_write) + if (!have_write && up2k) up2k.set_fsearch(); } diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 2f3f4c96..fbf4f0f4 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -368,6 +368,7 @@ function up2k_init(have_crypto) { "size": fobj.size, "lmod": lmod / 1000, "purl": get_vpath(), + "done": false, "hash": [] }; @@ -400,6 +401,19 @@ function up2k_init(have_crypto) { } more_one_file(); + function u2cleanup(e) { + ev(e); + for (var a = 0; a < st.files.length; a++) { + var t = st.files[a]; + if (t.done && t.name) { + var tr = ebi('f{0}p'.format(t.n)).parentNode; + tr.parentNode.removeChild(tr); + t.name = undefined; + } + } + } + ebi('u2cleanup').onclick = u2cleanup; + ///// //// /// actuator @@ -819,6 +833,7 @@ function up2k_init(have_crypto) { st.busy.handshake.splice(st.busy.handshake.indexOf(t), 1); if (done) { + t.done = true; st.bytes.uploaded += t.size - t.bytes_uploaded; var spd1 = (t.size / ((t.t2 - t.t1) / 1000.)) / (1024 * 1024.); var spd2 = (t.size / ((t.t3 - t.t2) / 1000.)) / (1024 * 1024.); @@ -1112,6 +1127,10 @@ function up2k_init(have_crypto) { for (var a = nodes.length - 1; a >= 0; a--) nodes[a].addEventListener('touchend', nop, false); + var perms = document.body.getAttribute('perms'); + if (perms && perms.indexOf('write') === -1) + set_fsearch(); + bumpthread({ "target": 1 }) return { "init_deps": init_deps, "set_fsearch": set_fsearch } diff --git a/copyparty/web/upload.css b/copyparty/web/upload.css index 784e37cd..a71679ac 100644 --- a/copyparty/web/upload.css +++ b/copyparty/web/upload.css @@ -211,4 +211,8 @@ font-style: italic; color: #fff; padding-left: .2em; -} \ No newline at end of file +} +#u2cleanup { + float: right; + margin-bottom: -.3em; +} diff --git a/copyparty/web/upload.html b/copyparty/web/upload.html index 86da6bf6..7770ee60 100644 --- a/copyparty/web/upload.html +++ b/copyparty/web/upload.html @@ -81,7 +81,7 @@ filename status - progress + progresscleanup