summaryrefslogtreecommitdiff
path: root/static/script.js
diff options
context:
space:
mode:
authorcyfraeviolae <cyfraeviolae>2022-03-06 11:22:27 -0500
committercyfraeviolae <cyfraeviolae>2022-03-06 11:22:27 -0500
commitbc892ccefef8368289ee082ebd5cc0e75f0bf8cc (patch)
tree472e9d6e2c97a81cd8c4a6c23b37c372d9e635f3 /static/script.js
parent028816bb4970f067fdba339bb0ccec5ed51060d8 (diff)
more poems
Diffstat (limited to 'static/script.js')
-rw-r--r--static/script.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/static/script.js b/static/script.js
index 41d9278..0de93ad 100644
--- a/static/script.js
+++ b/static/script.js
@@ -222,7 +222,8 @@ function winGame(challenge) {
document.getElementById('btns').style = 'display: none;'
document.getElementById('meter').innerText = challenge.meter
var collection = challenge.collection ? `${challenge.collection}, ` : ""
- document.getElementById('ctx').innerHTML = challenge.ctx.replaceAll(/^(.*)/gm, ' $1') + `\n\t<span class="byline">&mdash;<a href="${challenge.link}">${challenge.title}</a>\n\t\t${collection}${challenge.author}</span>`
+ var ctx = challenge.ctx.replace(/^\n/, '').replace(/\n$/, '').replaceAll(/^(.*)/gm, ' $1')
+ document.getElementById('ctx').innerHTML = ctx + `\n\t<span class="byline">&mdash;<a href="${challenge.link}">${challenge.title}</a>\n\t\t${collection}${challenge.author}</span>`
var firstguess = Object.values(guesses[0]).join(' ')
document.getElementById('share').value = `I solved Prosodyle #${getChallengeIdx()+1} at cyfraeviolae.org/prosodyle. My first guess was: "${firstguess}."`
}
@@ -302,7 +303,8 @@ function getDayOfYear() {
}
function getChallengeIdx() {
- return getDayOfYear() - 57
+ var idx = getDayOfYear() - 57
+ return Math.min(idx, challenges.length-1)
}
function getDailyChallenge() {