File size: 3,072 Bytes
7a83f15 | 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 | // Main script file for FRL website
document.addEventListener('DOMContentLoaded', function() {
// Initialize tooltips
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Countdown timer for next event
function updateCountdown() {
const eventDate = new Date('May 15, 2023 20:00:00 GMT').getTime();
const now = new Date().getTime();
const distance = eventDate - now;
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById('countdown').innerHTML = `
<div class="countdown-item">
<span class="countdown-number">${days}</span>
<span class="countdown-label">Days</span>
</div>
<div class="countdown-item">
<span class="countdown-number">${hours}</span>
<span class="countdown-label">Hours</span>
</div>
<div class="countdown-item">
<span class="countdown-number">${minutes}</span>
<span class="countdown-label">Minutes</span>
</div>
<div class="countdown-item">
<span class="countdown-number">${seconds}</span>
<span class="countdown-label">Seconds</span>
</div>
`;
}
setInterval(updateCountdown, 1000);
updateCountdown();
});
// Discord integration function
function connectDiscord() {
// This would be replaced with actual Discord OAuth implementation
window.location.href = 'https://discord.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code&scope=identify%20email';
}
// Function to fetch leaderboard data from API
async function fetchLeaderboard() {
try {
const response = await fetch('/api/leaderboard');
const data = await response.json();
return data;
} catch (error) {
console.error('Error fetching leaderboard:', error);
return null;
}
}
// Initialize SimGrid integration
async function initSimGrid() {
const integration = document.createElement('simgrid-integration');
document.querySelector('main').appendChild(integration);
}
document.addEventListener('DOMContentLoaded', function() {
initSimGrid();
// Rest of existing code...
|