From 327acfe1124cdafc5eb460a039222a160f867ba3 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 17 Nov 2021 13:39:16 +0100 Subject: Simplify URL for playing games. --- views/games.ejs | 44 +++++++++++++++++++-------------- views/info.ejs | 74 +++++++++++++++++++++++++++++++++---------------------- views/join.ejs | 16 +----------- views/profile.ejs | 55 ++++++++++++++++++++++++----------------- 4 files changed, 104 insertions(+), 85 deletions(-) (limited to 'views') diff --git a/views/games.ejs b/views/games.ejs index 3b3f485..86a2502 100644 --- a/views/games.ejs +++ b/views/games.ejs @@ -2,41 +2,49 @@

Open

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

Active

-
IDTitleScenarioPlayersDescriptionChangedActive -<% if (active_games.length > 0) { %> -<% active_games.forEach((row) => { %> +
IDTitleScenarioOptionsPlayersDescriptionChangedActive +<%_ if (active_games.length > 0) { _%> +<%_ active_games.forEach((row) => { _%>
<%= row.game_id %> <%= row.title_name %> <%= row.scenario %> +<%- row.options %> <%- row.player_names %> <%= row.description %> <%= row.mtime %> "><%= row.active %> -<% if (row.is_yours) { %> -Enter -<% } else { %> -View -<% } %> -<% }); } else { %> -
No active games. -<% } %> +<%_ + if (row.is_yours) { + if (row.is_shared) { + %>View<% + } else { + %>View<% + } + } else { + %>View<% + } +_%> +<%_ }); } else { _%> +
No active games. +<%_ } _%>
diff --git a/views/info.ejs b/views/info.ejs index 7c98e21..4a515ff 100644 --- a/views/info.ejs +++ b/views/info.ejs @@ -1,4 +1,4 @@ -<%- include('header', { title: title.title_name, refresh: (user ? 300 : 0) }) %> +<%- include('header', { title: title.title_name, refresh: (user ? 300 : 0) }) _%> <%- include('../public/' + title.title_id + '/about.html') %>

@@ -7,62 +7,78 @@ Read more about the game on

Open Games

-
IDScenarioPlayersDescriptionCreated -<% if (open_games.length > 0) { %> -<% open_games.forEach((row) => { %> +
IDScenarioOptionsPlayersDescriptionCreated +<%_ if (open_games.length > 0) { _%> +<%_ open_games.forEach((row) => { _%>
<%= row.game_id %> -<%= row.scenario %> -<%- row.player_names || `${row.owner_name}` %> +<%= row.scenario %> +<%- row.options %> +<%- row.player_names %> <%= row.description %> <%= row.ctime %> Join -<% }); } else { %> -
No open games. -<% } %> +<%_ }); } else { _%> +
No open games. +<%_ } _%>

Create a new game. -<% if (active_games.length > 0) { %> +<%_ if (active_games.length > 0) { _%>

Active Games

-
IDScenarioPlayersDescriptionChangedTurn -<% active_games.forEach((row) => { %> +
IDScenarioOptionsPlayersDescriptionChangedTurn +<%_ active_games.forEach((row) => { _%>
<%= row.game_id %> <%= row.scenario %> +<%- row.options %> <%- row.player_names %> <%= row.description %> <%= row.mtime %> "><%= row.active %> -<% if (row.is_yours) { %> -Enter -<% } else { %> -View -<% } %> -<% }); %> +<%_ + if (row.is_yours) { + if (row.is_shared) { + %>Play<% + } else { + %>Play<% + } + } else { + %>View<% + + } +_%> +<%_ }); _%>
-<% } %> +<%_ } _%> -<% if (finished_games.length > 0) { %> +<%_ if (finished_games.length > 0) { _%>

Finished Games

-
IDScenarioPlayersDescriptionFinishedResult -<% finished_games.forEach((row) => { %> +
IDScenarioOptionsPlayersDescriptionFinishedResult +<%_ finished_games.forEach((row) => { _%>
<%= row.game_id %> <%= row.scenario %> +<%- row.options %> <%- row.player_names %> <%= row.description %> <%= row.mtime %> <%= row.result %> -<% if (row.is_yours) { %> -Enter -<% } else { %> -View -<% } %> -<% }); %> +<%_ + if (row.is_yours) { + if (row.is_shared) { + %>View<% + } else { + %>View<% + } + } else { + %>View<% + } +_%> +<%_ }); _%>
-<% } %> +<%_ } _%> diff --git a/views/join.ejs b/views/join.ejs index fa33d5c..6558745 100644 --- a/views/join.ejs +++ b/views/join.ejs @@ -1,14 +1,4 @@ <%- include('header', { title: game.title_name }) -%> -<% -function to_english(k) { - if (k === true) return 'yes'; - if (k === false) return 'no'; - return k.replace(/_/g, " ").replace(/^\w/, c => c.toUpperCase()); -} -function format_options(options) { - return Object.entries(options||{}).map(([k,v]) => v === true ? to_english(k) : `${to_english(k)}=${to_english(v)}`).join(", "); -} --%>