dodge pushstate size limit

This commit is contained in:
ed 2021-03-04 21:06:59 +01:00
parent 7a7c832000
commit f7196ac773
4 changed files with 29 additions and 12 deletions

View file

@ -1228,7 +1228,7 @@ class HttpCli(object):
fspath = fsroot + "/" + fn fspath = fsroot + "/" + fn
try: try:
inf = stats.get(fn, os.stat(fsenc(fspath))) inf = stats.get(fn) or os.stat(fsenc(fspath))
except: except:
self.log("broken symlink: {}".format(repr(fspath))) self.log("broken symlink: {}".format(repr(fspath)))
continue continue

View file

@ -67,6 +67,7 @@ a,
#files a:hover { #files a:hover {
color: #fff; color: #fff;
background: #161616; background: #161616;
text-decoration: underline;
} }
#files thead a { #files thead a {
color: #999; color: #999;
@ -305,7 +306,7 @@ a,
width: calc(100% - 10.5em); width: calc(100% - 10.5em);
background: rgba(0,0,0,0.2); background: rgba(0,0,0,0.2);
} }
@media (min-width: 100em) { @media (min-width: 90em) {
#barpos, #barpos,
#barbuf { #barbuf {
width: calc(100% - 24em); width: calc(100% - 24em);
@ -535,7 +536,7 @@ input[type="checkbox"]:checked+label {
#files>thead>tr>th.min span { #files>thead>tr>th.min span {
position: absolute; position: absolute;
transform: rotate(270deg); 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; margin-left: -4.6em;
padding: .4em; padding: .4em;
top: 5.4em; top: 5.4em;
@ -555,3 +556,10 @@ input[type="checkbox"]:checked+label {
color: #400; color: #400;
text-shadow: none; text-shadow: none;
} }
#files tr.play a {
color: inherit;
}
#files tr.play a:hover {
color: #300;
background: #fea;
}

View file

@ -462,7 +462,7 @@ function play(tid, call_depth) {
o.setAttribute('id', 'thx_js'); o.setAttribute('id', 'thx_js');
if (window.history && history.replaceState) { if (window.history && history.replaceState) {
var nurl = (document.location + '').split('#')[0] + '#' + oid; var nurl = (document.location + '').split('#')[0] + '#' + oid;
history.replaceState(ebi('files').innerHTML, nurl, nurl); hist_push(ebi('files').innerHTML, nurl);
} }
else { else {
document.location.hash = oid; document.location.hash = oid;
@ -898,7 +898,7 @@ function autoplay_blocked() {
html = html.join('\n'); html = html.join('\n');
ebi('files').innerHTML = html; ebi('files').innerHTML = html;
history.pushState(html, this.top, this.top); hist_push(html, this.top);
apply_perms(res.perms); apply_perms(res.perms);
despin('#files'); despin('#files');
@ -960,16 +960,18 @@ function autoplay_blocked() {
window.onpopstate = function (e) { window.onpopstate = function (e) {
console.log(e.url + ' ,, ' + ((e.state + '').slice(0, 64))); console.log(e.url + ' ,, ' + ((e.state + '').slice(0, 64)));
if (e.state) { var html = sessionStorage.getItem(e.state || 1);
ebi('files').innerHTML = e.state; if (!html)
return;
ebi('files').innerHTML = html;
reload_tree(); reload_tree();
reload_browser(); reload_browser();
}
}; };
if (window.history && history.pushState) { if (window.history && history.pushState) {
var u = get_vpath() + window.location.hash; var u = get_vpath() + window.location.hash;
history.replaceState(ebi('files').innerHTML, u, u); hist_push(ebi('files').innerHTML, u);
} }
})(); })();

View file

@ -292,3 +292,10 @@ function jwrite(key, val) {
else else
swrite(key, JSON.stringify(val)); swrite(key, JSON.stringify(val));
} }
function hist_push(html, url) {
var key = new Date().getTime();
sessionStorage.setItem(key, html);
history.pushState(key, url, url);
}