Improve search result page
This commit is contained in:
+20
-1
@@ -121,7 +121,9 @@
|
||||
// diary photo grids wrap each thumbnail in a .photo-grid anchor.
|
||||
// The left tree rail's file anchors (a.tree-file) join in too;
|
||||
// folder anchors there end in "/" and fall through to navigation.
|
||||
var anchor = e.target.closest('.list-item a, a.thumb-tile, .photo-grid a, aside.tree-sidebar a.tree-file');
|
||||
// Search file-result anchors join in too: page results end in "/"
|
||||
// and fall through to navigation, file results don't and open locally.
|
||||
var anchor = e.target.closest('.list-item a, a.thumb-tile, .photo-grid a, aside.tree-sidebar a.tree-file, .search-card a');
|
||||
if (!anchor) return;
|
||||
var item = anchor.closest('.list-item');
|
||||
// Only intercept the primary file link, and only for files (not folders).
|
||||
@@ -153,6 +155,22 @@
|
||||
});
|
||||
}
|
||||
|
||||
function wireFileRevealButtons() {
|
||||
// Per-result "open location" buttons on the search page. Unlike the
|
||||
// page reveal button (which reveals window.location), each carries its
|
||||
// own file path so it reveals that specific file in its folder.
|
||||
if (!state.available) return;
|
||||
var btns = document.querySelectorAll('[data-companion-file-reveal]');
|
||||
btns.forEach(function (btn) {
|
||||
btn.hidden = false;
|
||||
btn.addEventListener('click', function () {
|
||||
var rel = btn.getAttribute('data-companion-file-reveal');
|
||||
if (!rel) return;
|
||||
companionGET('/open-folder', { path: rel }).catch(function () { });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function probeStatus() {
|
||||
return companionGET('/status').then(function (r) {
|
||||
if (!r.ok) throw new Error('status ' + r.status);
|
||||
@@ -171,6 +189,7 @@
|
||||
updateFooterIcon();
|
||||
wireFileLinks();
|
||||
wireRevealButton();
|
||||
wireFileRevealButtons();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user