$(document).ready(function () { var selectWeb = document.querySelector('#languageIdWeb'); var selectMobile = document.querySelector('#languageIdMobile'); var selectTab= document.querySelector('#languageIdTab'); console.log('change', selectWeb); selectWeb.addEventListener('change', function() { console.log('change 1', this.value); if (this.value == "fr_FR") { if (!window.location.pathname.startsWith('/fr/')) { // Get the current path without the leading slash let currentPath = window.location.pathname.substring(1); console.log('currentPath 1', currentPath); currentPath = currentPath.replace('ar/', ''); console.log('currentPath 2', currentPath); const newPath = '/fr/'+currentPath; const newUrl = window.location.origin +''+ newPath; window.location.replace(newUrl); } } else if (this.value == "ar_SA"){ if (!window.location.pathname.startsWith('/ar/')) { // Get the current path without the leading slash let currentPath = window.location.pathname.substring(1); console.log('currentPath 1', currentPath); currentPath = currentPath.replace('fr/', ''); console.log('currentPath 2', currentPath); const newPath = '/ar/'+currentPath; const newUrl = window.location.origin +''+ newPath; window.location.replace(newUrl); } } }); selectTab.addEventListener('change', function() { if (this.value == "fr_FR") { if (!window.location.pathname.startsWith('/fr/')) { // Get the current path without the leading slash let currentPath = window.location.pathname.substring(1); currentPath = currentPath.replace('ar/', ''); const newPath = '/fr/'+currentPath; const newUrl = window.location.origin +''+ newPath; window.location.replace(newUrl); } } else if (this.value == "ar_SA"){ if (!window.location.pathname.startsWith('/ar/')) { // Get the current path without the leading slash let currentPath = window.location.pathname.substring(1); currentPath = currentPath.replace('fr/', ''); const newPath = '/ar/'+currentPath; const newUrl = window.location.origin +''+ newPath; window.location.replace(newUrl); } } }); selectMobile.addEventListener('change', function() { if (this.value == "fr_FR") { if (!window.location.pathname.startsWith('/fr/')) { // Get the current path without the leading slash let currentPath = window.location.pathname.substring(1); console.log('currentPath 1', currentPath); currentPath = currentPath.replace('ar/', ''); console.log('currentPath 2', currentPath); const newPath = '/fr/'+currentPath; const newUrl = window.location.origin +''+ newPath; window.location.replace(newUrl); } } else if (this.value == "ar_SA"){ if (!window.location.pathname.startsWith('/ar/')) { // Get the current path without the leading slash let currentPath = window.location.pathname.substring(1); currentPath = currentPath.replace('fr/', ''); const newPath = '/ar/'+currentPath; const newUrl = window.location.origin +''+ newPath; window.location.replace(newUrl); } } }); $("#navDropdownMenuMobile, #navDropdownMenuService").click(function (event) { event.stopPropagation(); }); if (typeof navMenuLinks == 'undefined') { const navMenuLinks = document.querySelectorAll('.nav-menu-link'); // Add an event listener to each `
  • ` element navMenuLinks.forEach(navMenuLink => { // Add the `active` class to the `
  • ` element when it or any of its child elements is clicked navMenuLink.addEventListener('click', (event) => { // Get the parent `
  • ` element of the clicked element const parent = event.target.closest('.nav-menu-link'); // Remove the `active` class from all other `
  • ` elements navMenuLinks.forEach(otherNavMenuLink => { otherNavMenuLink.classList.remove('active'); }); // Add the `active` class to the parent `
  • ` element parent.classList.add('active'); const mainLink = navMenuLink.querySelector('a'); if (mainLink) { const mainHref = mainLink.getAttribute('href'); mainLink.style.textDecoration = 'none'; // Remove default underline mainLink.style.position = 'relative'; mainLink.style.color = 'inherit'; // Keep the original color mainLink.style.transition = 'color 0.3s ease'; const underline = document.createElement('span'); underline.className = 'active-underline'; underline.style.position = 'absolute'; underline.style.bottom = '-3px'; underline.style.left = '0'; underline.style.right = '0'; underline.style.height = '2px'; underline.style.backgroundColor = 'red'; underline.style.transform = 'scaleX(1)'; underline.style.transformOrigin = 'center'; underline.style.transition = 'transform 0.3s ease'; mainLink.appendChild(underline); } }); }); } });