var Webflow = Webflow || [];
Webflow.push(() => {
function changeTab(shouldScroll = false) {
const hashSegments = window.location.hash.substring(1).split('/');
const offset = 90; // change this to match your fixed header height if you have one
let lastTabTarget; for (const segment of hashSegments) {
const tabTarget = document.querySelector(`[data-w-tab="${segment}"]`); if (tabTarget) {
tabTarget.click();
lastTabTarget = tabTarget;
}
}
}
const tabs = document.querySelectorAll('[data-w-tab]');
tabs.forEach(tab => {
const dataWTabValue = tab.dataset.wTab;
const parsedDataTab = dataWTabValue.replace(/\s+/g,"-").toLowerCase();
tab.dataset.wTab = parsedDataTab;
tab.addEventListener('click', () => {
history.pushState({}, '', `#${parsedDataTab}`);
});
});
if (window.location.hash) {
requestAnimationFrame(() => { changeTab(true); });
} window.addEventListener('hashchange', () => { changeTab() });
});
// Date translation function from EN to ES when website is ES
function translateDateToES(observer) {
if (observer) observer.disconnect();
const userLang = document.documentElement.lang;
const dateElements = document.querySelectorAll('.date');
if (userLang.toLowerCase().includes('es')) {
dateElements.forEach(element => {
const englishDate = element.textContent.trim();
const translatedDate = englishDate
// Translate months
.replace('Jan', 'Ene')
//.replace('Feb', 'Feb')
//.replace('Mar', 'Mar')
.replace('Apr', 'Abr')
//.replace('May', 'May')
//.replace('Jun', 'Jun')
//.replace('Jul', 'Jul')
.replace('Aug', 'Ago')
//.replace('Sep', 'Sep')
//.replace('Oct', 'Oct')
//.replace('Nov', 'Nov')
.replace('Dec', 'Dic')
element.textContent = translatedDate;
});
}
// Reconnect the observer after the DOM changes are made
if (observer) observer.observe(document.body, { childList: true, subtree: true });
}
// Function to observe DOM changes and re-run translation
function observeDOMChanges() {
const targetNode = document.body;
const config = { childList: true, subtree: true }; // Watching for changes in the DOM subtree
const callback = function(mutationsList, observer) {
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
translateDateToES(observer); // Re-run the translation function
}
}
};
const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
// Initial translation on page load
translateDateToES(observer);
}
// Start observing changes on the page
observeDOMChanges();
-->