stub submit event

This commit is contained in:
Neale Pickett 2023-09-08 18:11:36 -06:00
parent 551afe04a5
commit 18c5f044cc
2 changed files with 13 additions and 4 deletions

View File

@ -20,9 +20,7 @@
<ul id="files"></ul> <ul id="files"></ul>
<p>Puzzle by <span id="authors">[loading]</span></p> <p>Puzzle by <span id="authors">[loading]</span></p>
</section> </section>
<form> <form class="answer">
<input type="hidden" name="cat">
<input type="hidden" name="points">
Team ID: <input type="text" name="id"> <br> Team ID: <input type="text" name="id"> <br>
Answer: <input type="text" name="answer" id="answer"> <span id="answer_ok"></span><br> Answer: <input type="text" name="answer" id="answer"> <span id="answer_ok"></span><br>
<input type="submit" value="Submit"> <input type="submit" value="Submit">

View File

@ -1,5 +1,13 @@
import * as moth from "./moth.mjs" import * as moth from "./moth.mjs"
/** Stores the current puzzle, globally */
let puzzle = null
function submit(event) {
event.preventDefault()
console.log(event)
}
function puzzleElement(clear=true) { function puzzleElement(clear=true) {
let e = document.querySelector("#puzzle") let e = document.querySelector("#puzzle")
if (clear) { if (clear) {
@ -16,7 +24,7 @@ function error(message) {
async function loadPuzzle(category, points) { async function loadPuzzle(category, points) {
let server = new moth.Server() let server = new moth.Server()
let puzzle = server.GetPuzzle(category, points) puzzle = server.GetPuzzle(category, points)
await puzzle.Populate() await puzzle.Populate()
let title = `${category} ${points}` let title = `${category} ${points}`
@ -49,6 +57,9 @@ function hashchange() {
} }
function init() { function init() {
for (let e of document.querySelectorAll("form.answer")) {
e.addEventListener("submit", submit)
}
window.addEventListener("hashchange", hashchange) window.addEventListener("hashchange", hashchange)
hashchange() hashchange()
} }