ozai-webui/templates/join.html

47 lines
1.5 KiB
HTML

<!-- HTML -->
<!DOCTYPE html>
<html>
<head>
<title>Join Game</title>
</head>
<body>
<!-- a field to add a game id -->
<form id="joinGameForm" method="POST" action="/join" onsubmit="submitForm(event)">
<input type="text" name="game_id" placeholder="Game ID" required value="{{ game_id }}">
<input type="submit" value="Join Game">
</form>
<button onclick="window.history.back();">Back</button>
<!-- script to get from localstorage and prefill join game -->
<script>
function submitForm(e) {
e.preventDefault();
var game_id = document.querySelector('input[name="game_id"]').value;
sessionStorage.setItem('game_id', game_id);
document.getElementById('joinGameForm').submit();
}
var game_id = sessionStorage.getItem('game_id');
if (game_id) {
document.querySelector('input[name="game_id"]').value = game_id;
}
</script>
{% if game_id %}
<script>
var game_id = '{{ game_id }}';
sessionStorage.setItem('game_id', game_id);
//redirect to join game
window.location.href = '/join_game/' + game_id;
</script>
<noscript>
<p>manual redirect</p>
<a href="/join_game/+{{ game_id }}">Go to player selection</a>
</noscript>
{% endif %}
<noscript>
<p>JavaScript is not enabled. Some convenience migth not work.</p>
</noscript>
</body>
</html>