fix tool removal in navbar

This commit is contained in:
Anthony Stirling 2024-05-20 18:43:47 +01:00
parent 0cc12f4456
commit 6adeecac9c

View File

@ -60,23 +60,22 @@ function handleDropdownItemClick(event) {
} }
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll(".nav-item.dropdown").forEach((element) => {
const dropdownMenu = element.querySelector(".dropdown-menu"); document.querySelectorAll(".col-lg-2.col-sm-6").forEach((element) => {
if ( const dropdownItems = element.querySelectorAll(".dropdown-item");
dropdownMenu.id !== "favoritesDropdown" && const items = Array.from(dropdownItems).filter(item => !item.querySelector("hr.dropdown-divider"));
dropdownMenu.children.length <= 2 &&
dropdownMenu.querySelectorAll("hr.dropdown-divider").length === dropdownMenu.children.length if (items.length <= 2) {
) { if (
if ( element.previousElementSibling &&
element.previousElementSibling && element.previousElementSibling.classList.contains("col-lg-2") &&
element.previousElementSibling.classList.contains("nav-item") && element.previousElementSibling.classList.contains("nav-item-separator")
element.previousElementSibling.classList.contains("nav-item-separator") ) {
) { element.previousElementSibling.remove();
element.previousElementSibling.remove(); }
} element.remove();
element.remove();
} }
}); });
//Sort languages by alphabet //Sort languages by alphabet
const list = Array.from(document.querySelector('.dropdown-menu[aria-labelledby="languageDropdown"]').children).filter( const list = Array.from(document.querySelector('.dropdown-menu[aria-labelledby="languageDropdown"]').children).filter(