From dc2c3dbc794b9ffaa848a32436c5be2639de7ca8 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Tue, 26 Feb 2019 16:52:23 -0700 Subject: [PATCH] bugfixes to dev server + helpers.js --- devel/devel-server.py | 6 +----- example-puzzles/example/5/helpers.js | 6 +++++- theme/puzzle.js | 11 +++++++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/devel/devel-server.py b/devel/devel-server.py index 3e837da..0b81552 100755 --- a/devel/devel-server.py +++ b/devel/devel-server.py @@ -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 = """ diff --git a/example-puzzles/example/5/helpers.js b/example-puzzles/example/5/helpers.js index 29ce813..3c566bc 100644 --- a/example-puzzles/example/5/helpers.js +++ b/example-puzzles/example/5/helpers.js @@ -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) { diff --git a/theme/puzzle.js b/theme/puzzle.js index eafda60..e54dfff 100644 --- a/theme/puzzle.js +++ b/theme/puzzle.js @@ -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 = "🙅"