From c2b66bbe73879733c2da841bbc87397bcb61e659 Mon Sep 17 00:00:00 2001
From: ed
Date: Thu, 14 Jul 2022 02:33:35 +0200
Subject: [PATCH] add potato mode
---
copyparty/httpcli.py | 2 +-
copyparty/web/browser.css | 7 +++-
copyparty/web/browser.js | 8 ++++-
copyparty/web/up2k.js | 67 ++++++++++++++++++++++++++++++++++++---
copyparty/web/util.js | 3 +-
docs/notes.sh | 3 ++
scripts/rls.sh | 9 ++++--
7 files changed, 88 insertions(+), 11 deletions(-)
diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py
index 924e1f95..9480b66c 100644
--- a/copyparty/httpcli.py
+++ b/copyparty/httpcli.py
@@ -1130,7 +1130,7 @@ class HttpCli(object):
cinf = self.headers.get("x-up2k-stat", "")
spd = self._spd(post_sz)
- self.log("{} thank {}".format(spd, cinf))
+ self.log("{:70} thank {}".format(spd, cinf))
self.reply(b"thank")
return True
diff --git a/copyparty/web/browser.css b/copyparty/web/browser.css
index a844041e..059d4e60 100644
--- a/copyparty/web/browser.css
+++ b/copyparty/web/browser.css
@@ -2216,6 +2216,10 @@ html.y #bbox-overlay figcaption a {
#u2notbtn * {
line-height: 1.3em;
}
+#u2mu div {
+ height: 1.2em;
+ overflow: hidden;
+}
#u2tabw {
min-height: 0;
transition: min-height .2s;
@@ -2225,6 +2229,7 @@ html.y #bbox-overlay figcaption a {
display: none;
}
#u2tab {
+ table-layout: fixed;
border-collapse: collapse;
width: calc(100% - 2em);
max-width: 100em;
@@ -2348,7 +2353,7 @@ html.y #bbox-overlay figcaption a {
width: 48em;
}
#u2conf.ww {
- width: 74em;
+ width: 78em;
}
#u2conf.ww #u2c3w {
width: 29em;
diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js
index cb54bc2c..c43dee32 100644
--- a/copyparty/web/browser.js
+++ b/copyparty/web/browser.js
@@ -63,6 +63,7 @@ var Ls = {
"ul_par": "parallel uploads:",
"ut_mt": "continue hashing other files while uploading$N$Nmaybe disable if your CPU or HDD is a bottleneck",
"ut_ask": "ask for confirmation before upload starts",
+ "ut_pot": "improve upload speed on slow devices$Nby making the UI less complex",
"ut_srch": "don't actually upload, instead check if the files already $N exist on the server (will scan all folders you can read)",
"ut_par": "pause uploads by setting it to 0$N$Nincrease if your connection is slow / high latency$N$Nkeep it 1 on LAN or if the server HDD is a bottleneck",
"ul_btn": "drop files / folders
here (or click me)",
@@ -390,6 +391,7 @@ var Ls = {
"ul_par": "samtidige handl.:",
"ut_mt": "fortsett å befare køen mens opplastning foregår$N$Nskru denne av dersom du har en$Ntreg prosessor eller harddisk",
"ut_ask": "bekreft filutvalg før opplastning starter",
+ "ut_pot": "forbedre ytelsen på trege enheter ved å$Nforenkle brukergrensesnittet",
"ut_srch": "utfør søk istedenfor å laste opp --$Nleter igjennom alle mappene du har lov til å se",
"ut_par": "sett til 0 for å midlertidig stanse opplastning$N$Nhøye verdier (4 eller 8) kan gi bedre ytelse,$Nspesielt på trege internettlinjer$N$Nbør ikke være høyere enn 1 på LAN$Neller hvis serveren sin harddisk er treg",
"ul_btn": "slipp filer / mapper
her (eller klikk meg)",
@@ -721,6 +723,10 @@ ebi('op_up2k').innerHTML = (
' \n' +
' \n' +
' \n' +
+ ' \n' +
+ ' \n' +
+ ' \n' +
+ ' \n' +
' \n' +
' \n' +
' \n' +
@@ -776,7 +782,7 @@ ebi('op_up2k').innerHTML = (
' \n' +
' \n' +
' \n' +
- '\n' +
+ '\n' +
'
' + L.ul_flagblk + '
\n' + '' diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 237d3598..1e1ffa20 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -144,6 +144,7 @@ function U2pvis(act, btns, uc) { r.head = 0; r.tail = -1; r.wsz = 3; + r.npotato = 99; var markup = { '404': '404', @@ -181,6 +182,9 @@ function U2pvis(act, btns, uc) { }; r.is_act = function (card) { + if (uc.potato && !uc.fsearch) + return false; + if (r.act == "done") return card == "ok" || card == "ng"; @@ -361,6 +365,38 @@ function U2pvis(act, btns, uc) { } }; + r.potato = function () { + QS('#u2cards a[act="bz"]').click(); + timer[uc.potato ? "add" : "rm"](draw_potato); + }; + + function draw_potato() { + if (++r.npotato < 2) + return; + + r.npotato = 0; + var html = [ + "files: {0} finished, {1} failed, {2} busy, {3} queued
".format(r.ctr.ok, r.ctr.ng, r.ctr.bz, r.ctr.q), + ]; + + while (r.head < r.tab.length && has(["ok", "ng"], r.tab[r.head].in)) + r.head++; + + var act = null; + if (r.head < r.tab.length) + act = r.tab[r.head]; + + if (act) + html.push("file {0} of {1} : {2} {3}