ozai-webui/templates/create.html

126 lines
3.9 KiB
HTML
Raw Normal View History

2024-02-14 21:52:29 +01:00
<!-- HTML -->
<!DOCTYPE html>
<html>
<head>
<title>Ozai:create</title>
<link rel="icon" type="image/png" href="/azul-flake.png">
2024-02-24 21:33:28 +01:00
<style>
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
2024-03-21 23:32:44 +01:00
margin-left: 10vw;
width: 80vw;
background-color: #000;
color: #fff;
color-scheme: dark;
}
div {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex-wrap: wrap; /* Allow the flex items to wrap onto the next line */
width: 100%;
2024-02-24 21:33:28 +01:00
}
form {
2024-03-21 23:32:44 +01:00
margin-top: 20vh;
max-width: 40em;
min-width: 300px;
2024-02-24 21:33:28 +01:00
margin: 0 auto;
}
input[type="text"] {
2024-03-21 23:32:44 +01:00
padding: 1em;
margin-top: 1em;
2024-02-24 21:33:28 +01:00
width: 100%;
box-sizing: border-box;
2024-03-21 23:32:44 +01:00
border: 0.5em solid #000;
border-radius: 1em;
2024-02-24 21:33:28 +01:00
}
input[type="submit"] {
2024-03-21 23:32:44 +01:00
padding: 1em;
margin-top: 3em;
2024-02-24 21:33:28 +01:00
width: 100%;
background-color: #0000FF;
color: #fff;
border: none;
2024-03-21 23:32:44 +01:00
border-radius: 1em;
2024-02-24 21:33:28 +01:00
cursor: pointer;
2024-03-21 23:32:44 +01:00
box-shadow: 0px 0.1em 0.5em rgba(255, 255, 255, 0.333); /* Add some shadow for depth */
transition: background-color 0.3s ease;
2024-02-24 21:33:28 +01:00
}
input[type="submit"]:hover {
background-color: #000099;
}
button {
2024-03-21 23:32:44 +01:00
padding: 1em;
margin-top: 1em;
2024-02-24 21:33:28 +01:00
background-color: #0000FF;
color: #fff;
border: none;
2024-03-21 23:32:44 +01:00
border-radius: 0.5em;
2024-02-24 21:33:28 +01:00
cursor: pointer;
}
button:hover {
background-color: #000099;
}
</style>
2024-02-14 21:52:29 +01:00
</head>
<body>
{% if not game_id %}
2024-03-21 23:32:44 +01:00
<div>
<h1>Create Game</h1>
<h2>Fill in playernames for wanted players</h2>
<h3>Leave empty for no player ...</h3>
</div>
2024-02-14 21:52:29 +01:00
<form method="POST" action="/create">
<input type="text" name="player1" placeholder="Player 1" required>
<input type="text" name="player2" placeholder="Player 2" required>
2024-03-21 23:32:44 +01:00
<input type="text" name="player3" placeholder="Player 3" style="background-color: #2a2929;">
<input type="text" name="player4" placeholder="Player 4" style="background-color: #2a2929;">
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>