// Shared JavaScript across all pages document.addEventListener('DOMContentLoaded', function() { // Initialize tooltips for all elements with data-tooltip attribute const tooltipElements = document.querySelectorAll('[data-tooltip]'); tooltipElements.forEach(el => { const tooltipText = el.getAttribute('data-tooltip'); el.addEventListener('mouseenter', () => { const tooltip = document.createElement('div'); tooltip.className = 'absolute z-50 bg-gray-800 text-white text-sm px-2 py-1 rounded whitespace-nowrap'; tooltip.textContent = tooltipText; const rect = el.getBoundingClientRect(); tooltip.style.top = `${rect.top - 30}px`; tooltip.style.left = `${rect.left + rect.width/2}px`; tooltip.style.transform = 'translateX(-50%)'; tooltip.id = 'current-tooltip'; document.body.appendChild(tooltip); }); el.addEventListener('mouseleave', () => { const tooltip = document.getElementById('current-tooltip'); if (tooltip) { tooltip.remove(); } }); }); // Add active class to current page link in navbar const currentPath = window.location.pathname; const navLinks = document.querySelectorAll('custom-navbar a'); navLinks.forEach(link => { if (link.getAttribute('href') === currentPath) { link.classList.add('font-semibold', 'text-blue-100'); } }); });