From a088f648b17fe2a76d8c40a0e03f5c08dae05d07 Mon Sep 17 00:00:00 2001 From: "Alex J. Best" Date: Mon, 18 Sep 2023 22:08:34 +0100 Subject: [PATCH] clean the expand-nav implementation up a bit --- static/expand-nav.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/static/expand-nav.js b/static/expand-nav.js index fd13ba6..2b28a28 100644 --- a/static/expand-nav.js +++ b/static/expand-nav.js @@ -2,16 +2,22 @@ document.querySelector('.navframe').addEventListener('load', function() { // Get the current page URL without the suffix after # var currentPageURL = window.location.href.split('#')[0]; - // Get all detail elements + // Get all anchor tags var as = document.querySelector('.navframe').contentWindow.document.body.querySelectorAll('a'); for (const a of as) { if (a.href) { var href = a.href.split('#')[0]; + // find the one with the current url if (href === currentPageURL) { a.style.fontStyle = 'italic'; + // open all detail tags above the current var el = a.parentNode.closest('details'); while (el) { el.open = true; el = el.parentNode.closest('details'); - }}}} + }} + // seeing as we found the link we were looking for, stop + break; + } + } });