From f8ea2ec67e24643fb60cbe7765abfd292ba6bdf2 Mon Sep 17 00:00:00 2001 From: akiyamn Date: Thu, 9 Nov 2023 00:46:00 +0000 Subject: Add live production day 1 patch --- fe/play.js | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'fe/play.js') diff --git a/fe/play.js b/fe/play.js index cc790a7..a29fc5d 100644 --- a/fe/play.js +++ b/fe/play.js @@ -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) +}); -- cgit v1.2.3