// Gridiron Nexus Command - Main JavaScript document.addEventListener('DOMContentLoaded', function() { // Initialize Feather Icons if (typeof feather !== 'undefined') { feather.replace(); } // Dashboard Role Selection const roleCards = document.querySelectorAll('.dashboard-role-card'); roleCards.forEach(card => { card.addEventListener('click', function() { // Remove active class from all cards roleCards.forEach(c => c.classList.remove('active')); // Add active class to clicked card this.classList.add('active'); const role = this.dataset.role; simulateDashboardChange(role); // Show notification showNotification(`Switched to ${role.charAt(0).toUpperCase() + role.slice(1)} Dashboard`); }); }); // Map Layer Toggles const mapToggles = document.querySelectorAll('.map-toggle'); mapToggles.forEach(toggle => { toggle.addEventListener('click', function() { const layer = this.dataset.layer; // Update active state mapToggles.forEach(t => t.classList.remove('bg-primary-700', 'text-white')); this.classList.add('bg-primary-700', 'text-white'); // Simulate layer change simulateMapLayerChange(layer); }); }); // Live Data Simulation let liveDataInterval; function startLiveDataSimulation() { if (liveDataInterval) clearInterval(liveDataInterval); liveDataInterval = setInterval(() => { // Update live metrics updateLiveMetrics(); // Animate data points animateDataBreath(); }, 3000); // Update every 3 seconds } function updateLiveMetrics() { const metrics = document.querySelectorAll('.ai-insight-card p span'); metrics.forEach(metric => { if (metric.textContent.includes('%')) { const currentValue = parseInt(metric.textContent); const change = Math.random() * 5 - 2.5; // Random change between -2.5 and +2.5 const newValue = Math.max(0, Math.min(100, Math.round(currentValue + change))); metric.textContent = `${newValue}%`; // Add visual feedback metric.style.color = newValue > currentValue ? '#10b981' : '#ef4444'; setTimeout(() => { metric.style.color = ''; }, 1000); } }); } function animateDataBreath() { const breathElements = document.querySelectorAll('.animate-breath'); breathElements.forEach(el => { el.style.animation = 'none'; setTimeout(() => { el.style.animation = 'breath 6s ease-in-out infinite'; }, 10); }); } // Simulate Dashboard Change function simulateDashboardChange(role) { const insights = document.querySelectorAll('.ai-insight-card'); const roleInsights = { coach: ['Game Management', 'Clock Control', 'Timeout Optimization'], analyst: ['Predictive Models', 'Trend Analysis', 'Statistical Significance'], scout: ['Player Evaluation', 'Opponent Weaknesses', 'Talent Projection'], player: ['Performance Review', 'Matchup Analysis', 'Development Goals'] }; insights.forEach((insight, index) => { const title = insight.querySelector('h4'); const content = insight.querySelector('p'); if (title && content) { title.textContent = `${roleInsights[role][index] || 'AI Insight'}`; content.textContent = getRandomInsightForRole(role); // Add animation insight.style.animation = 'slideInRight 0.5s ease-out'; setTimeout(() => { insight.style.animation = ''; }, 500); } }); } function getRandomInsightForRole(role) { const insights = { coach: [ 'Zone coverage showing 15% vulnerability on deep left side.', 'Red zone efficiency up 8% when using 2-TE sets.', 'Third down conversion rate optimal from 11 personnel.' ], analyst: [ 'EPA model predicts +0.12 advantage with RPO calls.', 'Correlation detected between defensive alignment and run success.', 'Machine learning identifies new passing lane vulnerability.' ], scout: [ 'WR prospect shows 95th percentile separation on go routes.', 'DT anchor strength metrics exceed NFL average by 12%.', 'RB vision score improved 22% over last season.' ], player: [ 'Your release time improved 0.08s from last game.', 'Route efficiency at 92% on crossing patterns.', 'Top speed reached 21.3 mph, career high.' ] }; const roleInsights = insights[role] || insights.coach; return roleInsights[Math.floor(Math.random() * roleInsights.length)]; } // Simulate Map Layer Change function simulateMapLayerChange(layer) { const map = document.querySelector('.map-visualization'); if (!map) return; // Remove existing layer classes map.classList.remove('heatmap-active', 'tracking-active', 'zones-active'); // Add new layer class map.classList.add(`${layer}-active`); // Update visual elements based on layer const aiCircle = map.querySelector('.ai-circle'); if (aiCircle) { switch(layer) { case 'heatmap': aiCircle.style.borderColor = '#ef4444'; aiCircle.querySelector('span').textContent = 'HOT'; break; case 'tracking': aiCircle.style.borderColor = '#06b6d4'; aiCircle.querySelector('span').textContent = 'TRK'; break; case 'zones': aiCircle.style.borderColor = '#10b981'; aiCircle.querySelector('span').textContent = 'ZONE'; break; } } } // Show Notification function showNotification(message, type = 'info') { const notification = document.createElement('div'); notification.className = `fixed top-4 right-4 px-6 py-3 rounded-lg shadow-lg z-50 transform translate-x-full transition-transform duration-300 ${ type === 'success' ? 'bg-green-900/90 border-l-4 border-green-500' : type === 'error' ? 'bg-red-900/90 border-l-4 border-red-500' : 'bg-surface border-l-4 border-primary-500' }`; notification.innerHTML = `