From 401a13ff9e7792f0e060ccfb15afdbd3bc5fc557 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 28 Jun 2021 12:38:42 +0200 Subject: Clean up SQL and use table views. --- views/games.ejs | 28 ++++++++++------------------ views/info.ejs | 23 ++++++++--------------- views/join.ejs | 1 - views/login.ejs | 2 +- views/profile.ejs | 18 +++++++++--------- 5 files changed, 28 insertions(+), 44 deletions(-) (limited to 'views') diff --git a/views/games.ejs b/views/games.ejs index fb58be8..4e6f2a4 100644 --- a/views/games.ejs +++ b/views/games.ejs @@ -5,52 +5,44 @@ td.nowrap a { color: black; text-decoration: none; }

Open

-
IDTitleScenarioOwnerDescriptionCreatedPlayers +
IDTitleScenarioPlayersDescriptionCreated <% if (open_games.length > 0) { %> <% open_games.forEach((row) => { %>
<%= row.game_id %> <%= row.title_name %> <%= row.scenario %> -<%= row.owner_name %> +<%= row.player_names || row.owner_name %> <%= row.description %> <%= row.ctime %> -<%= row.players.join(", ") %> Join <% }); } else { %> -
No open games. +
No open games. <% } %>

Active

-
IDTitleScenarioDescriptionChangedPlayersActive +
IDTitleScenarioPlayersDescriptionChangedActive <% if (active_games.length > 0) { %> <% active_games.forEach((row) => { %>
<%= row.game_id %> <%= row.title_name %> <%= row.scenario %> +<%= row.player_names %> <%= row.description %> <%= row.mtime %> -<%= row.players.join(", ") %> <% - if (row.your_turn) { - %><%= row.active %><% + if (row.is_your_turn) { + %><%= row.active_role %><% } else { - %><%= row.active %><% - } - let me = row.players.reduce((n,p) => n + (p === user.name ? 1 : 0), 0); - if (me == 1) { - %>Play<% - } else if (me > 1) { - %>Play<% - } else { - %>View<% + %><%= row.active_role %><% } + %>Enter<% %> <% }); } else { %> -
No active games. +
No active games. <% } %>
diff --git a/views/info.ejs b/views/info.ejs index 55b8faa..02ce2dd 100644 --- a/views/info.ejs +++ b/views/info.ejs @@ -9,13 +9,13 @@ Read more about the game on

Open Games

-
IDScenarioOwnerDescriptionCreated +
IDScenarioPlayersDescriptionCreated <% if (open_games.length > 0) { %> <% open_games.forEach((row) => { %>
<%= row.game_id %> <%= row.scenario %> -<%= row.owner_name %> +<%= row.player_names || row.owner_name %> <%= row.description %> <%= row.ctime %> Join @@ -35,23 +35,16 @@ Read more about the game on
<%= row.game_id %> <%= row.scenario %> -<%= row.players.join(", ") %> +<%= row.player_names %> <%= row.description %> <%= row.mtime %> <% - if (row.your_turn) { - %><%= row.active %><% + if (row.is_your_turn) { + %><%= row.active_role %><% } else { - %><%= row.active %><% - } - let me = row.players.reduce((n,p) => n + (p === user.name ? 1 : 0), 0); - if (me == 1) { - %>Play<% - } else if (me > 1) { - %>Play<% - } else { - %>View<% + %><%= row.active_role %><% } + %>Enter<% %> <% }); %>
@@ -65,7 +58,7 @@ Read more about the game on <%= row.game_id %> <%= row.scenario %> -<%= row.players.join(", ") %> +<%= row.player_names %> <%= row.description %> <%= row.mtime %> <%= row.result %> diff --git a/views/join.ejs b/views/join.ejs index 46c1e56..1d9347d 100644 --- a/views/join.ejs +++ b/views/join.ejs @@ -9,7 +9,6 @@ let game = <%- JSON.stringify(game) %>; let roles = <%- JSON.stringify(roles) %>; let players = <%- JSON.stringify(players) %>; let user_id = <%- user.user_id %>; -let solo = <%- solo %>; let ready = <%- ready %>; diff --git a/views/login.ejs b/views/login.ejs index b4089fc..3e1dd43 100644 --- a/views/login.ejs +++ b/views/login.ejs @@ -4,7 +4,7 @@ <% } else { %>

-
+


diff --git a/views/profile.ejs b/views/profile.ejs index 02f6e72..7829870 100644 --- a/views/profile.ejs +++ b/views/profile.ejs @@ -36,7 +36,7 @@ Your mail address is <%= user.mail %>. <%= row.game_id %> <%= row.title_name %> <%= row.scenario %> -<%= row.players.join(", ") %> +<%= row.player_names %> <%= row.description %> <%= row.ctime %> Join @@ -53,19 +53,19 @@ Your mail address is <%= user.mail %>. <%= row.game_id %> <%= row.title_name %> <%= row.scenario %> -<%= row.players.join(", ") %> +<%= row.player_names %> <%= row.description %> <%= row.mtime %> <% - if (row.your_turn) { - %><%= row.active %><% + if (row.is_your_turn) { + %><%= row.active_role %><% } else { - %><%= row.active %><% + %><%= row.active_role %><% } - if (row.players.reduce((n,p) => n + (p === user.name ? 1 : 0), 0) == 1) { - %>Play<% + if (row.is_shared) { + %>Enter<% } else { - %>Play<% + %>Play<% } %> <% }); %> @@ -81,7 +81,7 @@ Your mail address is <%= user.mail %>. <%= row.game_id %> <%= row.title_name %> <%= row.scenario %> -<%= row.players.join(", ") %> +<%= row.player_names %> <%= row.description %> <%= row.mtime %> <%= row.result %> -- cgit v1.2.3