hugfaceguy0001's picture
为网页添加语言切换选项,至少包括中文、英文
baa5998 verified
document.addEventListener('DOMContentLoaded', () => {
// Animate probability bars on load
const bars = document.querySelectorAll('[style*="width"]');
bars.forEach(bar => {
const width = bar.style.width;
bar.style.width = '0';
setTimeout(() => {
bar.style.transition = 'width 1.5s ease-out';
bar.style.width = width;
}, 300);
});
// Add hover effects to cards
const cards = document.querySelectorAll('.bg-gray-800');
cards.forEach(card => {
card.addEventListener('mouseenter', () => {
card.classList.add('transform', 'scale-105');
});
card.addEventListener('mouseleave', () => {
card.classList.remove('transform', 'scale-105');
});
});
});
// Function to share results
function shareResults() {
if (navigator.share) {
navigator.share({
title: 'Probability Paradox',
text: 'Check out which improbable dream is slightly more probable!',
url: window.location.href,
})
.catch(err => console.log('Error sharing:', err));
} else {
// Fallback for browsers that don't support Web Share API
alert('Share this page manually!');
}
}