File size: 1,900 Bytes
d03c1cb |
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
// 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 };
} |