2018-09-09 12:08:48 +00:00
|
|
|
function hideAllButCurrent(){
|
2020-09-03 20:27:38 +00:00
|
|
|
//by default all submenu items are hidden
|
2019-07-16 19:21:01 +00:00
|
|
|
//but we need to rehide them for search
|
|
|
|
document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) {
|
|
|
|
parent.style.display = "none";
|
|
|
|
});
|
2018-09-09 12:08:48 +00:00
|
|
|
|
|
|
|
//only current page (if it exists) should be opened
|
2019-07-16 19:21:01 +00:00
|
|
|
var file = window.location.pathname.split("/").pop().replace(/\.html/, '');
|
|
|
|
document.querySelectorAll("nav > ul > li > a").forEach(function(parent) {
|
|
|
|
var href = parent.attributes.href.value.replace(/\.html/, '');
|
|
|
|
if (file === href) {
|
|
|
|
parent.parentNode.querySelectorAll("ul li").forEach(function(elem) {
|
|
|
|
elem.style.display = "block";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2018-09-09 12:08:48 +00:00
|
|
|
}
|
2019-07-16 19:21:01 +00:00
|
|
|
|
2020-09-03 20:27:38 +00:00
|
|
|
hideAllButCurrent();
|