Now with variable usernames

This commit is contained in:
Dominic Zimmer
2020-04-17 02:57:46 +02:00
parent f966ee4abc
commit 39301255a8
3 changed files with 20 additions and 3 deletions

12
ui.html
View File

@@ -14,6 +14,9 @@
<br>
<button id="btn_create_session">Create session</button>
<br><br><br>
<input id="set_username" type="text" placeholder="New username" />
<button id="btn_set_username">Set Username</button>
<br><br><br>
<input id="join_session_id" type="text" placeholder="Enter session id" />
<button id="btn_join_session">Join session</button>
@@ -36,6 +39,15 @@
body: JSON.stringify(data),
})
};
document.getElementById("btn_set_username").onclick = async function (e) {
let text = document.getElementById("set_username").value;
let data = {"username": text};
await fetch('api/change_username', {
method: 'POST',
body: JSON.stringify(data),
})
};
</script>
</body>