document.addEventListener('DOMContentLoaded', function() { // Initialize tooltips const tooltipTriggers = document.querySelectorAll('.tooltip-trigger'); tooltipTriggers.forEach(trigger => { trigger.addEventListener('mouseenter', function() { const tooltip = this.nextElementSibling; tooltip.classList.remove('hidden'); tooltip.classList.add('block'); }); trigger.addEventListener('mouseleave', function() { const tooltip = this.nextElementSibling; tooltip.classList.remove('block'); tooltip.classList.add('hidden'); }); }); // Mobile menu toggle functionality const mobileMenuButton = document.getElementById('mobile-menu-button'); const mobileMenu = document.getElementById('mobile-menu'); if (mobileMenuButton && mobileMenu) { mobileMenuButton.addEventListener('click', function() { mobileMenu.classList.toggle('hidden'); }); } // Dark mode toggle const darkModeToggle = document.getElementById('dark-mode-toggle'); if (darkModeToggle) { darkModeToggle.addEventListener('click', function() { document.documentElement.classList.toggle('dark'); localStorage.setItem('darkMode', document.documentElement.classList.contains('dark')); }); // Check for saved user preference if (localStorage.getItem('darkMode') === 'false') { document.documentElement.classList.remove('dark'); } } // Favorite button functionality const favoriteButtons = document.querySelectorAll('.favorite-btn'); favoriteButtons.forEach(button => { button.addEventListener('click', function() { this.classList.toggle('text-red-500'); this.classList.toggle('text-gray-400'); }); }); }); // Crew builder functions function calculateCrewEfficiency(crewSkills) { // Placeholder for crew efficiency calculation logic return Math.min(100, crewSkills.length * 10 + 30); } // Hugging Face API integration async function analyzeCrew(crewData) { try { const response = await fetch('https://api-inference.huggingface.co/models/your-model-name', { method: 'POST', headers: { 'Authorization': 'Bearer your-huggingface-token', 'Content-Type': 'application/json' }, body: JSON.stringify(crewData) }); return await response.json(); } catch (error) { console.error('Error analyzing crew:', error); return null; } } function shareCrewBuild(buildId) { // Placeholder for share functionality const shareUrl = `${window.location.origin}/crew/${buildId}`; if (navigator.share) { navigator.share({ title: 'Check out my WoT Blitz crew build', text: 'I created this awesome crew configuration for WoT Blitz!', url: shareUrl, }).catch(err => { console.error('Error sharing:', err); }); } else { // Fallback for browsers that don't support Web Share API navigator.clipboard.writeText(shareUrl).then(() => { alert('Link copied to clipboard!'); }).catch(err => { console.error('Could not copy text: ', err); }); } }