From ee86b06676d5b8ade0fd64a2b1aca9fa47c69de0 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 8 Aug 2021 04:02:58 +0200 Subject: [PATCH] compat + perf + ux --- copyparty/up2k.py | 2 +- copyparty/web/browser.js | 40 ++++++++++++++++++++++++---------------- copyparty/web/mde.css | 4 ++++ copyparty/web/ui.css | 3 +++ copyparty/web/util.js | 11 +++-------- 5 files changed, 35 insertions(+), 25 deletions(-) diff --git a/copyparty/up2k.py b/copyparty/up2k.py index bdae1868..45afcaa1 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -1243,7 +1243,7 @@ class Up2k(object): hops = len(ndst[nc:]) - 1 lsrc = "../" * hops + "/".join(lsrc) os.symlink(fsenc(lsrc), fsenc(ldst)) - except (AttributeError, OSError) as ex: + except Exception as ex: self.log("cannot symlink; creating copy: " + repr(ex)) shutil.copy2(fsenc(src), fsenc(dst)) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index fdcdda40..0ba364bc 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -1568,7 +1568,10 @@ var fileman = (function () { r = {}; r.clip = null; - r.bus = new BroadcastChannel("fileman_bus"); + try { + r.bus = new BroadcastChannel("fileman_bus"); + } + catch (ex) { } r.render = function () { if (r.clip === null) @@ -1920,7 +1923,7 @@ var fileman = (function () { deleter(); } - modal.confirm('===== DANGER =====\nDELETE these ' + vps.length + ' items?\n\n' + vps.join('\n'), function () { + modal.confirm('===== DANGER =====\nDELETE these ' + vps.length + ' items?\n\n' + uricom_adec(vps).join('\n'), function () { modal.confirm('Last chance! Delete?', deleter, null); }, null); }; @@ -1936,14 +1939,15 @@ var fileman = (function () { if (!sel.length) return toast.err(3, 'select at least 1 item to cut'); - for (var a = 0; a < sel.length; a++) { - vps.push(sel[a].vp); - var cl = ebi(sel[a].id).closest('tr').classList, - inv = cl.contains('c1'); + if (sel.length < 100) + for (var a = 0; a < sel.length; a++) { + vps.push(sel[a].vp); + var cl = ebi(sel[a].id).closest('tr').classList, + inv = cl.contains('c1'); - cl.remove(inv ? 'c1' : 'c2'); - cl.add(inv ? 'c2' : 'c1'); - } + cl.remove(inv ? 'c1' : 'c2'); + cl.add(inv ? 'c2' : 'c1'); + } toast.inf(1, 'cut ' + sel.length + ' items'); jwrite('fman_clip', vps); @@ -2021,15 +2025,19 @@ var fileman = (function () { }, null); }; - r.bus.onmessage = function (e) { - r.clip = null; - r.render(); - var me = get_evpath(); - if (e && e.data == me) - treectl.goto(e.data); - }; + if (r.bus) + r.bus.onmessage = function (e) { + r.clip = null; + r.render(); + var me = get_evpath(); + if (e && e.data == me) + treectl.goto(e.data); + }; r.tx = function (msg) { + if (!r.bus) + return; + r.bus.postMessage(msg); r.bus.onmessage(); }; diff --git a/copyparty/web/mde.css b/copyparty/web/mde.css index 59585d12..d146e8eb 100644 --- a/copyparty/web/mde.css +++ b/copyparty/web/mde.css @@ -18,6 +18,10 @@ html, body { background: #f7f7f7; color: #333; } +#toast { + bottom: auto; + top: 1.4em; +} #mn { font-weight: normal; margin: 1.3em 0 .7em 1em; diff --git a/copyparty/web/ui.css b/copyparty/web/ui.css index 56fc3d02..c69e4872 100644 --- a/copyparty/web/ui.css +++ b/copyparty/web/ui.css @@ -155,6 +155,9 @@ html.light #tt em { padding: 1em 1.1em; border-radius: .6em; box-shadow: 0 .3em 3em rgba(0,0,0,0.5); + max-width: 50em; + max-height: 30em; + overflow: auto; } @media (min-width: 40em) { #modalc { diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 6a52aabc..6d99fd4e 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -733,15 +733,10 @@ var modal = (function () { if (a) a.onclick = ng; - var a = ebi('modal-ok'); - if (a) { - a.onclick = ok; - a.focus(); - } + a = ebi('modal-ok'); + a.onclick = ok; - var a = ebi('modali'); - if (a) - a.focus(); + (ebi('modali') || a).focus(); }; r.hide = function () {