Initial Commit
This commit is contained in:
commit
ef1c188807
16 files changed
+570
No files matched your search
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>MTG League</title>
|
||||
<style>
|
||||
:root{color-scheme:light dark}
|
||||
body{font-family:system-ui,sans-serif;max-width:900px;margin:1rem auto;padding:0 1rem}
|
||||
table{border-collapse:collapse;width:100%}td,th{border-bottom:1px solid #8884;padding:.3rem;text-align:left}
|
||||
form.i{display:inline}input,select{max-width:100%}
|
||||
</style>
|
||||
<script nonce="<%= nonce %>">document.addEventListener("submit",e=>{const m=e.target.dataset.confirm;if(m&&!confirm(m))e.preventDefault()})</script>
|
||||
<nav><a href="/">Leagues</a> ·
|
||||
<% if (admin) { %><b>admin</b> <form class="i" method="post" action="/logout"><button>Logout</button></form>
|
||||
<% } else { %><a href="/login">Admin login</a><% } %></nav>
|
||||
@@ -0,0 +1,8 @@
|
||||
<%- include('head') %>
|
||||
<h1>MTG Leagues</h1>
|
||||
<ul><% leagues.forEach(l => { %><li><a href="/league/<%= l.id %>"><%= l.name %></a> (best <%= l.best_n %> sessions count)</li><% }) %></ul>
|
||||
<% if (admin) { %>
|
||||
<h2>New league</h2>
|
||||
<form method="post" action="/admin/league"><input name="name" placeholder="Name" required>
|
||||
<input name="best_n" type="number" min="1" value="6"> best sessions count <button>Create</button></form>
|
||||
<% } %>
|
||||
@@ -0,0 +1,11 @@
|
||||
<%- include('head') %>
|
||||
<h1><%= lg.name %></h1>
|
||||
<h2>Leaderboard <small>(best <%= lg.best_n %> sessions)</small></h2>
|
||||
<table><tr><th>#</th><th>Player</th><th>Counted</th><th>All sessions</th><th>Played</th><th>W-D-L</th></tr>
|
||||
<% rows.forEach((r, i) => { %><tr><td><%= i + 1 %></td><td><%= r.name %></td><td><b><%= r.score %></b></td><td><%= r.total %></td>
|
||||
<td><%= r.sessions %></td><td><%= r.rec ? r.rec.join('-') : '–' %></td></tr><% }) %></table>
|
||||
<h2>Sessions</h2>
|
||||
<ul><% sessions.forEach(g => { %><li><a href="/session/<%= g.id %>">Session <%= g.number %> – <%= g.date %></a></li><% }) %></ul>
|
||||
<% if (admin) { %><form method="post" action="/admin/league/<%= lg.id %>/session"><input type="date" name="date" required> <button>New session</button></form><% } %>
|
||||
<h2>Deck performance <small>(match W-D-L)</small></h2>
|
||||
<table><tr><th>Deck</th><th>W-D-L</th></tr><% decks.forEach(([d, r]) => { %><tr><td><%= d %></td><td><%= r.join('-') %></td></tr><% }) %></table>
|
||||
@@ -0,0 +1,3 @@
|
||||
<%- include('head') %>
|
||||
<h1>Admin login</h1><% if (error) { %><p><%= error %></p><% } %>
|
||||
<form method="post"><input type="password" name="password" autofocus> <button>Login</button></form>
|
||||
@@ -0,0 +1,31 @@
|
||||
<%- include('head') %>
|
||||
<h1><%= lg.name %> – Session <%= gs.number %> (<%= gs.date %>)</h1>
|
||||
<p><a href="/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="/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="/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="/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="/admin/session/<%= gs.id %>/delete" data-confirm="Delete this session and its results?"><button>Delete session</button></form>
|
||||
<% } %>
|
||||
Reference in new issue
Block a user