126 lines
3.9 KiB
HTML
126 lines
3.9 KiB
HTML
<!-- HTML -->
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Ozai:create</title>
|
|
<link rel="icon" type="image/png" href="/azul-flake.png">
|
|
<style>
|
|
body {
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
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%;
|
|
}
|
|
|
|
form {
|
|
margin-top: 20vh;
|
|
max-width: 40em;
|
|
min-width: 300px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
input[type="text"] {
|
|
padding: 1em;
|
|
margin-top: 1em;
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
border: 0.5em solid #000;
|
|
border-radius: 1em;
|
|
}
|
|
|
|
input[type="submit"] {
|
|
padding: 1em;
|
|
margin-top: 3em;
|
|
width: 100%;
|
|
background-color: #0000FF;
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: 1em;
|
|
cursor: pointer;
|
|
box-shadow: 0px 0.1em 0.5em rgba(255, 255, 255, 0.333); /* Add some shadow for depth */
|
|
transition: background-color 0.3s ease;
|
|
}
|
|
|
|
input[type="submit"]:hover {
|
|
background-color: #000099;
|
|
}
|
|
|
|
button {
|
|
padding: 1em;
|
|
margin-top: 1em;
|
|
background-color: #0000FF;
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: 0.5em;
|
|
cursor: pointer;
|
|
}
|
|
|
|
button:hover {
|
|
background-color: #000099;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
{% if not game_id %}
|
|
<div>
|
|
<h1>Create Game</h1>
|
|
<h2>Fill in playernames for wanted players</h2>
|
|
<h3>Leave empty for no player ...</h3>
|
|
</div>
|
|
<form method="POST" action="/create">
|
|
<input type="text" name="player1" placeholder="Player 1" required>
|
|
<input type="text" name="player2" placeholder="Player 2" required>
|
|
<input type="text" name="player3" placeholder="Player 3" style="background-color: #2a2929;">
|
|
<input type="text" name="player4" placeholder="Player 4" style="background-color: #2a2929;">
|
|
<!-- 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 = "";
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% 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 }}');
|
|
//redirect to join game
|
|
window.location.href = '/join_game/{{ game_id }}';
|
|
</script>
|
|
{% endif %}
|
|
</body>
|
|
</html> |