File size: 1,922 Bytes
0938549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf94e78
 
 
 
 
 
 
 
 
 
 
 
 
0938549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// 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);
            }
        });
    }
}