Add Connections-style word game with puzzle editor
Express + node:sqlite server, vanilla HTML/JS frontend. Daily puzzle by assigned date, puzzle list, shuffle, one-away hint, shareable emoji results, and a password-protected admin page to create and edit puzzles. Answers are checked server-side and never sent before they are solved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0d3181ec99
commit
4a2309b589
18 changed files with 4286 additions and 0 deletions
31
public/common.js
Normal file
31
public/common.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Small helpers shared by every page.
|
||||
function el(tag, attrs = {}, ...kids) {
|
||||
const n = document.createElement(tag);
|
||||
for (const [k, v] of Object.entries(attrs)) {
|
||||
if (k === 'class') n.className = v;
|
||||
else if (k.startsWith('on')) n.addEventListener(k.slice(2), v);
|
||||
else if (v !== false && v != null) n.setAttribute(k, v === true ? '' : v);
|
||||
}
|
||||
n.append(...kids.flat().filter((k) => k != null));
|
||||
return n;
|
||||
}
|
||||
|
||||
async function api(url, opts = {}) {
|
||||
const res = await fetch(url, {
|
||||
...opts,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: opts.body ? JSON.stringify(opts.body) : undefined,
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
return { ok: res.ok, status: res.status, data };
|
||||
}
|
||||
|
||||
function toast(msg) {
|
||||
document.querySelector('.toast')?.remove();
|
||||
const t = el('div', { class: 'toast', role: 'status' }, msg);
|
||||
document.body.append(t);
|
||||
setTimeout(() => t.remove(), 1800);
|
||||
}
|
||||
|
||||
const fmtDate = (d) =>
|
||||
d ? new Date(d + 'T00:00:00Z').toLocaleDateString(undefined, { timeZone: 'UTC', year: 'numeric', month: 'long', day: 'numeric' }) : '';
|
||||
Loading…
Add table
Add a link
Reference in a new issue