SacoWeb javascript

                  document.addEventListener("DOMContentLoaded", () => {
	const logoDos = "/wp-content/uploads/2023/10/SACO-logo.png",
		idiomas = ["en-us", "es-mx"],
		textos = ["US", "PROJECTS", "SPACE", "CONTACT"],
		txtLinks = document.querySelectorAll(".header-link"),
		icoOpen = document.querySelector(".icono-open-menu"),
		icoClose = document.querySelector(".icono-cierra-menu"),
		secMenu = document.querySelector(".secc-menu"),
		divHea = document.querySelector(".div-header"),
		divIdi = document.querySelector(".div-idiomas"),
		logoImg = document.querySelector(".logo-img"),
		logImSrc = logoImg.src;

	icoOpen.addEventListener("click", (ele) => {
		secMenu.classList.add("header-movido");
	});

	icoClose.addEventListener("click", (ele) => {
		secMenu.classList.remove("header-movido");
	});

	controlL = (l) => {
		let encontrado = false;
		for (let i = 0; i < idiomas.length; i++) {
			if (location.pathname.includes(idiomas[i])) {
				l[i + 1].classList.add("lang-activo");
				encontrado = true;
			}
		}
		if (!encontrado) l[0].classList.add("lang-activo");

		if (encontrado) {
			let bUri = location.pathname.substring(1, 6);
			logoImg.parentElement.href = logoImg.parentElement.href + bUri;
			if (location.pathname.includes("/en-us/"))
				for (let i = 0; i < txtLinks.length; i++) {
					txtLinks[i].innerText = textos[i];
					txtLinks[i].href = "/en-us/" + textos[i].toLowerCase();
				}
		}
	};

	manLinks = () => {
		const heLinks = document.querySelectorAll(".header-link"),
			linEs = document.createElement("a"),
			linUs = document.createElement("a"),
			linMx = document.createElement("a");

		linEs.href = "/";
		linEs.className = "link-lang";
		linEs.textContent = "ES";
		linUs.href = "/en-us/";
		linUs.className = "link-lang";
		linUs.textContent = "US";
		linMx.href = "/es-mx/";
		linMx.className = "link-lang";
		linMx.textContent = "MX";
		linksL = document.querySelectorAll(".link-lang");

		if (linksL.length > 0)
			for (let i = 0; i < linksL.length; i++) linksL[i].parentNode.removeChild(linksL[i]);

		if (screen.width < 768) {
			divHea.appendChild(linEs);
			divHea.appendChild(linUs);
			divHea.appendChild(linMx);
			linEs.classList.add("link-lang-respon");
			linUs.classList.add("link-lang-respon");
			linMx.classList.add("link-lang-respon");
		} else {
			divIdi.appendChild(linEs);
			divIdi.appendChild(linUs);
			divIdi.appendChild(linMx);
		}

		linksL = document.querySelectorAll(".link-lang");
		controlL(linksL);
	};

	window.onresize = () => {
		manLinks();
	};
	window.addEventListener("scroll", () => {
		if (pageYOffset > 50) {
			logoImg.src = logoDos;
			logoImg.srcset = logoDos;
			logoImg.classList.add("logoH");
			secMenu.classList.add("menuOscuro");
		} else {
			logoImg.src = logImSrc;
			logoImg.srcset = logImSrc;
			logoImg.classList.remove("logoH");
			secMenu.classList.remove("menuOscuro");
		}
	});
	manLinks();

	//const updateSectionLinks = () => {
	if (location.pathname.includes("/es-mx/")) {
		txtLinks[0].href = "/es-mx/nosotros";
		txtLinks[1].href = "/es-mx/proyectos";
		txtLinks[2].href = "/es-mx/espacio";
		txtLinks[3].href = "/es-mx/contacto";
	} else if (location.pathname.includes("/en-us/")) {
		txtLinks[0].href = "/en-us/about-us";
		txtLinks[1].href = "/en-us/projects";
		txtLinks[2].href = "/en-us/space";
		txtLinks[3].href = "/en-us/contact";
	} /* else {
		txtLinks[0].href = "/nosotros";
		txtLinks[1].href = "/proyectos";
		txtLinks[2].href = "/espacio";
		txtLinks[3].href = "/contacto";
	}*/
	//};
	//updateSectionLinks()
});