diff --git a/public/app.js b/public/app.js index ef804e2..4ef44a9 100644 --- a/public/app.js +++ b/public/app.js @@ -349,16 +349,20 @@ function isGameInProgress() { function refreshGamesLink() { const link = $("games-link"); - if (!link) return; - if (isGameInProgress()) { - link.classList.add("disabled"); - link.title = "finish or abort the current game to open games & stats"; - link.removeAttribute("href"); - } else { - link.classList.remove("disabled"); - link.removeAttribute("title"); - link.setAttribute("href", "/games"); + const abortBtn = $("abort-game"); + const inProgress = isGameInProgress(); + if (link) { + if (inProgress) { + link.classList.add("disabled"); + link.title = "finish or abort the current game to open games & stats"; + link.removeAttribute("href"); + } else { + link.classList.remove("disabled"); + link.removeAttribute("title"); + link.setAttribute("href", "/games"); + } } + if (abortBtn) abortBtn.hidden = !inProgress; } function refreshSetupGate() { @@ -405,6 +409,11 @@ document.addEventListener("click", (e) => { $("new-game").addEventListener("click", () => openSetupDialog()); +$("abort-game").addEventListener("click", async () => { + if (!confirm("Прервать текущую партию?")) return; + await fetch("/api/abort-game", { method: "POST" }); +}); + // Agent change → repopulate models for (const side of ["white", "black"]) { document.querySelector(`[name="${side}-agent"]`).addEventListener("change", () => { diff --git a/public/index.html b/public/index.html index 9e1c0a9..4266c4c 100644 --- a/public/index.html +++ b/public/index.html @@ -23,6 +23,7 @@ games & stats + diff --git a/public/style.css b/public/style.css index 8de4b9f..b5ca4ad 100644 --- a/public/style.css +++ b/public/style.css @@ -162,6 +162,8 @@ button { } button:hover { background: #2e2e36; } #live-btn { background: #3d342a; color: #f0d090; } +#abort-game { background: #3a2222; color: #e09080; border-color: #5a3030; } +#abort-game:hover { background: #4a2a2a; } dialog { background: #15151a; color: #e7e5e4; border: 1px solid #2a2a30;