<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="alternate" type="application/rss+xml" href="atoms/{{ gameuidenc }}.xml" title="Multiplayer FreeOrion slow game turns" />
<link rel="stylesheet" type="text/css" href="static/style.css" />
<title>Welcome to multiplayer FreeOrion slow games!</title>
</head>
<body>
{{> header}}
<div class="content">
<h1>Welcome to FreeOrion slow game {{ gameuid }}!</h1>
<dl>
    <dt>Status:</dt>
    <dd>
    {{#if status}}
        {{#if (eq status "started")}}
            Started
        {{else}}
            Finished
        {{/if}}
    {{else}}
       Prepared
    {{/if}}
    </dd>
    {{#if notes_html}}
    <dt>Notes:</dt>
    <dd>{{ notes_html }}</dd>
    {{/if}}
    {{#if fo_forum_url}}
    <dt>FreeOrion forum URL:</dt>
    <dd><a href="{{ fo_forum_url }}">{{ fo_forum_url }}</a></dd>
    {{/if}}
    <dt>Players:</dt>
    <dd>{{ players }}</dd>
    {{#if min_turn_ts}}
    <dt>Fist turn at:</dt>
    <dd>{{ min_turn_ts }}</dd>
    {{/if}}
    {{#if max_turn_ts }}
    <dt>Last turn at:</dt>
    <dd>{{ max_turn_ts }}</dd>
    {{/if}}
    <dt>Turns:</dt>
    <dd>{{ turns }}</dd>
</dl>
{{#if player_list}}
<table>
    <caption>Players list</caption>
    <thead>
        <tr>
            <th>Player</th>
            {{#if is_teamed}}
            <th>Team</th>
            {{/if}}
            <th>Delegate</th>
        </tr>
    </thead>
    <tbody>
    {{#each player_list as |player|}}
        <tr>
            <td
            {{#if player.player_itself}}
            class="player-itself"
            {{/if}}
            >{{ player.player_name }}</td>
            {{#if ../is_teamed}}
            <td>{{ player.team_id }}</td>
            {{/if}}
            <td
            {{#if player.delegate_itself}}
            class="player-itself"
            {{/if}}
            >
            {{#if player.delegate_name}}
            {{ player.delegate_name }}
                {{#if player.revoke_delegate_data }}
                <br/>
                <form id="revoke-delegate-{{ player.revoke_delegate_data.csrf }}" action="revoke-delegate.do" method="post">
                <fieldset>
                    <input name="csrf" type="hidden" value="{{ player.revoke_delegate_data.csrf }}">
                    <input name="submit" type="submit" value="Revoke Delegate">
                </fieldset>
                </form>   
                {{/if}}
            {{/if}}
            {{#if player.query_delegate_data}}
                <form id="query-delegate-{{ player.query_delegate_data.csrf }}" action="query-delegate.do" method="post">
                <fieldset>
                    <label for="delegate_name">Delegate name:</label>
                    <input name="delegate_name" id="delegate_name-{{ player.query_delegate_data.csrf }}" type="text" placeholder="Username" required />
                    <input name="csrf" type="hidden" value="{{ player.query_delegate_data.csrf }}">
                    <input name="submit" type="submit" value="Query Delegate">
                </fieldset>
                </form>
            {{/if}}
            {{#if pending_delegates}}
            {{#each pending_delegates as |delegate|}}
                <form id="delegate-{{ delegate.csrf }}" action="delegate.do" method="post">
                <fieldset>
                    <label for="submit">{{delegate.name}}</label>
                    <input name="csrf" type="hidden" value="{{ delegate.csrf }}">
                    {{#if delegate.accept}}
                    <input name="submit" type="submit" value="Accept Delegate">
                    {{/if}}
                    <input name="submit" type="submit" value="Reject Delegate">
                </fieldset>
                </form>
            {{/each}}
            {{/if}}
            </td>
        </tr>
    {{/each}}
    </tbody>
</table>
{{/if}}
{{#if join_data}}
<form id="join-game" action="join-game.do" method="post">
<fieldset>
    <input name="csrf" type="hidden" value="{{ join_data.csrf }}">
    <input name="submit" type="submit" value="Join Game">
</fieldset>
</form>
{{/if}}
{{#if leave_data}}
<form id="leave-game" action="leave-game.do" method="post">
<fieldset>
    <input name="csrf" type="hidden" value="{{ leave_data.csrf }}">
    <input name="submit" type="submit" value="Leave Game">
</fieldset>
</form>
{{/if}}
</div>
{{> footer}}
</body>
</html>