blob: 4ef46abda6d67fdbc1c5a5c10a1124b903ceb6e5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import startGame from "./startGame.js";
let html = /* html */ `
<div class="container text-center fs-1" style="margin-top: 45vh;">
<label for="username">Vad heter du?</label>
<input type="text" name="username" required>
<button type="button" class="btn btn-light btn-lg" onclick="login">Starta spelet</button>
</div>
`;
async function login() {
let username = document.getElementsByTagName("input")[0].innerHTML,
res = await fetch("/login", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify({ username: username })
});
res = await res.json();
startGame(res);
}
document.body.innerHTML = html;
document.getElementsByTagName("button")[0].onclick = login;
|