diff options
| author | akiyamn | 2023-11-02 22:29:09 +1100 |
|---|---|---|
| committer | akiyamn | 2023-11-02 22:29:09 +1100 |
| commit | 5461621c421130bd359efff4a10c3e1ba330e85c (patch) | |
| tree | 32ab149b5993b89c42a46449c23c102858faa3a2 /fe/play.js | |
| download | jacbday-5461621c421130bd359efff4a10c3e1ba330e85c.tar.gz jacbday-5461621c421130bd359efff4a10c3e1ba330e85c.zip | |
Init
Diffstat (limited to 'fe/play.js')
| -rw-r--r-- | fe/play.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/fe/play.js b/fe/play.js new file mode 100644 index 0000000..cc790a7 --- /dev/null +++ b/fe/play.js @@ -0,0 +1,24 @@ +import { API_ROOT } from "./global.js" + +const {team: TEAM, username: USERNAME} = getUserInfo() + +async function increment() { + const response = await fetch(`${API_ROOT}/increment/${TEAM}/${USERNAME}`, {"method": "POST"}) + const {points} = await response.json() + return points +} + +function getUserInfo() { + const urlParams = new URLSearchParams(window.location.search); + return {"team": urlParams.get("team"), "username": urlParams.get("username")} + +} + +async function getUserPoints() { + const response = await fetch(`${API_ROOT}/points/${TEAM}/${USERNAME}`) + const {points} = await response.json() + return points +} + +document.querySelector("#increment").addEventListener("click", increment) +document.querySelector(".username")
\ No newline at end of file |
