File size: 1,306 Bytes
b257eec | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | // Shared functions
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;
}
// Check authentication
function checkAuth(requiredRole, redirectTo = 'index.html') {
// In a real app, this would check server-side authentication
const role = localStorage.getItem('role');
if (!role || (requiredRole && role !== requiredRole)) {
window.location.href = redirectTo;
}
}
// Initialize tooltips
function initTooltips() {
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
}
// Initialize after DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
initTooltips();
feather.replace();
}); |