leadership sprint bugfixes

* Messages now in config.json
* puzzle.html: display errors
This commit is contained in:
Neale Pickett 2023-09-19 16:48:24 -06:00
parent 768600e48e
commit 5350cf73a0
4 changed files with 24 additions and 10 deletions

View File

@ -1,5 +1,6 @@
{ {
"TrackSolved": true, "TrackSolved": true,
"URLInScoreboard": true, "URLInScoreboard": true,
"Messages": "<!-- Messages can go here (HTML) -->",
"__sentry__": "this is here so you don't have to remember to take the comma off the last item" "__sentry__": "this is here so you don't have to remember to take the comma off the last item"
} }

View File

@ -68,6 +68,10 @@ class App {
*/ */
async UpdateConfig() { async UpdateConfig() {
this.config = await common.Config() this.config = await common.Config()
for (let e of document.querySelectorAll(".messages")) {
e.innerHTML = this.config.Messages || ""
}
} }
/** /**
@ -79,9 +83,6 @@ class App {
*/ */
async UpdateState() { async UpdateState() {
this.state = await this.server.GetState() this.state = await this.server.GetState()
for (let e of document.querySelectorAll(".messages")) {
e.innerHTML = this.state.Messages
}
// Update elements with data-track-solved // Update elements with data-track-solved
for (let e of document.querySelectorAll("[data-track-solved]")) { for (let e of document.querySelectorAll("[data-track-solved]")) {
@ -133,7 +134,7 @@ class App {
if (this.state.DevelopmentMode()) { if (this.state.DevelopmentMode()) {
let a = h.appendChild(document.createElement('a')) let a = h.appendChild(document.createElement('a'))
a.classList.add("mothball") a.classList.add("mothball")
a.textContent = "📦" a.textContent = "⬇️"
a.href = this.server.URL(`mothballer/${cat}.mb`) a.href = this.server.URL(`mothballer/${cat}.mb`)
a.title = "Download a compiled puzzle for this category" a.title = "Download a compiled puzzle for this category"
} }

View File

@ -352,7 +352,7 @@ class State {
* @param {Object} obj Raw state data * @param {Object} obj Raw state data
*/ */
constructor(server, obj) { constructor(server, obj) {
for (let key of ["Config", "Messages", "TeamNames", "PointsLog"]) { for (let key of ["Config", "TeamNames", "PointsLog"]) {
if (!obj[key]) { if (!obj[key]) {
throw(`Missing state property: ${key}`) throw(`Missing state property: ${key}`)
} }

View File

@ -142,9 +142,24 @@ async function loadPuzzle(category, points) {
} }
let puzzle = server.GetPuzzle(category, points) let puzzle = server.GetPuzzle(category, points)
console.time("Populate") console.time("Populate")
try {
await puzzle.Populate() await puzzle.Populate()
}
catch {
let error = puzzleElement().appendChild(document.createElement("pre"))
error.classList.add("notification", "error")
error.textContent = puzzle.Error.Body
return
}
finally {
console.timeEnd("Populate") console.timeEnd("Populate")
}
console.info(`Setting base tag to ${contentBase}`)
let baseElement = document.head.appendChild(document.createElement("base"))
baseElement.href = contentBase
console.info("Tweaking HTML...") console.info("Tweaking HTML...")
let title = `${category} ${points}` let title = `${category} ${points}`
@ -183,9 +198,6 @@ async function loadPuzzle(category, points) {
} }
} }
let baseElement = document.head.appendChild(document.createElement("base"))
baseElement.href = contentBase
window.app.puzzle = puzzle window.app.puzzle = puzzle
console.info("window.app.puzzle =", window.app.puzzle) console.info("window.app.puzzle =", window.app.puzzle)