// Handle role-based UI elements document.addEventListener('DOMContentLoaded', function() { // Get user role from localStorage (simulated) const userRole = localStorage.getItem('userRole') || 'teacher'; // Hide/show elements based on role const adminElements = document.querySelectorAll('.admin-only'); const teacherElements = document.querySelectorAll('.teacher-only'); const studentElements = document.querySelectorAll('.student-only'); if (userRole === 'admin') { adminElements.forEach(el => el.style.display = 'block'); teacherElements.forEach(el => el.style.display = 'none'); studentElements.forEach(el => el.style.display = 'none'); } else if (userRole === 'teacher') { adminElements.forEach(el => el.style.display = 'none'); teacherElements.forEach(el => el.style.display = 'block'); studentElements.forEach(el => el.style.display = 'none'); } else { adminElements.forEach(el => el.style.display = 'none'); teacherElements.forEach(el => el.style.display = 'none'); studentElements.forEach(el => el.style.display = 'block'); } // Mobile menu toggle const mobileMenuButton = document.getElementById('mobile-menu-button'); const mobileMenu = document.getElementById('mobile-menu'); if (mobileMenuButton && mobileMenu) { mobileMenuButton.addEventListener('click', function() { const expanded = this.getAttribute('aria-expanded') === 'true'; this.setAttribute('aria-expanded', !expanded); mobileMenu.classList.toggle('hidden'); }); } }); // Calculate age from birth date function calculateAge(birthDate) { const today = new Date(); const birth = new Date(birthDate); let age = today.getFullYear() - birth.getFullYear(); const monthDiff = today.getMonth() - birth.getMonth(); if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birth.getDate())) { age--; } return age; } // Simulate sending WhatsApp message function sendWhatsAppMessage(phone, message) { const encodedMessage = encodeURIComponent(message); window.open(`https://wa.me/${phone}?text=${encodedMessage}`, '_blank'); }