A7: player area - play, wallet, movements (WEB-03, WEB-05, WEB-20..27)
Gioca: the round, the player's funds and their bet; the bet is two steps (a confirmation screen that sends nothing, then an explicit confirm) with a fresh idempotency key per screen, and the server re-checks everything. Portafoglio: spendable apart from in-confirmation, deposit address with a QR of the player's own address, copy button, simulated test deposits. Movimenti: the player's own ledger, paged, stacked as cards on a phone. GET /app/stato/ feeds the page and its polling. Every view takes the user from the session only. Checked end to end in a real browser (Playwright): status moves from pending to confirmed without a reload, a double click is one bet. Mutation checks: cross-account leak, non-idempotent POST and unrestricted test-deposit amounts are all caught. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
939c113043
commit
42e5e33371
21 files changed
+1192
-48
No files matched your search
@@ -36,7 +36,30 @@ if (typeof document !== "undefined") {
|
||||
const setText = (name, value) => { const el = field(name); if (el && el.textContent !== String(value)) el.textContent = value; };
|
||||
const setHidden = (name, hidden) => { const el = field(name); if (el) el.hidden = hidden; };
|
||||
|
||||
const me = (name) => document.querySelector(`[data-me="${name}"]`);
|
||||
const setMe = (name, value) => { const el = me(name); if (el && el.textContent !== String(value)) el.textContent = value; };
|
||||
const hideMe = (name, hidden) => { const el = me(name); if (el) el.hidden = hidden; };
|
||||
|
||||
/* The player's own block (play screen only): funds, the bet's status, whether a bet can be placed. */
|
||||
function renderMe(m) {
|
||||
setMe("spendable_text", m.spendable_text);
|
||||
setMe("incoming_text", m.incoming_text);
|
||||
hideMe("incoming-line", !m.incoming_sats);
|
||||
const p = m.participation;
|
||||
hideMe("participation-box", !p);
|
||||
setMe("participation_label", p ? p.label : "");
|
||||
const badge = me("participation_label");
|
||||
if (badge) badge.dataset.status = p ? p.status : "";
|
||||
setMe("participation_message", p ? p.message : "");
|
||||
hideMe("bet-form", !m.can_bet);
|
||||
setMe("bet_blocker", m.bet_blocker);
|
||||
hideMe("bet_blocker", !m.bet_blocker);
|
||||
setMe("last_result", m.last_result);
|
||||
hideMe("last_result", !m.last_result);
|
||||
}
|
||||
|
||||
function render(s) {
|
||||
if (s.me) renderMe(s.me);
|
||||
card.dataset.state = s.state;
|
||||
offsetMs = serverOffsetMs(s.server_now, Date.now());
|
||||
closesAt = s.closes_at || "";
|
||||
|
||||
@@ -87,3 +87,38 @@ input[type=text], input[type=password] { width: 100%; min-height: 2.75rem; paddi
|
||||
.stats dd .hint { font-size: .85rem; font-weight: 400; }
|
||||
.actions { margin: 0; }
|
||||
.button.big { min-height: 3.25rem; padding-inline: 2.2rem; font-size: 1.15rem; }
|
||||
|
||||
/* Player area (WEB-20 .. WEB-27) */
|
||||
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
||||
.nav a[aria-current="page"] { font-weight: 700; border-bottom: 2px solid var(--accent); }
|
||||
.message.info { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
|
||||
.status-box { margin: 0 0 1rem; }
|
||||
.badge { display: inline-block; margin: 0 0 .4rem; padding: .15rem .7rem; border-radius: 999px; font-size: .9rem; font-weight: 600;
|
||||
background: var(--bg); border: 1px solid var(--line); color: var(--text); }
|
||||
.badge[data-status="confirmed"] { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
|
||||
.badge[data-status="pending"] { border-color: var(--accent); color: var(--accent); }
|
||||
.badge[data-status="rejected"], .badge[data-status="excluded"], .badge[data-status="failed"] { background: var(--error-bg); color: var(--error); border-color: var(--error); }
|
||||
.result { font-weight: 600; margin: 1rem 0 0; }
|
||||
select { min-height: 2.75rem; padding: .5rem .75rem; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
|
||||
.copy-row { display: flex; gap: .5rem; align-items: stretch; flex-wrap: wrap; }
|
||||
.address { flex: 1 1 14rem; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
|
||||
input[type=text].address { width: auto; }
|
||||
.qr { display: block; margin: 1rem 0; background: #fff; padding: .5rem; border-radius: 8px; max-width: 100%; height: auto; }
|
||||
.plain { list-style: none; padding: 0; margin: 0; }
|
||||
.table-wrap { overflow-x: auto; }
|
||||
.movements { width: 100%; border-collapse: collapse; background: var(--surface); }
|
||||
.movements th, .movements td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
|
||||
.movements .num { text-align: right; font-variant-numeric: tabular-nums; }
|
||||
.credit { color: var(--ok); } .debit { color: var(--text); }
|
||||
.pager { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; margin-block: 1rem; }
|
||||
.button.secondary.big { margin-left: .5rem; }
|
||||
|
||||
/* On a phone the movements are stacked cards, so the amount is never scrolled out of sight. */
|
||||
@media (max-width: 40rem) {
|
||||
.movements, .movements tbody, .movements tr, .movements td { display: block; width: 100%; }
|
||||
.movements thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
|
||||
.movements tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .8rem; padding: .3rem .8rem; }
|
||||
.movements td { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border: 0; white-space: normal; text-align: right; }
|
||||
.movements td::before { content: attr(data-label); color: var(--muted); font-size: .9rem; text-align: left; }
|
||||
.movements td.num { text-align: right; }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/* The wallet's «Copia» button (WEB-21). Without JavaScript the address is a read-only field the visitor can select
|
||||
and copy; with it, a button appears that copies it and says so. No dependencies, no inline code. */
|
||||
|
||||
function copyText(text, clipboard) {
|
||||
if (clipboard && typeof clipboard.writeText === "function") return clipboard.writeText(text);
|
||||
return Promise.reject(new Error("clipboard unavailable"));
|
||||
}
|
||||
|
||||
if (typeof module !== "undefined") module.exports = { copyText };
|
||||
|
||||
if (typeof document !== "undefined") {
|
||||
document.querySelectorAll("[data-copy-target]").forEach((button) => {
|
||||
const input = document.getElementById(button.dataset.copyTarget);
|
||||
const status = document.querySelector("[data-copy-status]");
|
||||
if (!input) return;
|
||||
button.hidden = false;
|
||||
button.addEventListener("click", async () => {
|
||||
let message = "Indirizzo copiato.";
|
||||
try {
|
||||
await copyText(input.value, navigator.clipboard);
|
||||
} catch (error) {
|
||||
input.select(); // the clipboard is not available here: leave the address selected for the visitor to copy
|
||||
message = "Non riesco a copiare da solo: l'indirizzo è selezionato, copialo a mano.";
|
||||
}
|
||||
if (status) { status.textContent = message; status.hidden = false; }
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user