🚀 Patch auto
This commit is contained in:
102
frontend/public/scoreboard/index.html
Normal file
102
frontend/public/scoreboard/index.html
Normal file
@@ -0,0 +1,102 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Super Sunday — Classement live</title>
|
||||
<link rel="stylesheet" href="/assets/style.css?v=13" />
|
||||
<style>
|
||||
.wrap{max-width:1080px;margin:0 auto}
|
||||
table{width:100%;border-collapse:separate;border-spacing:0 10px}
|
||||
th,td{text-align:left;padding:10px 12px}
|
||||
thead th{font-weight:700;letter-spacing:.02em}
|
||||
tbody tr{background:rgba(15,27,51,.6);border:1px solid rgba(255,255,255,.08)}
|
||||
tbody tr td:first-child{border-top-left-radius:14px;border-bottom-left-radius:14px}
|
||||
tbody tr td:last-child{border-top-right-radius:14px;border-bottom-right-radius:14px}
|
||||
.muted{color:#a9bfd6}
|
||||
.controls{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}
|
||||
.controls select,.controls input{min-width:180px}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Classement Live</h1>
|
||||
<nav>
|
||||
<a href="/">Accueil</a>
|
||||
<a href="/events">Événements</a>
|
||||
<a href="/scoreboard" class="active">Classement</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container wrap">
|
||||
<div class="controls">
|
||||
<select id="tid"></select>
|
||||
<button id="refresh" class="btn-outline">Rafraîchir</button>
|
||||
<label class="muted"><input type="checkbox" id="auto" checked> Auto-refresh (10s)</label>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th><th>Joueur</th><th class="muted">J</th><th>Pts (jeux)</th><th>Diff</th><th class="muted">V</th><th class="muted">N</th><th class="muted">D</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="rows"></tbody>
|
||||
</table>
|
||||
<p id="status" class="muted"></p>
|
||||
</main>
|
||||
|
||||
<script type="module">
|
||||
import { listTournaments } from '/assets/api.js?v=13';
|
||||
async function fetchJSON(url){ const r=await fetch(url); if(!r.ok) throw new Error(await r.text()); return r.json(); }
|
||||
|
||||
const tid = document.getElementById('tid');
|
||||
const rows = document.getElementById('rows');
|
||||
const status = document.getElementById('status');
|
||||
const auto = document.getElementById('auto');
|
||||
|
||||
async function loadTournaments(){
|
||||
const ts = await listTournaments();
|
||||
tid.innerHTML = ['<option value="">— choisir un tournoi —</option>'].concat(
|
||||
ts.map(t=>`<option value="${t.id}">#${t.id} — ${t.name}</option>`)
|
||||
).join('');
|
||||
}
|
||||
|
||||
async function render(){
|
||||
const id = Number(tid.value||'0');
|
||||
if(!id){ rows.innerHTML=''; status.textContent=''; return; }
|
||||
try{
|
||||
const data = await fetchJSON(`/api/tournaments/${id}/standings`);
|
||||
const st = data.standings || [];
|
||||
rows.innerHTML = st.map(s => `
|
||||
<tr>
|
||||
<td>${s.rank}</td>
|
||||
<td><strong>${s.name}</strong></td>
|
||||
<td class="muted">${s.played}</td>
|
||||
<td>${s.points}</td>
|
||||
<td>${(s.games_for - s.games_against)}</td>
|
||||
<td class="muted">${s.wins}</td>
|
||||
<td class="muted">${s.draws}</td>
|
||||
<td class="muted">${s.losses}</td>
|
||||
</tr>`).join('');
|
||||
status.textContent = st.length ? '' : 'Aucun résultat pour le moment.';
|
||||
}catch(e){
|
||||
status.textContent = 'Erreur: ' + e.message;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('refresh').addEventListener('click', render);
|
||||
tid.addEventListener('change', render);
|
||||
|
||||
let timer = null;
|
||||
function tick(){
|
||||
if (auto.checked) render();
|
||||
timer = setTimeout(tick, 10000);
|
||||
}
|
||||
auto.addEventListener('change', ()=>{ if(!auto.checked && timer){ clearTimeout(timer); } else { tick(); } });
|
||||
|
||||
await loadTournaments();
|
||||
tick();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user