| |
| function formatDate(dateString) { |
| const options = { year: 'numeric', month: 'long', day: 'numeric' }; |
| return new Date(dateString).toLocaleDateString('tr-TR', options); |
| } |
|
|
| function calculateAge(birthDate) { |
| const today = new Date(); |
| const birthDateObj = new Date(birthDate); |
| let age = today.getFullYear() - birthDateObj.getFullYear(); |
| const monthDiff = today.getMonth() - birthDateObj.getMonth(); |
| |
| if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDateObj.getDate())) { |
| age--; |
| } |
| |
| return age; |
| } |
|
|
| |
| function checkAuth(requiredRole, redirectTo = 'index.html') { |
| |
| const role = localStorage.getItem('role'); |
| if (!role || (requiredRole && role !== requiredRole)) { |
| window.location.href = redirectTo; |
| } |
| } |
|
|
| |
| function initTooltips() { |
| const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); |
| tooltipTriggerList.map(function (tooltipTriggerEl) { |
| return new bootstrap.Tooltip(tooltipTriggerEl); |
| }); |
| } |
|
|
| |
| document.addEventListener('DOMContentLoaded', function() { |
| initTooltips(); |
| feather.replace(); |
| }); |