bugfixes to dev server + helpers.js

This commit is contained in:
Neale Pickett 2019-02-26 16:52:23 -07:00
parent 041b582935
commit dc2c3dbc79
3 changed files with 15 additions and 8 deletions

View File

@ -38,10 +38,6 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
super().__init__(request, client_address, server, directory=server.args["theme_dir"]) super().__init__(request, client_address, server, directory=server.args["theme_dir"])
def get_seed(self):
return seed
def get_puzzle(self): def get_puzzle(self):
category = self.req.get("cat") category = self.req.get("cat")
points = int(self.req.get("points")) points = int(self.req.get("points"))
@ -144,7 +140,7 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
def handle_index(self): def handle_index(self):
seed = self.get_seed() seed = random.getrandbits(32)
body = """<!DOCTYPE html> body = """<!DOCTYPE html>
<html> <html>
<head> <head>

View File

@ -1,3 +1,5 @@
// jshint asi:true
function helperUpdateAnswer(event) { function helperUpdateAnswer(event) {
let e = event.currentTarget let e = event.currentTarget
let value = e.value let value = e.value
@ -26,7 +28,9 @@ function helperUpdateAnswer(event) {
value = value.toUpperCase() value = value.toUpperCase()
} }
document.querySelector("#answer").value = value let answer = document.querySelector("#answer")
answer.value = value
answer.dispatchEvent(new InputEvent("input"))
} }
function helperActivate(e) { function helperActivate(e) {

View File

@ -1,3 +1,5 @@
// jshint asi:true
// devel_addin drops a bunch of development extensions into element e. // devel_addin drops a bunch of development extensions into element e.
// It will only modify stuff inside e. // It will only modify stuff inside e.
function devel_addin(obj, e) { function devel_addin(obj, e) {
@ -16,6 +18,12 @@ function devel_addin(obj, e) {
case "body": case "body":
continue continue
} }
let val = obj[key]
if ((! val) || (val.length === 0)) {
// Empty, skip it
continue
}
let d = document.createElement("div") let d = document.createElement("div")
e.appendChild(d) e.appendChild(d)
@ -25,7 +33,6 @@ function devel_addin(obj, e) {
d.appendChild(ktxt) d.appendChild(ktxt)
ktxt.textContent = key ktxt.textContent = key
let val = obj[key]
if (Array.isArray(val)) { if (Array.isArray(val)) {
let vi = document.createElement("select") let vi = document.createElement("select")
d.appendChild(vi) d.appendChild(vi)
@ -182,7 +189,7 @@ function answerCheck(e) {
} }
if (possiblyCorrect) { if (possiblyCorrect) {
ok.textContent = "🙆" ok.textContent = ""
ok.title = "Possibly correct" ok.title = "Possibly correct"
} else { } else {
ok.textContent = "🙅" ok.textContent = "🙅"