From 1d9f9459df1238cd6c1471c408e4a6e03ba72da1 Mon Sep 17 00:00:00 2001 From: Michael Pilosov Date: Thu, 25 Jun 2026 19:44:35 +0000 Subject: [PATCH] ui: default to a new game; clean placeholder game info; status beside info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Open on a fresh 'You vs Opponent' game instead of the Immortal Game. - Hide chess.js Seven-Tag-Roster placeholders ("?", "????.??.??") so a new game reads just "You vs Opponent" rather than "You vs Opponent — ? — ????.??.??". - Move the turn/move status onto the same row as the game info (top of the side panel) instead of below the move list. --- src/chess_pressure/static/app.js | 20 +++++++++++--------- src/chess_pressure/static/index.html | 11 ++++++----- src/chess_pressure/static/style.css | 18 +++++++++++++----- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/chess_pressure/static/app.js b/src/chess_pressure/static/app.js index 8e1f8d3..a08bd0e 100644 --- a/src/chess_pressure/static/app.js +++ b/src/chess_pressure/static/app.js @@ -18,6 +18,7 @@ let legalMoves = []; // legal moves from selected square const PLAY_SPEED = 800; // ms between auto-advance + const NEW_GAME_PGN = '[White "You"]\n[Black "Opponent"]\n[Result "*"]\n\n*'; // --- Pressure colors --- function pressureColor(value, maxAbs) { @@ -241,10 +242,13 @@ return; } const h = gameData.headers; + // chess.js fills the Seven Tag Roster with "?" / "????.??.??" placeholders; + // skip those so a fresh game just reads "You vs Opponent". + const real = (v) => v && v !== "?" && v !== "????.??.??"; const parts = []; - if (h.White) parts.push(`${h.White} vs ${h.Black || "?"}`); - if (h.Event) parts.push(h.Event); - if (h.Date) parts.push(h.Date); + if (real(h.White) || real(h.Black)) parts.push(`${h.White || "?"} vs ${h.Black || "?"}`); + if (real(h.Event)) parts.push(h.Event); + if (real(h.Date)) parts.push(h.Date); el.textContent = parts.join(" — "); } @@ -489,11 +493,9 @@ const select = document.getElementById("game-select"); populateGameSelect(); - // Load first game by default - if (BUILTIN_GAMES.length) { - loadGame(BUILTIN_GAMES[0].id); - select.value = BUILTIN_GAMES[0].id; - } + // Start on a fresh game so the player can begin immediately. + loadPGN(NEW_GAME_PGN); + select.value = "__new"; // Show board after first render (prevents tan flash) document.getElementById("board").classList.add("ready"); @@ -502,7 +504,7 @@ select.addEventListener("change", (e) => { const v = e.target.value; if (v === "__new") { - loadPGN('[White "You"]\n[Black "Opponent"]\n[Result "*"]\n\n*'); + loadPGN(NEW_GAME_PGN); } else if (v.startsWith("saved:")) { loadSaved(v.slice(6)); } else if (v) { diff --git a/src/chess_pressure/static/index.html b/src/chess_pressure/static/index.html index 1b2e5aa..09d1fc0 100644 --- a/src/chess_pressure/static/index.html +++ b/src/chess_pressure/static/index.html @@ -4,7 +4,7 @@ Chess Pressure - + @@ -63,7 +63,10 @@ -
+
+ + +
@@ -78,8 +81,6 @@ - -
@@ -128,6 +129,6 @@ - + diff --git a/src/chess_pressure/static/style.css b/src/chess_pressure/static/style.css index 787bdbc..4b7fa2a 100644 --- a/src/chess_pressure/static/style.css +++ b/src/chess_pressure/static/style.css @@ -235,12 +235,20 @@ main { .game-selector button:hover, .fork-controls button:hover { background: var(--move-active); } -/* --- Game info --- */ +/* --- Game info + status (one row) --- */ +.game-meta { + display: flex; + justify-content: space-between; + align-items: baseline; + gap: 0.6rem; + flex-wrap: wrap; + padding: 0.4rem 0; + border-bottom: 1px solid var(--border); +} .game-info { font-size: 0.8rem; color: var(--fg2); - padding: 0.4rem 0; - border-bottom: 1px solid var(--border); + min-width: 0; } /* --- Move list --- */ @@ -340,8 +348,8 @@ dialog select { .status-bar { font-size: 0.8rem; color: var(--fg2); - padding: 0.4rem 0; - border-top: 1px solid var(--border); + white-space: nowrap; + text-align: right; } /* --- PGN Dialog --- */