From 95cfd9241629f50ff36fb0c4700530cf5b697158 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 17 Jun 2021 16:35:18 +0200 Subject: Add list of public games page at /games. --- views/games.ejs | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 views/games.ejs (limited to 'views') diff --git a/views/games.ejs b/views/games.ejs new file mode 100644 index 0000000..fb58be8 --- /dev/null +++ b/views/games.ejs @@ -0,0 +1,56 @@ +<%- include('header', { title: "All Public Games", refresh: (user ? 300 : 0) }) %> + + +

Open

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

Active

+ + +
IDTitleScenarioDescriptionChangedPlayersActive +<% if (active_games.length > 0) { %> +<% active_games.forEach((row) => { %> +
<%= row.game_id %> +<%= row.title_name %> +<%= row.scenario %> +<%= row.description %> +<%= row.mtime %> +<%= row.players.join(", ") %> +<% + if (row.your_turn) { + %><%= row.active %><% + } 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<% + } +%> +<% }); } else { %> +
No active games. +<% } %> +
+ -- cgit v1.2.3