Import all events and results from our simgrid page: https://www.thesimgrid.com/communities/formula-racing-league
7a83f15 verified Download script.js from bruneeto84/speedgrid-sync-masters: direct link, hf CLI and curl.
- Browser
- Download file 3.07 kB
-
https://huggingface.co/spaces/bruneeto84/speedgrid-sync-masters/resolve/main/script.js
- Command line
-
hf download hf://spaces/bruneeto84/speedgrid-sync-masters/script.js
-
curl -L -o script.js https://huggingface.co/spaces/bruneeto84/speedgrid-sync-masters/resolve/main/script.js
3.07 kB
| // 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... | |