diff --git a/src/chess_pressure/static/app.js b/src/chess_pressure/static/app.js index 042bab0..f806300 100644 --- a/src/chess_pressure/static/app.js +++ b/src/chess_pressure/static/app.js @@ -532,8 +532,26 @@ updateSavedControls(); } - function exportPGN() { + async function exportPGN() { if (!gameData) return; + + // Let the user set player names before download; pre-fill from headers, + // treating placeholders ("?") as blank. Names are written back so they show + // on screen and persist on Save too. + const whiteEl = document.getElementById("pgn-white"); + const blackEl = document.getElementById("pgn-black"); + const real = (v) => (v && v !== "?" && v !== "????.??.??" ? v : ""); + whiteEl.value = real(gameData.headers.White); + blackEl.value = real(gameData.headers.Black); + setTimeout(() => { whiteEl.focus(); whiteEl.select(); }, 0); + + const ok = await openModal(document.getElementById("export-pgn-dialog")); + if (!ok) return; + + gameData.headers.White = whiteEl.value.trim() || "White"; + gameData.headers.Black = blackEl.value.trim() || "Black"; + updateGameInfo(); + const pgn = ChessPressure.toPgn(gameData.headers, gameData.moves); const slug = (defaultGameName() || "game") .toLowerCase() diff --git a/src/chess_pressure/static/index.html b/src/chess_pressure/static/index.html index 7ee2d2e..bc58541 100644 --- a/src/chess_pressure/static/index.html +++ b/src/chess_pressure/static/index.html @@ -4,7 +4,7 @@ Chess Pressure - + @@ -135,6 +135,18 @@ + +
+

Export PGN

+ + +
+ + +
+
+
+

Please confirm

@@ -164,6 +176,6 @@ - + diff --git a/src/chess_pressure/static/sw.js b/src/chess_pressure/static/sw.js index 15528fb..7c93399 100644 --- a/src/chess_pressure/static/sw.js +++ b/src/chess_pressure/static/sw.js @@ -7,7 +7,7 @@ * * Bump CACHE on every deploy so clients pick up new assets. */ -const CACHE = "chess-pressure-v30"; +const CACHE = "chess-pressure-v31"; // Same-origin app shell. Cached by canonical path; the fetch handler matches // with ignoreSearch so cache-busting query strings (?v=NN) still hit.