Spaces:
Running
Running
Download script.js from Dootje/teamtrack-pro: direct link, hf CLI and curl.
- Browser
- Download file 1.92 kB
-
https://huggingface.co/spaces/Dootje/teamtrack-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/Dootje/teamtrack-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Dootje/teamtrack-pro/resolve/main/script.js
1.92 kB
| // Global event listeners | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Initialize tooltips | |
| const tooltipElements = document.querySelectorAll('[data-tooltip]'); | |
| tooltipElements.forEach(el => { | |
| el.addEventListener('mouseenter', showTooltip); | |
| el.addEventListener('mouseleave', hideTooltip); | |
| }); | |
| // Mobile menu toggle would be handled by navbar component | |
| }); | |
| function showTooltip(e) { | |
| const tooltipText = e.target.getAttribute('data-tooltip'); | |
| const tooltip = document.createElement('div'); | |
| tooltip.className = 'absolute z-50 px-3 py-1 text-sm text-white bg-gray-800 rounded whitespace-nowrap'; | |
| tooltip.textContent = tooltipText; | |
| const rect = e.target.getBoundingClientRect(); | |
| tooltip.style.top = `${rect.top - 35}px`; | |
| tooltip.style.left = `${rect.left + (rect.width / 2)}px`; | |
| tooltip.style.transform = 'translateX(-50%)'; | |
| tooltip.setAttribute('id', 'current-tooltip'); | |
| document.body.appendChild(tooltip); | |
| } | |
| function hideTooltip() { | |
| const tooltip = document.getElementById('current-tooltip'); | |
| if (tooltip) { | |
| tooltip.remove(); | |
| } | |
| } | |
| // Player metrics tracking | |
| const playerMetrics = { | |
| technical: 8.2, | |
| tactical: 7.5, | |
| physical: 9.1, | |
| mental: 6.8 | |
| }; | |
| function updatePlayerMetrics(metrics) { | |
| Object.assign(playerMetrics, metrics); | |
| // Here you would typically also update the database | |
| console.log('Player metrics updated:', playerMetrics); | |
| } | |
| // Form handling | |
| function handleFormSubmit(formId, callback) { | |
| const form = document.getElementById(formId); | |
| if (form) { | |
| form.addEventListener('submit', async (e) => { | |
| e.preventDefault(); | |
| const formData = new FormData(form); | |
| const data = Object.fromEntries(formData.entries()); | |
| if (typeof callback === 'function') { | |
| callback(data); | |
| } | |
| }); | |
| } | |
| } |