-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
98 lines (87 loc) · 3.66 KB
/
Copy pathindex.html
File metadata and controls
98 lines (87 loc) · 3.66 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Risiko Ranking</title>
<link rel="stylesheet" href="style.css">
<script src="app.js"></script>
</head>
<body>
<div class="container">
<header>
<h1>Risiko Ranking</h1>
<p class="subtitle">Classifica Ufficiale</p>
</header>
<nav>
<a href="index.html" class="active">Classifica</a>
<a href="matches.html">Partite</a>
<a href="rules.html">Regolamento</a>
<a href="admin.html">Admin</a>
</nav>
<div class="card">
<div id="loading" class="loading">Caricamento...</div>
<div class="table-container fade-in">
<table id="leaderboard" class="hidden">
<thead>
<tr>
<th>#</th>
<th>Giocatore</th>
<th>Partite</th>
<th>Rating</th>
</tr>
</thead>
<tbody id="leaderboard-body">
<!-- Populated via JS -->
</tbody>
</table>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', async () => {
try {
const players = await fetchAPI('/leaderboard');
const tbody = document.getElementById('leaderboard-body');
const loading = document.getElementById('loading');
const table = document.getElementById('leaderboard');
loading.classList.add('hidden');
table.classList.remove('hidden');
let rankCounter = 0;
let provisionalHeaderShown = false;
players.forEach((p) => {
const tr = document.createElement('tr');
let rankDisplay;
if (p.is_ranked) {
rankCounter++;
rankDisplay = rankCounter;
} else {
tr.classList.add('provisional');
rankDisplay = '<span title="Punteggio Provvisorio (Troppe poche partite)">-</span>';
}
tr.innerHTML = `
<td class="rank-cell">${rankDisplay}</td>
<td style="font-weight: 500">
${p.name}
${!p.is_ranked ? `<span style="font-size: 0.75rem; opacity: 0.7; margin-left: 5px;">(Provvisorio)</span>` : ''}
</td>
<td>
${p.games_played}
${!p.is_ranked ? `<span style="font-size: 0.7rem; color: var(--text-secondary); display: block;">Minimo: ${p.threshold}</span>` : ''}
</td>
<td class="rating-cell">
${formatRating(p.rating)}
<a href="player.html?id=${p.id}" style="float: right; color: var(--text-secondary); text-decoration: none; font-size: 0.8em">↗</a>
</td>
`;
tr.onclick = () => window.location.href = `player.html?id=${p.id}`;
tr.style.cursor = 'pointer';
tbody.appendChild(tr);
});
} catch (err) {
document.getElementById('loading').innerText = 'Errore caricamento: ' + err.message;
}
});
</script>
</body>
</html>