diff options
author | cyfraeviolae <cyfraeviolae> | 2022-02-27 01:32:55 -0500 |
---|---|---|
committer | cyfraeviolae <cyfraeviolae> | 2022-02-27 01:32:55 -0500 |
commit | f4f0f93466771dd277a4a847224c6da626f65590 (patch) | |
tree | 7c0ad277cad9d08b7276e1132b2cbaf4225afdee | |
parent | 97b3462ffd3395cb97b39e007332decccd3196ee (diff) |
date
-rw-r--r-- | static/script.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/static/script.js b/static/script.js index caea216..16296a2 100644 --- a/static/script.js +++ b/static/script.js @@ -195,9 +195,8 @@ function winGame(challenge) { document.getElementById('btns').style = 'display: none;' document.getElementById('meter').innerText = challenge.meter document.getElementById('ctx').innerHTML = challenge.ctx.replaceAll(/^(.*)/gm, ' $1') + `\n\t<span class="byline">—<a href="${challenge.link}">${challenge.title}</a>\n\t\t${challenge.collection}, ${challenge.author}</span>` - var date = new Date().toISOString().slice(0, 10) var firstguess = Object.values(guesses[0]).join(' ') - document.getElementById('share').value = `I solved the ${date} Prosodyle at cyfraeviolae.org/prosodyle. My first guess was: "${firstguess}".` + document.getElementById('share').value = `I solved Prosodyle #${getChallengeIdx()+1} at cyfraeviolae.org/prosodyle. My first guess was: "${firstguess}."` } function keyHandler(key) { @@ -248,15 +247,23 @@ document.addEventListener('mousedown', function(e) { } }) -function getDailyChallenge() { - // begin snippet from https://stackoverflow.com/a/8619946 + +// from https://stackoverflow.com/a/8619946 +function getDayOfYear() { var now = new Date(); var start = new Date(now.getFullYear(), 0, 0); var diff = now - start; var oneDay = 1000 * 60 * 60 * 24; var day = Math.floor(diff / oneDay); - // end snippet - return challenges[day-57] + return day; +} + +function getChallengeIdx() { + return getDayOfYear() - 57 +} + +function getDailyChallenge() { + return challenges[getChallengeIdx()] } document.getElementById('copy').addEventListener('click', function(e) { |