mirror of
https://github.com/tchartron/blow
synced 2025-04-04 06:46:01 +00:00
1 line
No EOL
1.1 KiB
JavaScript
1 line
No EOL
1.1 KiB
JavaScript
function findCorrespondingTocTitle(t){return[...document.querySelectorAll("#toc li a")].find(e=>e.href.substring(e.href.indexOf("#"))==="#"+t.id)}function setActive(e,t){null!==t&&(findCorrespondingTocTitle(t.target),t.parentElement.classList.remove("bg-blue-800"));let n=findCorrespondingTocTitle(e.target);n.parentElement.classList.add("bg-blue-800")}function setNextActive(e){let t=findCorrespondingTocTitle(e.target);console.log(t),t.parentElement.classList.remove("bg-blue-800"),t.parentElement.nextElementSibling.classList.add("bg-blue-800")}function setPreviousActive(e){let t=findCorrespondingTocTitle(e.target);t.parentElement.classList.remove("bg-blue-800"),t.parentElement.previousElementSibling.classList.add("bg-blue-800")}document.addEventListener("DOMContentLoaded",function(){document.getElementById("navbar").clientHeight,document.getElementById("toc");var e=document.querySelectorAll("#toc li a"),t=(document.getElementById("page-content"),[]);[...e].forEach(e=>{t.push(e.href.substring(e.href.indexOf("#")))});e=document.querySelectorAll(t.join(","));console.log(e),window.addEventListener("scroll",()=>{})}); |