summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorJulien Dessaux2022-11-22 22:55:36 +0100
committerJulien Dessaux2022-11-22 22:55:36 +0100
commit038c877aed55cffdb4401a4c7e7b15b113798145 (patch)
treee2902779e76ba8bd60b63be0e512a3c112530d68 /views
parentAdded basic games handling (diff)
downloadjeux-de-mots-038c877aed55cffdb4401a4c7e7b15b113798145.tar.gz
jeux-de-mots-038c877aed55cffdb4401a4c7e7b15b113798145.tar.bz2
jeux-de-mots-038c877aed55cffdb4401a4c7e7b15b113798145.zip
Implemented game creation
Diffstat (limited to 'views')
-rw-r--r--views/game.ejs6
-rw-r--r--views/games.ejs26
2 files changed, 26 insertions, 6 deletions
diff --git a/views/game.ejs b/views/game.ejs
index e1fab41..7fae405 100644
--- a/views/game.ejs
+++ b/views/game.ejs
@@ -27,10 +27,10 @@
</aside>
</p>
<p>
-<span id="player_1_name">player one name</span>: <span class="player_name" id="player_1_points">0</span><br>
-<span id="player_2_name">player two name</span>: <span class="player_name" id="player_2_points">0</span>
+<span id="player_1_name"><%- data.player1.username %></span>: <span class="player_name" id="player_1_points"><%- data.player1.score %></span><br>
+<span id="player_2_name"><%- data.player2.username %></span>: <span class="player_name" id="player_2_points"><%- data.player2.score %></span>
</p>
<p id="remaining_letters"></p>
-<script>var CWDATA = <%- CWDATA.data %></script>
+<script>var CWDATA = <%- JSON.stringify(data) %></script>
<script type="module" src="/static/index.js"></script>
<%- include("footer") %>
diff --git a/views/games.ejs b/views/games.ejs
index 3189be8..9cee7bb 100644
--- a/views/games.ejs
+++ b/views/games.ejs
@@ -7,11 +7,31 @@
<tr><th>Partie</th><th>Joueur 1</th><th>Joueur 2</th></tr>
<% games.forEach((game) => { %>
<tr>
- <td><a href="/games/<%= game.id %>"><%= game.data.title %></a></td>
- <td><a href="/users/<%= game.player1 %>"><%= game.data.player1.name %></a></td>
- <td><a href="/users/<%= game.player2 %>"><%= game.data.player2.name %></a></td>
+ <td><a href="/games/<%= game.id %>"><%= game.data.name %></a></td>
+ <td><a href="/users/<%= game.player1.id %>"><%= game.data.player1.username %></a></td>
+ <td><a href="/users/<%= game.player2.id %>"><%= game.data.player2.username %></a></td>
</tr>
<% }) %>
</table>
<% } %>
+<% if (Object.keys(errors).length === 0) { %>
+<h2>Nouvelle partie</h2>
+<% } else { %>
+<h2>Oops, erreur lors de la création d'une nouvelle partie!</h2>
+<% } %>
+<form action="/games" method="post">
+ <div class="form-field<%= errors.username ? ' form-field-invalid' : '' %>">
+ <input type="text" placeholder="Identifiant de votre adversaire" name="username" value="<%= formdata.username %>" required autofocus>
+ <% if (errors.username) { %>
+ <label class="error" for="username"><%= errors.username.msg %></label>
+ <% } %>
+ </div>
+ <div class="form-field<%= errors.name ? ' form-field-invalid' : '' %>">
+ <input type="text" placeholder="Nom ou titre de cette partie" name="name" value="<%= formdata.name %>" required>
+ <% if (errors.name) { %>
+ <label class="error" for="name"><%= errors.name.msg %></label>
+ <% } %>
+ </div>
+ <button type="submit">Démarrer</button>
+</form>
<%- include("footer") %>