bigbrotherr's picture
--- Change Log Entry: 2025-10-26 03:18:42 ---
d03c1cb verified
raw
history blame
1.9 kB
// Shared JavaScript across all pages
// Initialize application
document.addEventListener('DOMContentLoaded', function() {
console.log('JCode Evolution Tracker loaded');
// Add subtle animations to cards
const cards = document.querySelectorAll('.bg-white\\/10');
cards.forEach((card, index) => {
card.style.animationDelay = `${index * 0.1}s`;
card.classList.add('fade-in-up');
});
// Handle navigation active states
const currentPath = window.location.pathname;
const navLinks = document.querySelectorAll('a[href]');
navLinks.forEach(link => {
if (link.getAttribute('href') === currentPath) {
link.classList.add('active');
}
});
});
// Utility functions
const utils = {
// Format date for display
formatDate: (dateString) => {
const options = { year: 'numeric', month: 'long', day: 'numeric' };
return new Date(dateString).toLocaleDateString(undefined, options);
},
// Truncate text with ellipsis
truncateText: (text, maxLength = 100) => {
if (text.length <= maxLength) return text;
return text.substring(0, maxLength) + '...';
},
// Debounce function for performance
debounce: (func, wait) => {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
},
// Generate random color
randomColor: () => {
const colors = ['#667eea', '#764ba2', '#f093fb', '#f5576c', '#4facfe', '#00f2fe'];
return colors[Math.floor(Math.random() * colors.length)];
}
};
// Export for module usage
if (typeof module !== 'undefined' && module.exports) {
module.exports = { utils };
}