Skip to content

Commit

Permalink
add amount checker to helpbutton
Browse files Browse the repository at this point in the history
  • Loading branch information
carreb committed Mar 2, 2022
1 parent dd5238f commit 3accd4d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,28 @@ function getHelpOptionsRandom() {
.then(data => data.random)
}

function getHelpOptionsAmount() {
return fetch(HELP_URL + promptRelated.prompt)
.then(response => response.json())
.then(data => data.amount)
}

async function setHelpOptions() {
shortest = await getHelpOptionsShortest()
longest = await getHelpOptionsLongest()
random = await getHelpOptionsRandom()
helpRandom.innerText = "random: " + random
amount = await getHelpOptionsAmount()
helpShortest.innerText = "shortest: " + shortest
helpLongest.innerText = "longest: " + longest
if (amount === 1) {
helpRandom.innerText = "Max1 (H)"
}
else if (amount === 2) {
helpRandom.innerText = "Max2 (H)"
}
else {
helpRandom.innerText = "random: " + random
}
}

helpButton.addEventListener("click", () => {
Expand Down Expand Up @@ -165,6 +180,10 @@ devInput.addEventListener("keydown", function(e){
promptDisplay.innerText = promptRelated.prompt
devInput.value = null
}
else if (devInput.value.includes("refreshprompt")) {
renderPrompt()
devInput.value = null
}
}})


Expand Down

0 comments on commit 3accd4d

Please sign in to comment.