mirror of https://github.com/dirtbags/moth.git
bugfixes to dev server + helpers.js
This commit is contained in:
parent
041b582935
commit
dc2c3dbc79
|
@ -38,10 +38,6 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
|
|||
super().__init__(request, client_address, server, directory=server.args["theme_dir"])
|
||||
|
||||
|
||||
def get_seed(self):
|
||||
return seed
|
||||
|
||||
|
||||
def get_puzzle(self):
|
||||
category = self.req.get("cat")
|
||||
points = int(self.req.get("points"))
|
||||
|
@ -144,7 +140,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
|
|||
|
||||
|
||||
def handle_index(self):
|
||||
seed = self.get_seed()
|
||||
seed = random.getrandbits(32)
|
||||
body = """<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// jshint asi:true
|
||||
|
||||
function helperUpdateAnswer(event) {
|
||||
let e = event.currentTarget
|
||||
let value = e.value
|
||||
|
@ -26,7 +28,9 @@ function helperUpdateAnswer(event) {
|
|||
value = value.toUpperCase()
|
||||
}
|
||||
|
||||
document.querySelector("#answer").value = value
|
||||
let answer = document.querySelector("#answer")
|
||||
answer.value = value
|
||||
answer.dispatchEvent(new InputEvent("input"))
|
||||
}
|
||||
|
||||
function helperActivate(e) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// jshint asi:true
|
||||
|
||||
// devel_addin drops a bunch of development extensions into element e.
|
||||
// It will only modify stuff inside e.
|
||||
function devel_addin(obj, e) {
|
||||
|
@ -16,6 +18,12 @@ function devel_addin(obj, e) {
|
|||
case "body":
|
||||
continue
|
||||
}
|
||||
let val = obj[key]
|
||||
|
||||
if ((! val) || (val.length === 0)) {
|
||||
// Empty, skip it
|
||||
continue
|
||||
}
|
||||
|
||||
let d = document.createElement("div")
|
||||
e.appendChild(d)
|
||||
|
@ -25,7 +33,6 @@ function devel_addin(obj, e) {
|
|||
d.appendChild(ktxt)
|
||||
ktxt.textContent = key
|
||||
|
||||
let val = obj[key]
|
||||
if (Array.isArray(val)) {
|
||||
let vi = document.createElement("select")
|
||||
d.appendChild(vi)
|
||||
|
@ -182,7 +189,7 @@ function answerCheck(e) {
|
|||
}
|
||||
|
||||
if (possiblyCorrect) {
|
||||
ok.textContent = "🙆"
|
||||
ok.textContent = ""
|
||||
ok.title = "Possibly correct"
|
||||
} else {
|
||||
ok.textContent = "🙅"
|
||||
|
|
Loading…
Reference in New Issue