diff options
| author | alex <[email protected]> | 2026-11-10 21:04:55 +0100 |
|---|---|---|
| committer | alex <[email protected]> | 2026-11-10 21:04:55 +0100 |
| commit | 51f7f58bbb6bdcfd5df86e6b0756545fa251b524 (patch) | |
| tree | e90458fa9f89352dca4cbfb7f8bf6b400578c0ca /public/app.js | |
| parent | 5bdac896f505b850142682a12e3f5961f775efb7 (diff) | |
| download | wheel-of-names-clone.git-51f7f58bbb6bdcfd5df86e6b0756545fa251b524.tar.xz wheel-of-names-clone.git-51f7f58bbb6bdcfd5df86e6b0756545fa251b524.zip | |
only has the wheel now
Diffstat (limited to 'public/app.js')
| -rw-r--r-- | public/app.js | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/public/app.js b/public/app.js index a757086..9c8e6a8 100644 --- a/public/app.js +++ b/public/app.js @@ -1,9 +1,6 @@ const socket = io(); const wheelEl = document.getElementById("wheel"); -const winnerChip = document.getElementById("winnerChip"); -const exampleCommandsEl = document.getElementById("exampleCommands"); - const ctx = wheelEl.getContext("2d"); const radius = wheelEl.width / 2; const center = { x: radius, y: radius }; @@ -12,7 +9,6 @@ const palette = ["#d95d39", "#f2a541", "#4f6d7a", "#90be6d", "#f28482", "#8d5a97 const appState = { entries: [], - selectedWinner: null, angle: 0, spinning: false, }; @@ -68,23 +64,6 @@ const drawWheel = () => { ctx.restore(); }; -const normalizeAngle = (angle) => { - const full = Math.PI * 2; - return ((angle % full) + full) % full; -}; - -const indexAtPointer = () => { - const count = appState.entries.length; - if (!count) { - return -1; - } - - const slice = (Math.PI * 2) / count; - const pointerAngle = -Math.PI / 2; - const relative = normalizeAngle(pointerAngle - appState.angle); - return Math.floor(relative / slice) % count; -}; - const targetAngleForWinner = (winner) => { const entries = appState.entries; const winnerIndex = entries.indexOf(winner); @@ -130,13 +109,6 @@ const animateSpin = (winner) => { appState.angle = final; drawWheel(); appState.spinning = false; - - const idx = indexAtPointer(); - const landed = idx >= 0 ? appState.entries[idx] : winner; - winnerChip.textContent = `Winner: ${landed}`; - winnerChip.classList.remove("pulse"); - void winnerChip.offsetWidth; - winnerChip.classList.add("pulse"); }; requestAnimationFrame(frame); @@ -144,19 +116,7 @@ const animateSpin = (winner) => { const setState = (next) => { appState.entries = Array.isArray(next.entries) ? next.entries : []; - appState.selectedWinner = next.selectedWinner || null; drawWheel(); - - if (!appState.selectedWinner) { - winnerChip.textContent = "Waiting for spin..."; - } - - const commands = [ - `curl -X POST http://localhost:3000/api/entries \\\n+ -H 'Content-Type: application/json' \\\n+ -d '{"entries":["Alice","Bob","Charlie","Diana"]}'`, - `curl -X POST http://localhost:3000/api/spin \\\n+ -H 'Content-Type: application/json' \\\n+ -d '{"winner":"Charlie"}'`, - ]; - - exampleCommandsEl.textContent = commands.join("\n\n"); }; socket.on("state", setState); |
