$(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 `