diff --git a/app.js b/app.js index 071859f..cd5f41e 100644 --- a/app.js +++ b/app.js @@ -15,6 +15,7 @@ let currentMoveIndex = -1; let userSelectedGame = false; let userScrolledMoves = false; let lastMtime = 0; +let currentRound = 0; let pollId = 0; /** @@ -26,8 +27,12 @@ async function loadPGN(showOverlay = true) { hideError(); try { + if (currentRound === 0) { + if (showOverlay) showLoading(false); + return; + } const [pgnResponse, statusResponse] = await Promise.all([ - fetch(`http://localhost:8111/pgn?since=${lastMtime}`), + fetch(`http://localhost:8111/pgn/${currentRound}?since=${lastMtime}`), fetch('http://localhost:8111/status').catch(() => null) ]); @@ -382,6 +387,7 @@ function updateStandings() { return res.json(); }) .then(data => { + if (data && data.round) currentRound = data.round; const container = document.getElementById('standings-content'); if (!data || data.error) { container.innerHTML = '
Daten nicht verfügbar
'; diff --git a/server.py b/server.py index 7f91e32..b2110a1 100644 --- a/server.py +++ b/server.py @@ -132,6 +132,7 @@ def fetch_standings(): "losses": clean[7], "points": clean[8], "round_info": round_info, + "round": current_round, } return None except Exception as e: @@ -162,7 +163,8 @@ class PGNHandler(http.server.BaseHTTPRequestHandler): def do_GET(self): parsed_path = urllib.parse.urlparse(self.path) - if parsed_path.path == "/pgn": + parts = parsed_path.path.strip("/").split("/") + if len(parts) == 2 and parts[0] == "pgn" and parts[1].isdigit(): params = urllib.parse.parse_qs(parsed_path.query) since = float(params.get("since", [0])[0]) content, mtime = get_pgn_content_longpoll(since)