summaryrefslogtreecommitdiff
path: root/views/join.ejs
blob: b9cf824a10443b98f5fdf311458ba072207adb9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<%- 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(", ");
}
-%>
<style>
th, td { min-width: 10em; font-size: 16px; }
a.red { text-decoration: none; color: brown; font-size: 15px; }
.hide { display: none; }
</style>
<script>
let game = <%- JSON.stringify(game) %>;
let roles = <%- JSON.stringify(roles) %>;
let players = <%- JSON.stringify(players) %>;
let user_id = <%- user.user_id %>;
let ready = <%- ready %>;
</script>
<script src="/join.js"></script>
<p id="error" class="error"></p>

<a href="/info/<%= game.title_id %>"><img class="logo" src="/<%= game.title_id %>/cover.jpg"></a>

<div class="info">
<p>
Owner: <%= game.owner_name %>
<br>
Private: <%= game.private ? "yes" : "no" %>
<br>
Scenario: <%= game.scenario %>
<br>
Options: <%- format_options(JSON.parse(game.options)) %>
<br>
Description: <%= game.description || "No description." %>
<br>
Status: <span id="game_status"></span>
<br>
Result: <span id="game_result"></span>

<br clear=left>

<table>
<tr>
<% roles.forEach((role) => { %><th id="role_<%= role.replace(/ /g, '_') %>_name"><%= role %></th><% }); %>
<tr>
<% roles.forEach((role) => { %><td id="role_<%= role.replace(/ /g, '_') %>">-</td><% }); %>
<tr>
<td id="message" colspan="<%= roles.length %>">-</td>
</table>

<p>
<button class="hide" id="delete_button" onclick="confirm_delete()">Delete</button>
<button class="hide" id="start_button" onclick="javascript:send('/start/<%= game.game_id %>')" disabled>Start!</button>