summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2024-08-14 11:20:22 -0400
committerpommicket <pommicket@gmail.com>2024-08-14 11:20:22 -0400
commit8664ecfef8df4c1e2103a52d628f2693eefb6f89 (patch)
tree2f89b89c509a1467c7ca3d73fdd944226b2ade13 /index.js
parentdb63e7ada26e2aacbbaa3bf9a44fdafed9032c9e (diff)
index.html
Diffstat (limited to 'index.js')
-rw-r--r--index.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/index.js b/index.js
index 4a7fbd3..7ad57f0 100644
--- a/index.js
+++ b/index.js
@@ -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}`;
});
});