Files
ozai-webui/src/templates/join_game.html

100 lines
3.0 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Ozai webui: Join Game</title>
<link rel="icon" type="image/png" href="/azul-flake.png">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: black;
color: white;
color-scheme: dark;
}
div {
margin-top: 20vh;
}
div, form {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex-wrap: wrap;
width: 90vw;
}
ul {
list-style-type: none;
padding: 0;
}
li {
margin-bottom: 1em;
}
select, input[type="button"] {
padding: 1em;
margin-top: 1em;
width: 40%;
min-width: 30em;
max-width: 50em;
height: 7vh;
}
input[type="button"] {
background-color: #3779fd;
border: none;
border-radius: 1em;
text-decoration: none;
margin: 6em 1em;
cursor: pointer;
}
</style>
</head>
<body>
<div>
{% if game_id %}
<p>Selected game to join is: <strong>{{ game_id }}</strong></p>
{% endif %}
{% if players %}
<p>Players in game:</p>
<ul>
{% for player in players %}
<li>{{ player }}</li>
{% endfor %}
</ul>
<form id="joinGameForm">
<select name="player" id="playerSelect">
<option value="spectator" selected>Spectator</option>
{% for player in players %}
<option value="{{ player }}">{{ player }}</option>
{% endfor %}
</select>
<p>Game type</p>
<select name="local_game" id="gameTypeSelect" required>
<option value="True" selected>Local</option>
<option value="False">Online</option>
</select>
<input type="button" value="Join Game" onclick="redirectToGame()">
</form>
{% else %}
<p>No players found in game, please recreate the game.</p>
{% endif %}
</div>
<script>
function redirectToGame() {
const player = document.getElementById('playerSelect').value;
const gameType = document.getElementById('gameTypeSelect').value;
const gameId = "{{ game_id }}";
const url = gameType === 'True' ? `/game/${gameId}/player/${player}/local/${gameType}` : `/game/${gameId}/player/${player}`;
sessionStorage.setItem('player_name', player);
sessionStorage.setItem('local_game', gameType);
window.location.href = url;
}
</script>
</body>
</html>