diff options
Diffstat (limited to 'fe/play.js')
| -rw-r--r-- | fe/play.js | 31 |
1 files changed, 25 insertions, 6 deletions
@@ -1,6 +1,9 @@ import { API_ROOT } from "./global.js" const {team: TEAM, username: USERNAME} = getUserInfo() +const PROMPT_POLL = 30000 + +const element = (e) => document.querySelector(e) async function increment() { const response = await fetch(`${API_ROOT}/increment/${TEAM}/${USERNAME}`, {"method": "POST"}) @@ -14,11 +17,27 @@ function getUserInfo() { } -async function getUserPoints() { - const response = await fetch(`${API_ROOT}/points/${TEAM}/${USERNAME}`) - const {points} = await response.json() - return points +// async function getUserPoints() { +// const response = await fetch(`${API_ROOT}/points/${TEAM}/${USERNAME}`) +// const {points} = await response.json() +// return points +// } + +async function getPrompt() { + const response = await fetch(`${API_ROOT}/prompt/`, { "method": "GET" }) + const { prompt } = await response.json() + return prompt } -document.querySelector("#increment").addEventListener("click", increment) -document.querySelector(".username")
\ No newline at end of file +async function fillPrompt() { + element("button").innerHTML = await getPrompt() +} + +element("#increment").addEventListener("click", increment) + +document.addEventListener("DOMContentLoaded", async () => { + // element(".username").innerHTML = USERNAME + console.log("sdfsdf") + fillPrompt() + const polling = setInterval(fillPrompt, PROMPT_POLL) +}); |
