webpnp/ui.html
2020-04-17 02:57:46 +02:00

55 lines
1.5 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>leafblade Minecraft Server</title>
<meta charset="UTF-8"/>
</head>
<body>
<span id="greeting"></span><br>
<br>
<span id="current_session">You are not in any session.</span><br>
<div id="all_sessions"></div><br>
<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>
<script src="../static/renderer.js"></script>
<script>
document.getElementById("btn_create_session").onclick = async function (e) {
let data = {};
await fetch('api/create_session', {
method: 'POST',
body: JSON.stringify(data),
})
};
document.getElementById("btn_join_session").onclick = async function (e) {
let text = document.getElementById("join_session_id").value;
let data = {"sessionid": text};
await fetch('api/join_session', {
method: 'POST',
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>
</html>