UNPKG

decentralized-internet

Version:

An NPM library of programs to create decentralized web and distributed computing projects

1 lines 1.29 kB
var searchAttr="data-search-mode";function contains(e,t){return-1!==(e.textContent||e.innerText||"").toUpperCase().indexOf(t)}document.getElementById("nav-search").addEventListener("keyup",function(e){var t=this.value.toUpperCase();t?(document.documentElement.setAttribute(searchAttr,""),document.querySelectorAll("nav > ul > li").forEach(function(e){e.style.display="block"}),document.querySelectorAll("nav > ul > li > ul li").forEach(function(e){e.style.display="none"}),document.querySelectorAll("nav > ul > li > ul a").forEach(function(e){contains(e.parentNode,t)&&(e.parentNode.style.display="block")}),document.querySelectorAll("nav > ul > li").forEach(function(e){var l=0;e.querySelectorAll("a").forEach(function(e){contains(e,t)&&l++});var n=0,o=0;e.querySelectorAll("ul").forEach(function(e){contains(e,t)&&n++;var l=e.children;for(i=0;i<l.length;i++){"none"!=l[i].style.display&&o++}}),0==l&&0===n?e.style.display="none":0==l&&0==o&&(e.style.display="none")})):(document.documentElement.removeAttribute(searchAttr),document.querySelectorAll("nav > ul > li:not(.level-hide)").forEach(function(e){e.style.display="block"}),"function"==typeof hideAllButCurrent?hideAllButCurrent():document.querySelectorAll("nav > ul > li > ul li").forEach(function(e){e.style.display="block"}))});