Make shared replay links a permanent standalone page.
Anyone following ?replay= now gets only the tile and playback controls, without a modal, close button or app chrome behind it. Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -154,4 +154,4 @@ Games newly entering Your turn go to the end of the queue; the ordering survives
154
154
155
155
Replays store the initial position plus two binary bytes per ply, including promotions, separately from permanent result/rating statistics. Saved games have no retention limit and are not automatically deleted based on age. Existing finished tiles can be imported when their original color and complete history are still available. Older rematches whose color was overwritten cannot be reconstructed reliably and are not imported. Data exports include available replay positions. No scheduled worker is required.
156
156
157
The replay footer’s chain icon copies a permanent link with an unguessable token. Anyone with that link can view and play back that one game without signing in. Replay headers identify White and Black with their king icons; transport buttons use previous-track, play/pause and next-track icons with accessible labels. Public replay responses include player names and game positions, not account IDs or private history. Invalid tokens return 404.
157
The replay footer’s chain icon copies a permanent link with an unguessable token. Anyone with that link can view and play back that one game without signing in. Shared links open a standalone replay page containing only the tile and playback/share controls, with no modal, close button or surrounding application interface. Replay headers identify White and Black with their king icons; transport buttons use previous-track, play/pause and next-track icons with accessible labels. Public replay responses include player names and game positions, not account IDs or private history. Invalid tokens return 404.
@@ -154,4 +154,4 @@ Games newly entering Your turn go to the end of the queue; the ordering survives154
154
155
Replays store the initial position plus two binary bytes per ply, including promotions, separately from permanent result/rating statistics. Saved games have no retention limit and are not automatically deleted based on age. Existing finished tiles can be imported when their original color and complete history are still available. Older rematches whose color was overwritten cannot be reconstructed reliably and are not imported. Data exports include available replay positions. No scheduled worker is required.155
Replays store the initial position plus two binary bytes per ply, including promotions, separately from permanent result/rating statistics. Saved games have no retention limit and are not automatically deleted based on age. Existing finished tiles can be imported when their original color and complete history are still available. Older rematches whose color was overwritten cannot be reconstructed reliably and are not imported. Data exports include available replay positions. No scheduled worker is required.156
156
157
The replay footer’s chain icon copies a permanent link with an unguessable token. Anyone with that link can view and play back that one game without signing in. Replay headers identify White and Black with their king icons; transport buttons use previous-track, play/pause and next-track icons with accessible labels. Public replay responses include player names and game positions, not account IDs or private history. Invalid tokens return 404.157
The replay footer’s chain icon copies a permanent link with an unguessable token. Anyone with that link can view and play back that one game without signing in. Shared links open a standalone replay page containing only the tile and playback/share controls, with no modal, close button or surrounding application interface. Replay headers identify White and Black with their king icons; transport buttons use previous-track, play/pause and next-track icons with accessible labels. Public replay responses include player names and game positions, not account IDs or private history. Invalid tokens return 404.@@ -1431,3 +1431,6 @@ dialog.replay-modal { width: min(400px, calc(100vw - 24px)); }
1431
1431
.replay-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
1432
1432
#replay-share { margin-left: auto; font-size: 22px; }
1433
1433
.replay-controls button { font-size: 21px; min-width: 52px; }
1434
1435
body.replay-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 12px; }
1436
#replay-page { width: min(360px, 100%); }
@@ -1431,3 +1431,6 @@ dialog.replay-modal { width: min(400px, calc(100vw - 24px)); }1431
.replay-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }1431
.replay-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }1432
#replay-share { margin-left: auto; font-size: 22px; }1432
#replay-share { margin-left: auto; font-size: 22px; }1433
.replay-controls button { font-size: 21px; min-width: 52px; }1433
.replay-controls button { font-size: 21px; min-width: 52px; }1434
1435
body.replay-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 12px; }1436
#replay-page { width: min(360px, 100%); }@@ -41,12 +41,12 @@ let inviteToken = new URLSearchParams(location.search).get('invite');
41
41
const modal = $('#modal');
42
42
function toast (message) { $('#toast').textContent = message; $('#toast').classList.add('visible'); clearTimeout(toastTimer); toastTimer = setTimeout(() => $('#toast').classList.remove('visible'), 5000); }
43
43
function showModal (html) { delete $('#modal-content').dataset.rivalry; stopReplay(); modal.classList.remove('avatar-picker', 'replay-modal'); $('#modal-content').innerHTML = html; if (!modal.open) modal.showModal(); }
44
function clearReplay () { stopReplay(); if (modal.classList.contains('replay-modal')) { $('#modal-content').innerHTML = ''; modal.classList.remove('replay-modal'); } }
45
function closeModal () { clearReplay(); modal.close(); }
46
$('#modal-close').onclick = closeModal;
47
modal.addEventListener('click', e => { if (e.target === modal) { const r = modal.getBoundingClientRect(); if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) closeModal(); } });
44
function clearReplay () { stopReplay(); if (modal?.classList.contains('replay-modal')) { $('#modal-content').innerHTML = ''; modal.classList.remove('replay-modal'); } }
45
function closeModal () { if (!modal) return; clearReplay(); modal.close(); }
46
if ($('#modal-close')) $('#modal-close').onclick = closeModal;
47
modal?.addEventListener('click', e => { if (e.target === modal) { const r = modal.getBoundingClientRect(); if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) closeModal(); } });
48
48
function dismissInvite () { inviteToken = null; history.replaceState(null, '', location.pathname); }
49
modal.addEventListener('close', () => { if (!modal.open) clearReplay(); if (inviteShown) dismissInvite(); });
49
modal?.addEventListener('close', () => { if (!modal.open) clearReplay(); if (inviteShown) dismissInvite(); });
50
50
const mobileLayout = matchMedia('(max-width: 760px)');
51
51
function showSidebar (open)
52
52
{
@@ -62,7 +62,7 @@ function showSidebar (open)
62
62
}
63
63
mobileLayout.addEventListener('change', () => showSidebar(false));
64
64
if ($('#sidebar')) $('#sidebar').inert = mobileLayout.matches;
65
$('#friends-toggle').onclick = () => showSidebar(!$('#sidebar').classList.contains('open'));
65
if ($('#friends-toggle')) $('#friends-toggle').onclick = () => showSidebar(!$('#sidebar').classList.contains('open'));
66
66
if ($('#friends-close')) $('#friends-close').onclick = () => showSidebar(false);
67
67
if ($('#sidebar-backdrop')) $('#sidebar-backdrop').onclick = () => showSidebar(false);
68
68
document.addEventListener('keydown', e => { if (e.key === 'Escape') { showSidebar(false); selected = null; promotion = null; claimIntended = null; renderGames(); } });
@@ -299,7 +299,7 @@ function renderMatchmaking ()
299
299
async function createLink (kind) { await action({ action: 'create_link', kind }, r => { showModal(`<span class="eyebrow">${kind === 'friend' ? 'GOOD COMPANY' : 'GAME ON'}</span><h2>${kind === 'friend' ? 'Invite a friend.' : 'Send a little challenge.'}</h2><p>Share this link. ${kind === 'friend' ? 'You’ll become friends when the other person clicks accept.' : 'The first person to accept starts a game with you.'} It expires in one month.</p><input aria-label="Invitation link" id="share-url" readonly value="${esc(r.url)}"><div class="actions"><button class="primary" data-modal-action="copy">Copy link ↗</button></div>${kind === 'match' ? '<div id="matchmaking-actions" class="settings-actions"></div>' : ''}`); renderMatchmaking(); }); }
300
300
if ($('#match-link')) $('#match-link').onclick = () => createLink('match');
301
301
if ($('#friend-link')) $('#friend-link').onclick = () => createLink('friend');
302
$('#settings-button').onclick = () => { if (!state) return; showModal(`<h2>Your account</h2><p>Signed in as ${esc(state.user.name)}.</p><p>${state.user.rating} Elo</p><div class="settings-actions">${state.local ? `<button class="secondary" data-modal-action="switch">Switch to ${state.user.name === 'test_user_1' ? 'test_user_2' : 'test_user_1'}</button>` : ''}<a class="button secondary" href="api.php?action=export" download>Export my data (JSON)</a><button class="secondary" data-modal-action="logout">Sign out</button></div>`); };
302
if ($('#settings-button')) $('#settings-button').onclick = () => { if (!state) return; showModal(`<h2>Your account</h2><p>Signed in as ${esc(state.user.name)}.</p><p>${state.user.rating} Elo</p><div class="settings-actions">${state.local ? `<button class="secondary" data-modal-action="switch">Switch to ${state.user.name === 'test_user_1' ? 'test_user_2' : 'test_user_1'}</button>` : ''}<a class="button secondary" href="api.php?action=export" download>Export my data (JSON)</a><button class="secondary" data-modal-action="logout">Sign out</button></div>`); };
303
303
if ($('#rules-button')) $('#rules-button').onclick = () => showModal(`<span class="eyebrow">MICROCHESS</span><h2>Small board. Real chess.</h2><p>The usual rules of chess, on a 4 × 5 board.</p><ul class="rules-list"><li>Each side starts with a king, rook, bishop, knight and one pawn. White moves first.</li><li>Pawns move one square forward, capture diagonally and never move two squares. There is no castling or en passant.</li><li>Reach the last rank to promote to a queen, rook, bishop or knight.</li><li>Protect your king. Checkmate wins; stalemate and dead positions draw.</li><li>Claim a draw after three repetitions or 50 moves by each side without a pawn move or capture. You may also claim with an intended move, via the game menu. Five repetitions or 75 moves draw automatically.</li><li>Click a piece to see legal destinations, then click a dot. Or drag it to a destination.</li><li>The bar below your opponent’s name compares remaining material: White on the left, Black on the right. Pawn 1, knight/bishop 3, rook 5, queen 9; kings are not counted.</li><li>After your move, a blue pulse marks a clear estimated gain; red marks a likely material loss or mating threat. This quick tactical check can miss deeper ideas. Quiet or uncertain moves get no pulse.</li></ul><p class="inline-note">Pieces by Cburnett, from <a href="https://commons.wikimedia.org/wiki/Category:SVG_chess_pieces" target="_blank" rel="noreferrer">Wikimedia Commons</a>, <a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank" rel="noreferrer">CC BY-SA 3.0</a>. Unmodified SVGs.</p>`);
304
304
document.addEventListener('click', e =>
305
305
{
@@ -395,8 +395,9 @@ async function openReplay (id)
395
395
}
396
396
function showReplay (game)
397
397
{
398
showModal('<div id="replay-card"></div><div class="replay-controls"><button class="secondary" data-replay-control="back" aria-label="Previous move" title="Previous move; double-click for beginning">⏮</button><button class="primary" data-replay-control="play" aria-label="Play">▶</button><button class="secondary" data-replay-control="next" aria-label="Next move" title="Next move; double-click for end">⏭</button></div><p id="replay-progress" aria-live="polite"></p><div class="replay-bottom">' + (game.shared ? '<a class="text-button" href="./">Microchess ↗</a>' : '<button class="text-button" id="history-return">← Game history</button>') + '<button class="text-button" id="replay-share" aria-label="Copy game link" title="Copy game link">🔗</button></div>');
399
modal.classList.add('replay-modal');
398
const content = '<div id="replay-card"></div><div class="replay-controls"><button class="secondary" data-replay-control="back" aria-label="Previous move" title="Previous move; double-click for beginning">⏮</button><button class="primary" data-replay-control="play" aria-label="Play">▶</button><button class="secondary" data-replay-control="next" aria-label="Next move" title="Next move; double-click for end">⏭</button></div><p id="replay-progress" aria-live="polite"></p><div class="replay-bottom">' + (game.shared ? '' : '<button class="text-button" id="history-return">← Game history</button>') + '<button class="text-button" id="replay-share" aria-label="Copy game link" title="Copy game link">🔗</button></div>';
399
if (game.shared) { stopReplay(); $('#modal-content').innerHTML = content; }
400
else { showModal(content); modal.classList.add('replay-modal'); }
400
401
replay = { ...game, index: 0 };
401
402
renderReplay();
402
403
}
@@ -471,8 +472,7 @@ function animateSavedGames ()
471
472
472
473
if (new URLSearchParams(location.search).has('replay')) {
473
474
const token = new URLSearchParams(location.search).get('replay');
474
showModal('<h2 id="modal-title">Game replay</h2><p>Loading saved game…</p>');
475
historyFetch('shared_replay&token=' + encodeURIComponent(token)).then(game => { if (modal.open) showReplay(game); }).catch(e => {
476
if (modal.open) showModal(`<h2 id="modal-title">Game unavailable</h2><p>${esc(e.message)}</p>`);
475
historyFetch('shared_replay&token=' + encodeURIComponent(token)).then(showReplay).catch(e => {
476
$('#modal-content').innerHTML = `<h1>Game unavailable</h1><p>${esc(e.message)}</p>`;
477
477
});
478
478
}
@@ -41,12 +41,12 @@ let inviteToken = new URLSearchParams(location.search).get('invite');41
const modal = $('#modal');41
const modal = $('#modal');42
function toast (message) { $('#toast').textContent = message; $('#toast').classList.add('visible'); clearTimeout(toastTimer); toastTimer = setTimeout(() => $('#toast').classList.remove('visible'), 5000); }42
function toast (message) { $('#toast').textContent = message; $('#toast').classList.add('visible'); clearTimeout(toastTimer); toastTimer = setTimeout(() => $('#toast').classList.remove('visible'), 5000); }43
function showModal (html) { delete $('#modal-content').dataset.rivalry; stopReplay(); modal.classList.remove('avatar-picker', 'replay-modal'); $('#modal-content').innerHTML = html; if (!modal.open) modal.showModal(); }43
function showModal (html) { delete $('#modal-content').dataset.rivalry; stopReplay(); modal.classList.remove('avatar-picker', 'replay-modal'); $('#modal-content').innerHTML = html; if (!modal.open) modal.showModal(); }44
function clearReplay () { stopReplay(); if (modal.classList.contains('replay-modal')) { $('#modal-content').innerHTML = ''; modal.classList.remove('replay-modal'); } }44
function clearReplay () { stopReplay(); if (modal?.classList.contains('replay-modal')) { $('#modal-content').innerHTML = ''; modal.classList.remove('replay-modal'); } }45
function closeModal () { clearReplay(); modal.close(); }45
function closeModal () { if (!modal) return; clearReplay(); modal.close(); }46
$('#modal-close').onclick = closeModal;46
if ($('#modal-close')) $('#modal-close').onclick = closeModal;47
modal.addEventListener('click', e => { if (e.target === modal) { const r = modal.getBoundingClientRect(); if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) closeModal(); } });47
modal?.addEventListener('click', e => { if (e.target === modal) { const r = modal.getBoundingClientRect(); if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) closeModal(); } });48
function dismissInvite () { inviteToken = null; history.replaceState(null, '', location.pathname); }48
function dismissInvite () { inviteToken = null; history.replaceState(null, '', location.pathname); }49
modal.addEventListener('close', () => { if (!modal.open) clearReplay(); if (inviteShown) dismissInvite(); });49
modal?.addEventListener('close', () => { if (!modal.open) clearReplay(); if (inviteShown) dismissInvite(); });50
const mobileLayout = matchMedia('(max-width: 760px)');50
const mobileLayout = matchMedia('(max-width: 760px)');51
function showSidebar (open)51
function showSidebar (open)52
{52
{@@ -62,7 +62,7 @@ function showSidebar (open)62
}62
}63
mobileLayout.addEventListener('change', () => showSidebar(false));63
mobileLayout.addEventListener('change', () => showSidebar(false));64
if ($('#sidebar')) $('#sidebar').inert = mobileLayout.matches;64
if ($('#sidebar')) $('#sidebar').inert = mobileLayout.matches;65
$('#friends-toggle').onclick = () => showSidebar(!$('#sidebar').classList.contains('open'));65
if ($('#friends-toggle')) $('#friends-toggle').onclick = () => showSidebar(!$('#sidebar').classList.contains('open'));66
if ($('#friends-close')) $('#friends-close').onclick = () => showSidebar(false);66
if ($('#friends-close')) $('#friends-close').onclick = () => showSidebar(false);67
if ($('#sidebar-backdrop')) $('#sidebar-backdrop').onclick = () => showSidebar(false);67
if ($('#sidebar-backdrop')) $('#sidebar-backdrop').onclick = () => showSidebar(false);68
document.addEventListener('keydown', e => { if (e.key === 'Escape') { showSidebar(false); selected = null; promotion = null; claimIntended = null; renderGames(); } });68
document.addEventListener('keydown', e => { if (e.key === 'Escape') { showSidebar(false); selected = null; promotion = null; claimIntended = null; renderGames(); } });@@ -299,7 +299,7 @@ function renderMatchmaking ()299
async function createLink (kind) { await action({ action: 'create_link', kind }, r => { showModal(`<span class="eyebrow">${kind === 'friend' ? 'GOOD COMPANY' : 'GAME ON'}</span><h2>${kind === 'friend' ? 'Invite a friend.' : 'Send a little challenge.'}</h2><p>Share this link. ${kind === 'friend' ? 'You’ll become friends when the other person clicks accept.' : 'The first person to accept starts a game with you.'} It expires in one month.</p><input aria-label="Invitation link" id="share-url" readonly value="${esc(r.url)}"><div class="actions"><button class="primary" data-modal-action="copy">Copy link ↗</button></div>${kind === 'match' ? '<div id="matchmaking-actions" class="settings-actions"></div>' : ''}`); renderMatchmaking(); }); }299
async function createLink (kind) { await action({ action: 'create_link', kind }, r => { showModal(`<span class="eyebrow">${kind === 'friend' ? 'GOOD COMPANY' : 'GAME ON'}</span><h2>${kind === 'friend' ? 'Invite a friend.' : 'Send a little challenge.'}</h2><p>Share this link. ${kind === 'friend' ? 'You’ll become friends when the other person clicks accept.' : 'The first person to accept starts a game with you.'} It expires in one month.</p><input aria-label="Invitation link" id="share-url" readonly value="${esc(r.url)}"><div class="actions"><button class="primary" data-modal-action="copy">Copy link ↗</button></div>${kind === 'match' ? '<div id="matchmaking-actions" class="settings-actions"></div>' : ''}`); renderMatchmaking(); }); }300
if ($('#match-link')) $('#match-link').onclick = () => createLink('match');300
if ($('#match-link')) $('#match-link').onclick = () => createLink('match');301
if ($('#friend-link')) $('#friend-link').onclick = () => createLink('friend');301
if ($('#friend-link')) $('#friend-link').onclick = () => createLink('friend');302
$('#settings-button').onclick = () => { if (!state) return; showModal(`<h2>Your account</h2><p>Signed in as ${esc(state.user.name)}.</p><p>${state.user.rating} Elo</p><div class="settings-actions">${state.local ? `<button class="secondary" data-modal-action="switch">Switch to ${state.user.name === 'test_user_1' ? 'test_user_2' : 'test_user_1'}</button>` : ''}<a class="button secondary" href="api.php?action=export" download>Export my data (JSON)</a><button class="secondary" data-modal-action="logout">Sign out</button></div>`); };302
if ($('#settings-button')) $('#settings-button').onclick = () => { if (!state) return; showModal(`<h2>Your account</h2><p>Signed in as ${esc(state.user.name)}.</p><p>${state.user.rating} Elo</p><div class="settings-actions">${state.local ? `<button class="secondary" data-modal-action="switch">Switch to ${state.user.name === 'test_user_1' ? 'test_user_2' : 'test_user_1'}</button>` : ''}<a class="button secondary" href="api.php?action=export" download>Export my data (JSON)</a><button class="secondary" data-modal-action="logout">Sign out</button></div>`); };303
if ($('#rules-button')) $('#rules-button').onclick = () => showModal(`<span class="eyebrow">MICROCHESS</span><h2>Small board. Real chess.</h2><p>The usual rules of chess, on a 4 × 5 board.</p><ul class="rules-list"><li>Each side starts with a king, rook, bishop, knight and one pawn. White moves first.</li><li>Pawns move one square forward, capture diagonally and never move two squares. There is no castling or en passant.</li><li>Reach the last rank to promote to a queen, rook, bishop or knight.</li><li>Protect your king. Checkmate wins; stalemate and dead positions draw.</li><li>Claim a draw after three repetitions or 50 moves by each side without a pawn move or capture. You may also claim with an intended move, via the game menu. Five repetitions or 75 moves draw automatically.</li><li>Click a piece to see legal destinations, then click a dot. Or drag it to a destination.</li><li>The bar below your opponent’s name compares remaining material: White on the left, Black on the right. Pawn 1, knight/bishop 3, rook 5, queen 9; kings are not counted.</li><li>After your move, a blue pulse marks a clear estimated gain; red marks a likely material loss or mating threat. This quick tactical check can miss deeper ideas. Quiet or uncertain moves get no pulse.</li></ul><p class="inline-note">Pieces by Cburnett, from <a href="https://commons.wikimedia.org/wiki/Category:SVG_chess_pieces" target="_blank" rel="noreferrer">Wikimedia Commons</a>, <a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank" rel="noreferrer">CC BY-SA 3.0</a>. Unmodified SVGs.</p>`);303
if ($('#rules-button')) $('#rules-button').onclick = () => showModal(`<span class="eyebrow">MICROCHESS</span><h2>Small board. Real chess.</h2><p>The usual rules of chess, on a 4 × 5 board.</p><ul class="rules-list"><li>Each side starts with a king, rook, bishop, knight and one pawn. White moves first.</li><li>Pawns move one square forward, capture diagonally and never move two squares. There is no castling or en passant.</li><li>Reach the last rank to promote to a queen, rook, bishop or knight.</li><li>Protect your king. Checkmate wins; stalemate and dead positions draw.</li><li>Claim a draw after three repetitions or 50 moves by each side without a pawn move or capture. You may also claim with an intended move, via the game menu. Five repetitions or 75 moves draw automatically.</li><li>Click a piece to see legal destinations, then click a dot. Or drag it to a destination.</li><li>The bar below your opponent’s name compares remaining material: White on the left, Black on the right. Pawn 1, knight/bishop 3, rook 5, queen 9; kings are not counted.</li><li>After your move, a blue pulse marks a clear estimated gain; red marks a likely material loss or mating threat. This quick tactical check can miss deeper ideas. Quiet or uncertain moves get no pulse.</li></ul><p class="inline-note">Pieces by Cburnett, from <a href="https://commons.wikimedia.org/wiki/Category:SVG_chess_pieces" target="_blank" rel="noreferrer">Wikimedia Commons</a>, <a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank" rel="noreferrer">CC BY-SA 3.0</a>. Unmodified SVGs.</p>`);304
document.addEventListener('click', e =>304
document.addEventListener('click', e =>305
{305
{@@ -395,8 +395,9 @@ async function openReplay (id)395
}395
}396
function showReplay (game)396
function showReplay (game)397
{397
{398
showModal('<div id="replay-card"></div><div class="replay-controls"><button class="secondary" data-replay-control="back" aria-label="Previous move" title="Previous move; double-click for beginning">⏮</button><button class="primary" data-replay-control="play" aria-label="Play">▶</button><button class="secondary" data-replay-control="next" aria-label="Next move" title="Next move; double-click for end">⏭</button></div><p id="replay-progress" aria-live="polite"></p><div class="replay-bottom">' + (game.shared ? '<a class="text-button" href="./">Microchess ↗</a>' : '<button class="text-button" id="history-return">← Game history</button>') + '<button class="text-button" id="replay-share" aria-label="Copy game link" title="Copy game link">🔗</button></div>');398
const content = '<div id="replay-card"></div><div class="replay-controls"><button class="secondary" data-replay-control="back" aria-label="Previous move" title="Previous move; double-click for beginning">⏮</button><button class="primary" data-replay-control="play" aria-label="Play">▶</button><button class="secondary" data-replay-control="next" aria-label="Next move" title="Next move; double-click for end">⏭</button></div><p id="replay-progress" aria-live="polite"></p><div class="replay-bottom">' + (game.shared ? '' : '<button class="text-button" id="history-return">← Game history</button>') + '<button class="text-button" id="replay-share" aria-label="Copy game link" title="Copy game link">🔗</button></div>';399
modal.classList.add('replay-modal');399
if (game.shared) { stopReplay(); $('#modal-content').innerHTML = content; }400
else { showModal(content); modal.classList.add('replay-modal'); }400
replay = { ...game, index: 0 };401
replay = { ...game, index: 0 };401
renderReplay();402
renderReplay();402
}403
}@@ -471,8 +472,7 @@ function animateSavedGames ()471
472
472
if (new URLSearchParams(location.search).has('replay')) {473
if (new URLSearchParams(location.search).has('replay')) {473
const token = new URLSearchParams(location.search).get('replay');474
const token = new URLSearchParams(location.search).get('replay');474
showModal('<h2 id="modal-title">Game replay</h2><p>Loading saved game…</p>');475
historyFetch('shared_replay&token=' + encodeURIComponent(token)).then(showReplay).catch(e => {475
historyFetch('shared_replay&token=' + encodeURIComponent(token)).then(game => { if (modal.open) showReplay(game); }).catch(e => {476
$('#modal-content').innerHTML = `<h1>Game unavailable</h1><p>${esc(e.message)}</p>`;476
if (modal.open) showModal(`<h2 id="modal-title">Game unavailable</h2><p>${esc(e.message)}</p>`);477
});477
});478
}478
}@@ -12,10 +12,12 @@ $invite=is_string($_GET['invite']??null)&&preg_match('/^[a-f0-9]{48}$/D',$_GET['
12
12
<link rel="icon" href="assets/pieces/nlt.svg" type="image/svg+xml">
13
13
<link rel="stylesheet" href="assets/app.css"><script src="assets/app.js" defer></script>
14
14
</head>
15
<body>
15
<body<?= $sharedReplay?' class="replay-page"':'' ?>>
16
<?php if (!$sharedReplay): ?>
16
17
<header class="topbar"><a class="brand" href="./"><span class="brandmark">m<span>↗</span></span>microchess<span class="brand-dot">.</span></a><span class="tagline">Small board. Big game.</span><div class="account-nav"><button id="settings-button" class="quiet" aria-label="Open account settings">Account</button><button id="friends-toggle" class="mobile-friends" aria-controls="sidebar" aria-expanded="false">Friends <span id="friend-count">0</span></button></div></header>
18
<?php endif ?>
17
19
<?php if ($sharedReplay): ?>
18
<main class="login"><h1>Game replay</h1><p>Watch a game of Microchess.</p><a class="button secondary" href="./">Microchess ↗</a></main>
20
<main id="replay-page" aria-label="Game replay"><div id="modal-content"><p role="status">Loading saved game…</p></div></main>
19
21
<?php elseif (!$logged): ?>
20
22
<main class="login"><span class="eyebrow">A LITTLE CHESS. A LOT OF POSSIBILITIES.</span><h1>Your next move<br>starts here.</h1><p>Five pieces. Twenty squares. Challenge your friends to a game of Microchess, one move at a time.</p><a class="button primary" href="auth.php<?= $invite?'?invite='.htmlspecialchars($invite):'' ?>">Sign in with Tim Falken <span>↗</span></a><small>Sign in to play and accept invitations.</small></main>
21
23
<?php else: ?>
@@ -26,6 +28,8 @@ $invite=is_string($_GET['invite']??null)&&preg_match('/^[a-f0-9]{48}$/D',$_GET['
26
28
<footer><button id="rules-button" class="text-button">How to play ↗</button></footer></main>
27
29
<div id="sidebar-backdrop" hidden></div><aside id="sidebar" aria-label="Friends"><div class="sidebar-heading"><h2>Your people<span class="brand-dot">.</span></h2><button id="friends-close" class="quiet" aria-label="Close friends">✕</button></div><button id="friend-link" class="invite-friend">+ Invite a friend <span>↗</span></button><div class="friends-label">FRIENDS <span id="sidebar-count">0</span></div><div id="friend-list"></div><div id="friend-requests"></div><div class="sidebar-note"><span>♘</span><h3>Better with a rival.</h3><p>Invite a friend, make your move.<br>Come back for the rematch.</p></div><div id="account-summary"></div></aside></div>
28
30
<?php endif ?>
31
<?php if (!$sharedReplay): ?>
29
32
<dialog id="modal" aria-labelledby="modal-title"><button id="modal-close" class="modal-close quiet" aria-label="Close dialog">✕</button><div id="modal-content"></div></dialog>
33
<?php endif ?>
30
34
<div id="toast" role="status" aria-live="polite"></div>
31
35
</body></html>
@@ -12,10 +12,12 @@ $invite=is_string($_GET['invite']??null)&&preg_match('/^[a-f0-9]{48}$/D',$_GET['12
<link rel="icon" href="assets/pieces/nlt.svg" type="image/svg+xml">12
<link rel="icon" href="assets/pieces/nlt.svg" type="image/svg+xml">13
<link rel="stylesheet" href="assets/app.css"><script src="assets/app.js" defer></script>13
<link rel="stylesheet" href="assets/app.css"><script src="assets/app.js" defer></script>14
</head>14
</head>15
<body>15
<body<?= $sharedReplay?' class="replay-page"':'' ?>>16
<?php if (!$sharedReplay): ?>16
<header class="topbar"><a class="brand" href="./"><span class="brandmark">m<span>↗</span></span>microchess<span class="brand-dot">.</span></a><span class="tagline">Small board. Big game.</span><div class="account-nav"><button id="settings-button" class="quiet" aria-label="Open account settings">Account</button><button id="friends-toggle" class="mobile-friends" aria-controls="sidebar" aria-expanded="false">Friends <span id="friend-count">0</span></button></div></header>17
<header class="topbar"><a class="brand" href="./"><span class="brandmark">m<span>↗</span></span>microchess<span class="brand-dot">.</span></a><span class="tagline">Small board. Big game.</span><div class="account-nav"><button id="settings-button" class="quiet" aria-label="Open account settings">Account</button><button id="friends-toggle" class="mobile-friends" aria-controls="sidebar" aria-expanded="false">Friends <span id="friend-count">0</span></button></div></header>18
<?php endif ?>17
<?php if ($sharedReplay): ?>19
<?php if ($sharedReplay): ?>18
<main class="login"><h1>Game replay</h1><p>Watch a game of Microchess.</p><a class="button secondary" href="./">Microchess ↗</a></main>20
<main id="replay-page" aria-label="Game replay"><div id="modal-content"><p role="status">Loading saved game…</p></div></main>19
<?php elseif (!$logged): ?>21
<?php elseif (!$logged): ?>20
<main class="login"><span class="eyebrow">A LITTLE CHESS. A LOT OF POSSIBILITIES.</span><h1>Your next move<br>starts here.</h1><p>Five pieces. Twenty squares. Challenge your friends to a game of Microchess, one move at a time.</p><a class="button primary" href="auth.php<?= $invite?'?invite='.htmlspecialchars($invite):'' ?>">Sign in with Tim Falken <span>↗</span></a><small>Sign in to play and accept invitations.</small></main>22
<main class="login"><span class="eyebrow">A LITTLE CHESS. A LOT OF POSSIBILITIES.</span><h1>Your next move<br>starts here.</h1><p>Five pieces. Twenty squares. Challenge your friends to a game of Microchess, one move at a time.</p><a class="button primary" href="auth.php<?= $invite?'?invite='.htmlspecialchars($invite):'' ?>">Sign in with Tim Falken <span>↗</span></a><small>Sign in to play and accept invitations.</small></main>21
<?php else: ?>23
<?php else: ?>@@ -26,6 +28,8 @@ $invite=is_string($_GET['invite']??null)&&preg_match('/^[a-f0-9]{48}$/D',$_GET['26
<footer><button id="rules-button" class="text-button">How to play ↗</button></footer></main>28
<footer><button id="rules-button" class="text-button">How to play ↗</button></footer></main>27
<div id="sidebar-backdrop" hidden></div><aside id="sidebar" aria-label="Friends"><div class="sidebar-heading"><h2>Your people<span class="brand-dot">.</span></h2><button id="friends-close" class="quiet" aria-label="Close friends">✕</button></div><button id="friend-link" class="invite-friend">+ Invite a friend <span>↗</span></button><div class="friends-label">FRIENDS <span id="sidebar-count">0</span></div><div id="friend-list"></div><div id="friend-requests"></div><div class="sidebar-note"><span>♘</span><h3>Better with a rival.</h3><p>Invite a friend, make your move.<br>Come back for the rematch.</p></div><div id="account-summary"></div></aside></div>29
<div id="sidebar-backdrop" hidden></div><aside id="sidebar" aria-label="Friends"><div class="sidebar-heading"><h2>Your people<span class="brand-dot">.</span></h2><button id="friends-close" class="quiet" aria-label="Close friends">✕</button></div><button id="friend-link" class="invite-friend">+ Invite a friend <span>↗</span></button><div class="friends-label">FRIENDS <span id="sidebar-count">0</span></div><div id="friend-list"></div><div id="friend-requests"></div><div class="sidebar-note"><span>♘</span><h3>Better with a rival.</h3><p>Invite a friend, make your move.<br>Come back for the rematch.</p></div><div id="account-summary"></div></aside></div>28
<?php endif ?>30
<?php endif ?>31
<?php if (!$sharedReplay): ?>29
<dialog id="modal" aria-labelledby="modal-title"><button id="modal-close" class="modal-close quiet" aria-label="Close dialog">✕</button><div id="modal-content"></div></dialog>32
<dialog id="modal" aria-labelledby="modal-title"><button id="modal-close" class="modal-close quiet" aria-label="Close dialog">✕</button><div id="modal-content"></div></dialog>33
<?php endif ?>30
<div id="toast" role="status" aria-live="polite"></div>34
<div id="toast" role="status" aria-live="polite"></div>31
</body></html>35
</body></html>@@ -183,6 +183,17 @@ try{
183
183
await guest.locator('#replay-card .board').waitFor();
184
184
assert.equal(await guest.locator('.replay-players').innerText(),await white.locator('.replay-players').innerText(),'Shared page identifies both players');
185
185
assert.equal(await guest.locator('#history-return').count(),0,'Public replay has no private history navigation');
186
assert.equal(await guest.locator('dialog, #modal-close, .topbar, .login, #sidebar').count(),0,'Standalone replay has no dialog, close button or background UI');
187
await guest.keyboard.press('Escape');
188
await guest.locator('#replay-card .board').waitFor();
189
await guest.locator('body').click({position:{x:4,y:4}});
190
await guest.locator('#replay-card .board').waitFor();
191
await guest.setViewportSize({width:390,height:844});
192
assert(await guest.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),'Standalone replay fits mobile width');
193
await guest.screenshot({path:path.join(web,'tests/artifacts/shared-replay-mobile.png')});
194
await guest.reload();
195
await guest.locator('#replay-card .board').waitFor();
196
186
197
await guest.locator('[data-replay-control="next"]').dblclick();
187
198
assert.match(await guest.locator('#replay-card [data-square="1"] img').getAttribute('src'),/nlt/,'Shared replay plays the same promotion');
188
199
await guestContext.close();
@@ -183,6 +183,17 @@ try{183
await guest.locator('#replay-card .board').waitFor();183
await guest.locator('#replay-card .board').waitFor();184
assert.equal(await guest.locator('.replay-players').innerText(),await white.locator('.replay-players').innerText(),'Shared page identifies both players');184
assert.equal(await guest.locator('.replay-players').innerText(),await white.locator('.replay-players').innerText(),'Shared page identifies both players');185
assert.equal(await guest.locator('#history-return').count(),0,'Public replay has no private history navigation');185
assert.equal(await guest.locator('#history-return').count(),0,'Public replay has no private history navigation');186
assert.equal(await guest.locator('dialog, #modal-close, .topbar, .login, #sidebar').count(),0,'Standalone replay has no dialog, close button or background UI');187
await guest.keyboard.press('Escape');188
await guest.locator('#replay-card .board').waitFor();189
await guest.locator('body').click({position:{x:4,y:4}});190
await guest.locator('#replay-card .board').waitFor();191
await guest.setViewportSize({width:390,height:844});192
assert(await guest.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),'Standalone replay fits mobile width');193
await guest.screenshot({path:path.join(web,'tests/artifacts/shared-replay-mobile.png')});194
await guest.reload();195
await guest.locator('#replay-card .board').waitFor();196
186
await guest.locator('[data-replay-control="next"]').dblclick();197
await guest.locator('[data-replay-control="next"]').dblclick();187
assert.match(await guest.locator('#replay-card [data-square="1"] img').getAttribute('src'),/nlt/,'Shared replay plays the same promotion');198
assert.match(await guest.locator('#replay-card [data-square="1"] img').getAttribute('src'),/nlt/,'Shared replay plays the same promotion');188
await guestContext.close();199
await guestContext.close();