From b8a93e74bf40d16794e8537991019011ca17cab2 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 7 Oct 2022 21:38:01 +0200 Subject: [PATCH] fix default upload expiration + ux --- copyparty/up2k.py | 2 +- copyparty/web/baguettebox.js | 16 +++++++++------- copyparty/web/up2k.js | 16 ++++++++++++++-- copyparty/web/util.js | 5 +++++ 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/copyparty/up2k.py b/copyparty/up2k.py index c369fcaa..d425a8c9 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -2315,7 +2315,7 @@ class Up2k(object): flt = job["life"] vfs = self.asrv.vfs.all_vols[job["vtop"]] vlt = vfs.flags["lifetime"] - if vlt and flt < vlt: + if vlt and flt > 1 and flt < vlt: upt -= vlt - flt wake_sr = True t = "using client lifetime; at={:.0f} ({}-{})" diff --git a/copyparty/web/baguettebox.js b/copyparty/web/baguettebox.js index 4c6ef35b..0a826ca4 100644 --- a/copyparty/web/baguettebox.js +++ b/copyparty/web/baguettebox.js @@ -246,12 +246,18 @@ window.baguetteBox = (function () { } function keyDownHandler(e) { - if (e.ctrlKey || e.altKey || e.metaKey || e.isComposing || modal.busy) + if (anymod(e, true) || modal.busy) return; var k = e.code + '', v = vid(), pos = -1; - if (k == "ArrowLeft" || k == "KeyJ") + if (k == "BracketLeft") + setloop(1); + else if (k == "BracketRight") + setloop(2); + else if (e.shiftKey) + return; + else if (k == "ArrowLeft" || k == "KeyJ") showPreviousImage(); else if (k == "ArrowRight" || k == "KeyL") showNextImage(); @@ -289,10 +295,6 @@ window.baguetteBox = (function () { rotn(e.shiftKey ? -1 : 1); else if (k == "KeyY") dlpic(); - else if (k == "BracketLeft") - setloop(1); - else if (k == "BracketRight") - setloop(2); } function anim() { @@ -406,7 +408,7 @@ window.baguetteBox = (function () { } function keyUpHandler(e) { - if (e.ctrlKey || e.altKey || e.metaKey || e.isComposing) + if (anymod(e)) return; var k = e.code + ''; diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index ac4370cb..65299a16 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -2497,7 +2497,7 @@ function up2k_init(subtle) { tt.att(QS('#u2conf')); function bumpthread2(e) { - if (e.ctrlKey || e.altKey || e.metaKey || e.isComposing) + if (anymod(e)) return; if (e.code == 'ArrowUp') @@ -2571,6 +2571,7 @@ function up2k_init(subtle) { el.innerHTML = '
' + L.u_life_cfg + '
' + L.u_life_est + '
'; set_life(Math.min(lifetime, icfg_get('lifetime', lifetime))); ebi('lifem').oninput = ebi('lifeh').oninput = mod_life; + ebi('lifem').onkeydown = ebi('lifeh').onkeydown = kd_life; tt.att(ebi('u2life')); } draw_life(); @@ -2596,12 +2597,23 @@ function up2k_init(subtle) { set_life(v); } + function kd_life(e) { + var el = e.target, + d = e.code == 'ArrowUp' ? 1 : e.code == 'ArrowDown' ? -1 : 0; + + if (anymod(e) || !d) + return; + + el.value = parseInt(el.value) + d; + mod_life(e); + } + function set_life(v) { //ebi('lifes').value = v; ebi('lifem').value = parseInt(v / 60); ebi('lifeh').value = parseInt(v / 3600); - var undo = have_unpost - (v || lifetime); + var undo = have_unpost - (v ? lifetime - v : 0); ebi('undor').innerHTML = undo <= 0 ? L.u_unp_ng : L.u_unp_ok.format(lhumantime(undo)); diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 906ffeeb..26d78767 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -239,6 +239,11 @@ function ctrl(e) { } +function anymod(e, shift_ok) { + return e && (e.ctrlKey || e.altKey || e.metaKey || e.isComposing || (!shift_ok && e.shiftKey)); +} + + function ev(e) { e = e || window.event; if (!e)