From f7196ac7732d208c5d32ba3bef14bc6d15fc1268 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 4 Mar 2021 21:06:59 +0100 Subject: [PATCH] dodge pushstate size limit --- copyparty/httpcli.py | 2 +- copyparty/web/browser.css | 14 +++++++++++--- copyparty/web/browser.js | 18 ++++++++++-------- copyparty/web/util.js | 7 +++++++ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index d10b4ba0..1df76f16 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -1228,7 +1228,7 @@ class HttpCli(object): fspath = fsroot + "/" + fn try: - inf = stats.get(fn, os.stat(fsenc(fspath))) + inf = stats.get(fn) or os.stat(fsenc(fspath)) except: self.log("broken symlink: {}".format(repr(fspath))) continue diff --git a/copyparty/web/browser.css b/copyparty/web/browser.css index 70ec4a24..94a2ba18 100644 --- a/copyparty/web/browser.css +++ b/copyparty/web/browser.css @@ -67,6 +67,7 @@ a, #files a:hover { color: #fff; background: #161616; + text-decoration: underline; } #files thead a { color: #999; @@ -305,7 +306,7 @@ a, width: calc(100% - 10.5em); background: rgba(0,0,0,0.2); } -@media (min-width: 100em) { +@media (min-width: 90em) { #barpos, #barbuf { width: calc(100% - 24em); @@ -535,7 +536,7 @@ input[type="checkbox"]:checked+label { #files>thead>tr>th.min span { position: absolute; transform: rotate(270deg); - background: linear-gradient(90deg, #222, #444); + background: linear-gradient(90deg, rgba(68,68,68,0), rgba(68,68,68,0.5) 70%, #444); margin-left: -4.6em; padding: .4em; top: 5.4em; @@ -554,4 +555,11 @@ input[type="checkbox"]:checked+label { border-color: transparent; color: #400; text-shadow: none; -} \ No newline at end of file +} +#files tr.play a { + color: inherit; +} +#files tr.play a:hover { + color: #300; + background: #fea; +} diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 97c7a10d..6ff78e6e 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -462,7 +462,7 @@ function play(tid, call_depth) { o.setAttribute('id', 'thx_js'); if (window.history && history.replaceState) { var nurl = (document.location + '').split('#')[0] + '#' + oid; - history.replaceState(ebi('files').innerHTML, nurl, nurl); + hist_push(ebi('files').innerHTML, nurl); } else { document.location.hash = oid; @@ -898,7 +898,7 @@ function autoplay_blocked() { html = html.join('\n'); ebi('files').innerHTML = html; - history.pushState(html, this.top, this.top); + hist_push(html, this.top); apply_perms(res.perms); despin('#files'); @@ -960,16 +960,18 @@ function autoplay_blocked() { window.onpopstate = function (e) { console.log(e.url + ' ,, ' + ((e.state + '').slice(0, 64))); - if (e.state) { - ebi('files').innerHTML = e.state; - reload_tree(); - reload_browser(); - } + var html = sessionStorage.getItem(e.state || 1); + if (!html) + return; + + ebi('files').innerHTML = html; + reload_tree(); + reload_browser(); }; if (window.history && history.pushState) { var u = get_vpath() + window.location.hash; - history.replaceState(ebi('files').innerHTML, u, u); + hist_push(ebi('files').innerHTML, u); } })(); diff --git a/copyparty/web/util.js b/copyparty/web/util.js index fdadabc3..02ea61a3 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -292,3 +292,10 @@ function jwrite(key, val) { else swrite(key, JSON.stringify(val)); } + + +function hist_push(html, url) { + var key = new Date().getTime(); + sessionStorage.setItem(key, html); + history.pushState(key, url, url); +}