ozai-webui/templates/create.html

112 lines
3.5 KiB
HTML
Raw Normal View History

2024-02-14 21:52:29 +01:00
<!-- HTML -->
<!DOCTYPE html>
<html>
<head>
<title>Create Game</title>
2024-02-24 21:33:28 +01:00
<style>
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-left: 20vw;
width: 60vw;
background: url({{ url_for('static', filename='azul.webp') }}) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
form {
margin-top: 20px;
width: 300px;
margin: 0 auto;
}
input[type="text"] {
padding: 10px;
margin-top: 10px;
width: 100%;
box-sizing: border-box;
border: 2px solid #000;
border-radius: 4px;
}
input[type="submit"] {
padding: 10px;
margin-top: 10px;
width: 100%;
background-color: #0000FF;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #000099;
}
button {
padding: 10px;
margin-top: 10px;
background-color: #0000FF;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #000099;
}
</style>
2024-02-14 21:52:29 +01:00
</head>
<body>
{% if not game_id %}
<form method="POST" action="/create">
<div>Fill inn playernames for wanted players ...</div>
<div>Leave empty for no player ...</div>
<input type="text" name="player1" placeholder="Player 1" required>
<input type="text" name="player2" placeholder="Player 2" required>
2024-02-24 21:33:28 +01:00
<input type="text" name="player3" placeholder="Player 3" style="background-color: #D3D3D3;">
<input type="text" name="player4" placeholder="Player 4" style="background-color: #D3D3D3;">
2024-02-14 21:52:29 +01:00
<!-- Add more input fields for more players -->
<input type="submit" value="Create Game">
</form>
<button onclick="window.history.back();">Back</button>
<script>
// Select all player input elements
var playerInputs = document.querySelectorAll('input[name^="player"]');
// Attach event listener to each input
playerInputs.forEach(function(input) {
input.addEventListener('change', function() {
var currentValue = this.value;
console.log(currentValue);
var isUnique = Array.from(playerInputs).every(function(otherInput) {
return otherInput === input || otherInput.value !== currentValue;
});
if (!isUnique && currentValue !== "") {
alert('Player names must be unique!');
// append a number to the name
this.value = "";
}
});
});
2024-02-24 21:33:28 +01:00
</script>
2024-02-14 21:52:29 +01:00
{% endif %}
{% if game_id %}
<p>Your game ID is: {{ game_id }}</p>
<!-- button to redirect to /join/gameid -->
<a href="/join_game/{{ game_id }}">Join Game</a>
<script>
sessionStorage.setItem('game_id', '{{ game_id }}');
2024-02-24 21:33:28 +01:00
//redirect to join game
window.location.href = '/join_game/{{ game_id }}';
</script>
2024-02-14 21:52:29 +01:00
{% endif %}
</body>
</html>