Spaces:
Running
Running
File size: 1,385 Bytes
3e519ec | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | // Main Application Logic
document.addEventListener('DOMContentLoaded', () => {
// Handle Navigation / SPA Routing
const handleNavigation = () => {
const hash = window.location.hash || '#home';
const sections = document.querySelectorAll('.view-section');
sections.forEach(section => {
if (section.id === hash.substring(1)) {
section.classList.remove('hidden');
// Reset animation
section.classList.remove('fade-in');
void section.offsetWidth; // trigger reflow
section.classList.add('fade-in');
} else {
section.classList.add('hidden');
}
});
// Update active state in navbar if needed (optional implementation)
const navLinks = document.querySelectorAll('a[href^="#"]');
navLinks.forEach(link => {
if (link.getAttribute('href') === hash) {
link.classList.add('text-primary-400');
} else {
link.classList.remove('text-primary-400');
}
});
};
// Listen for hash changes
window.addEventListener('hashchange', handleNavigation);
// Initial load
handleNavigation();
// Global initialization for any components that need it
console.log('FlowState OS Initialized ๐');
}); |