diff options
author | pommicket <pommicket@gmail.com> | 2024-08-14 11:20:22 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2024-08-14 11:20:22 -0400 |
commit | 8664ecfef8df4c1e2103a52d628f2693eefb6f89 (patch) | |
tree | 2f89b89c509a1467c7ca3d73fdd944226b2ade13 /index.js | |
parent | db63e7ada26e2aacbbaa3bf9a44fdafed9032c9e (diff) |
index.html
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -1,5 +1,22 @@ window.addEventListener('load', function () { const getById = (id) => document.getElementById(id); - getById("host").addEventListener("click", async function () { + const customImageRadio = getById("custom-image"); + const customImageURL = getById("image-url"); + function onImageTypeChange() { + customImageURL.disabled = customImageRadio.checked ? '' : 'disabled'; + } + onImageTypeChange(); + for (const radio of document.querySelectorAll('input[name=image]')) { + radio.addEventListener("change", onImageTypeChange); + } + const hostForm = getById("host-form"); + hostForm.addEventListener("submit", function () { + const formData = new FormData(hostForm); + const pieceCount = formData.get('pieces'); + const image = formData.get('image') === 'custom' ? formData.get('image-url') : formData.get('image'); + const search = new URLSearchParams(); + search.set('image', image); + search.set('pieces', pieceCount); + location.href = `game.html?${search}`; }); }); |