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.querySelectorAll(".nav-item.dropdown").forEach((element) => {
const dropdownMenu = element.querySelector(".dropdown-menu");
if (
dropdownMenu.id !== "favoritesDropdown" &&
dropdownMenu.children.length <= 2 &&
dropdownMenu.querySelectorAll("hr.dropdown-divider").length === dropdownMenu.children.length
) {
if (
element.previousElementSibling &&
element.previousElementSibling.classList.contains("nav-item") &&
element.previousElementSibling.classList.contains("nav-item-separator")
) {
element.previousElementSibling.remove();
}
element.remove();
document.querySelectorAll(".col-lg-2.col-sm-6").forEach((element) => {
const dropdownItems = element.querySelectorAll(".dropdown-item");
const items = Array.from(dropdownItems).filter(item => !item.querySelector("hr.dropdown-divider"));
if (items.length <= 2) {
if (
element.previousElementSibling &&
element.previousElementSibling.classList.contains("col-lg-2") &&
element.previousElementSibling.classList.contains("nav-item-separator")
) {
element.previousElementSibling.remove();
}
element.remove();
}
});
});
//Sort languages by alphabet
const list = Array.from(document.querySelector('.dropdown-menu[aria-labelledby="languageDropdown"]').children).filter(