File size: 3,385 Bytes
1e1dd95 8fadc60 1e1dd95 8fadc60 1e1dd95 | 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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 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);
});
}
} |