| |
| document.addEventListener('DOMContentLoaded', function() { |
| |
| const userRole = localStorage.getItem('userRole') || 'teacher'; |
| |
| |
| 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'); |
| } |
| |
| |
| 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'); |
| }); |
| } |
| }); |
|
|
| |
| 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; |
| } |
|
|
| |
| function sendWhatsAppMessage(phone, message) { |
| const encodedMessage = encodeURIComponent(message); |
| window.open(`https://wa.me/${phone}?text=${encodedMessage}`, '_blank'); |
| } |