From bc9ba5928ab753c76f76b8428ea26317903de7f2 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 14 Jan 2026 23:51:44 +0000 Subject: [PATCH] Update browser.js Signed-off-by: ed --- copyparty/web/browser.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index ac390261..6c0eb92b 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -9500,9 +9500,10 @@ var rcm = (function () { elem: null, type: null, path: null, + dpath: null, url: null, id: null, - relpath: null, + fname: null, no_dsel: false }; var selFile = jcp(nsFile); @@ -9564,9 +9565,9 @@ var rcm = (function () { a.target = selFile.type == "dir" ? '' : '_blank'; a.click(); break; - case 'ply': selFile.type == 'gf' ? thegrid.imshow(selFile.relpath) : play('f-' + selFile.id); break; + case 'ply': selFile.type == 'gf' ? thegrid.imshow(selFile.name) : play('f-' + selFile.id); break; case 'pla': play('f-' + selFile.id); break; - case 'txt': location = selFile.basepath + '?doc=' + selFile.relpath; break; + case 'txt': location = selFile.dpath + '?doc=' + selFile.name; break; case 'md': location = selFile.path + (has(selFile.path, '?') ? '&v' : '?v'); break; case 'cpl': cliptxt(selFile.url, function() {toast.ok(2, L.clipped)}); break; case 'dl': ebi('seldl').click(); break; @@ -9599,18 +9600,18 @@ var rcm = (function () { var ref = ebi(target.getAttribute('ref')); file = ref && ref.closest('#files tbody tr'); } - if (file) { + var fa = file && file.children[1].querySelector('a[id]'); + if (fa) { selFile.no_dsel = clgot(file, "sel"); clmod(file, "sel", true); selFile.elem = file; - - var isSearchView = file.children[1].firstChild.tagName === "DIV"; - - selFile.url = isSearchView ? file.children[1].firstChild.lastChild.href : file.children[1].firstChild.href; + selFile.url = fa.href; selFile.path = basenames(selFile.url).replace(/(&|\?)v/, ''); - selFile.basepath = selFile.path.lastIndexOf("/") === 0 ? "/" : selFile.path.slice(0, selFile.path.lastIndexOf("/")); - selFile.relpath = selFile.path.split('/').slice(-1)[0].split("?")[0]; - if (!isSearchView && noq_href(file.children[1].firstChild).endsWith("/")) + var url = selFile.url.split("?")[0], + vsp = vsplit(url); + selFile.dpath = vsp[0]; + selFile.name = vsp[1]; + if (url.endsWith("/")) selFile.type = "dir"; else { var lead = file.firstChild.firstChild; @@ -9634,7 +9635,7 @@ var rcm = (function () { clmod(ebi('rpla'), 'hide', selFile.type != 'gf'); clmod(ebi('rtxt'), 'hide', !selFile.id); clmod(ebi('rs1'), 'hide', !selFile.path); - clmod(ebi('rmd'), 'hide', selFile.relpath.slice(-3) != ".md"); + clmod(ebi('rmd'), 'hide', selFile.name.slice(-3) != ".md"); clmod(ebi('rcpl'), 'hide', !selFile.path); clmod(ebi('rdl'), 'hide', !has_sel); clmod(ebi('rzip'), 'hide', !has_sel);