all repos — searchix @ 807a691936113eecb43b6a64e2f4524a68a9a0d1

Search engine for NixOS, nix-darwin, home-manager and NUR users

refactor(js): cleanup unused code
Alan Pearce alan@alanpearce.eu
Sat, 29 Mar 2025 13:19:21 +0100
commit

807a691936113eecb43b6a64e2f4524a68a9a0d1

parent

eb130a451eb27fbbfb5467420e7e166d545ef938

1 files changed, 1 insertions(+), 11 deletions(-)

jump to
M frontend/static/search.jsfrontend/static/search.js
@@ -18,7 +18,6 @@ let state = history.state || {   url: urlLocation.toString(),
   input: urlLocation.searchParams.get("query"),
   results: resultsRange.cloneContents().innerHTML || null,
-  opened: [],
 };
 
 let escapePolicy = null;
@@ -105,7 +104,6 @@     // render errors sent as HTML as well as OK responses
     if (res.headers.get("content-type").startsWith("text/html")) {
       state.results = await res.text();
-      state.opened = [];
       history.replaceState(state, null, url);
       renderResults(state.results);
     } else {
@@ -155,7 +153,7 @@ resultsRange.deleteContents();   state.results = "";
   history.pushState(state, null, ev.target.href);
   ev.preventDefault();
-  document.querySelectorAll("nav > a:not(.current)").forEach(function (node) {
+  nav.querySelectorAll("a:not(.current)").forEach(function (node) {
     const u = new URL(node.href);
     u.search = "";
     node.href = u.toString();
@@ -216,14 +214,6 @@ if (!(ev.ctrlKey || ev.metaKey || ev.shiftKey || ev.altKey)) {     getDetail(new URL(ev.target.href));
     ev.preventDefault();
   }
-}
-
-if (state.opened.length > 0) {
-  state.opened.forEach((id) =>
-    document.getElementById(id).setAttribute("open", "open"),
-  );
-} else if (location.hash) {
-  document.getElementById(location.hash.slice(1)).setAttribute("open", "open");
 }
 
 addEventListener("popstate", function (ev) {