Files
FTCWebsite/static/js/scripts.js
abhiramtx befc3160be Saved your changes before starting work
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 5e584ab0-c340-4432-97ef-1972582b60e9
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 6d4dbe7c-69e4-4510-bd62-638ff9c78d5c
2025-11-08 22:13:45 +00:00

34 lines
1.1 KiB
JavaScript

document.addEventListener('DOMContentLoaded', function() {
const currentPath = window.location.pathname;
const navLinks = document.querySelectorAll('.nav-item-center, .nav-item-left');
navLinks.forEach(navItem => {
const link = navItem.querySelector('a');
if (link) {
const linkPath = new URL(link.href).pathname;
if (linkPath === currentPath || (currentPath === '/' && linkPath === '/')) {
navItem.classList.add('active');
}
}
});
const sidebarLinks = document.querySelectorAll('.sidebar a');
const hash = window.location.hash;
if (hash) {
sidebarLinks.forEach(link => {
if (link.getAttribute('href') === hash) {
link.classList.add('active');
}
});
} else if (sidebarLinks.length > 0) {
sidebarLinks[0].classList.add('active');
}
sidebarLinks.forEach(link => {
link.addEventListener('click', function() {
sidebarLinks.forEach(l => l.classList.remove('active'));
this.classList.add('active');
});
});
});