// Function to toggle the visibility of divs based on the page URL
function toggleDivsVisibilityBasedOnURL() {
// Get the current page URL
const currentURL = window.location.href;
// Check if the URL starts with 'fr.'
const isFrenchURL = currentURL.startsWith('https://fr.') || currentURL.startsWith('http://fr.');
// Define the divs to be toggled based on the URL
const divsToToggle = [
{ divSelector: '#form-FR', showOnFrench: true },
{ divSelector: '#form-EN', showOnFrench: false }
];
// Loop through each div and toggle visibility
divsToToggle.forEach(({ divSelector, showOnFrench }) => {
// Get the div to be shown/hidden
const div = document.querySelector(divSelector);
if (!div) {
console.warn(`Target div ${divSelector} not found on the page.`);
return;
}
// Show or hide the div based on the URL
if ((isFrenchURL && showOnFrench) || (!isFrenchURL && !showOnFrench)) {
div.style.display = 'block';
} else {
div.style.display = 'none';
}
});
}
// Run the function after the page has loaded
window.addEventListener('DOMContentLoaded', toggleDivsVisibilityBasedOnURL);