window.addEventListener('load', function(){ // Sub Lnb Depth Event const dep = document.getElementById("dep"); if (dep) { let title = dep.firstElementChild; let items = dep.lastElementChild.querySelectorAll("li a"); let currentPath = location.pathname; items.forEach(function(item) { let link = document.createElement('a'); link.href = item.getAttribute("href"); if (currentPath === link.pathname) { title.textContent = item.textContent; } }); } let depBtns = document.querySelectorAll('.depth'); let depLists = document.querySelectorAll('.depth_list'); depBtns.forEach((btn) => { btn.addEventListener('click', function(e){ let targetList = btn.querySelector('.depth_list'); depLists.forEach((list) => { if (list !== targetList) { list.style.display = "none"; list.style.maxHeight = null; } }); if (targetList.style.maxHeight) { targetList.style.display = "none"; targetList.style.maxHeight = null; } else { targetList.style.display = "block"; targetList.style.maxHeight = targetList.scrollHeight + 'px'; } e.stopPropagation(); }); }); document.addEventListener('click', function() { depLists.forEach((list) => { list.style.display = "none"; list.style.maxHeight = null; }); }); });