Files
mtg-league/views/session.ejs
T
2026-10-28 14:41:43 +00:00

32 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<%- include('head') %>
<h1><%= lg.name %> – Session <%= gs.number %> (<%= gs.date %>)</h1>
<p><a href="<%= base %>/league/<%= lg.id %>">← Standings</a></p>
<% rounds.forEach(r => { %><h2>Round <%= r.round %></h2><table>
<% r.matches.forEach(m => { %><tr>
<td><%= m.p1 %> <small>(<%= m.p1_deck || '?' %>)</small></td>
<td><% if (m.p2) { %><%= m.p2 %> <small>(<%= m.p2_deck || '?' %>)</small><% } else { %><i>BYE</i><% } %></td>
<td><b><%= m.p1_wins %>–<%= m.p2_wins %><%= m.draws ? '–' + m.draws : '' %></b></td></tr>
<% }) %></table><% }) %>
<% if (!rounds.length && !results.length) { %><p>No results yet.</p><% } %>
<% if (results.length) { %><h2>Standings <small>(imported)</small></h2>
<form method="post" action="<%= base %>/admin/session/<%= gs.id %>/decks">
<table><tr><th>Player</th><th>Points</th><th>W-D-L</th><th>Deck</th></tr>
<% results.forEach(r => { %><tr><td><%= r.name %></td><td><b><%= r.points %></b></td><td><%= r.rec %></td>
<td><% if (admin) { %><input name="deck_<%= r.id %>" value="<%= r.deck || '' %>" list="decks"><% } else { %><%= r.deck || '' %><% } %></td></tr><% }) %></table>
<% if (admin) { %><datalist id="decks"><% known.forEach(k => { %><option value="<%= k %>"><% }) %></datalist><button>Save decks</button><% } %>
</form>
<p><small>If this session also has match rows, those are used for scoring instead.</small></p><% } %>
<% if (admin) { %>
<h2>Import Melee standings export</h2>
<p>Upload the CSV/JSON from Melee's Standings tab (or paste it). Saving replaces this session's imported standings but keeps decks already entered.</p>
<form method="post" enctype="multipart/form-data" action="<%= base %>/admin/session/<%= gs.id %>/import-standings">
<input type="file" name="file" accept=".csv,.json,.txt"><br>
<textarea name="data" rows="5" style="width:100%;font-family:monospace" placeholder="...or paste here"></textarea><br><button>Import standings</button></form>
<h2>Import matches by hand</h2>
<p>One match per line: <code>round, player1, deck1, player2, deck2, p1 wins, p2 wins, draws</code>. Leave player 2 blank for a bye.
Comma- or tab-separated. Saving <b>replaces</b> this session's matches.</p>
<form method="post" action="<%= base %>/admin/session/<%= gs.id %>/import">
<textarea name="data" rows="12" style="width:100%;font-family:monospace"><%= csvtext %></textarea><br><button>Save matches</button></form>
<form method="post" action="<%= base %>/admin/session/<%= gs.id %>/delete" data-confirm="Delete this session and its results?"><button>Delete session</button></form>
<% } %>