diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-25 21:49:16 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-25 21:49:16 +0100 |
commit | b1e9490f55e4f360c249a107dcc5809a663dec42 (patch) | |
tree | 185894b396f1b844ae8667bd55ea7bc36b1efced /web/pw-frontend/src | |
parent | e681eb91cd8293cefed983e2a877ab99813ae1c5 (diff) | |
download | planetwars.dev-b1e9490f55e4f360c249a107dcc5809a663dec42.tar.xz planetwars.dev-b1e9490f55e4f360c249a107dcc5809a663dec42.zip |
add match meta header to logs
Diffstat (limited to 'web/pw-frontend/src')
-rw-r--r-- | web/pw-frontend/src/lib/MatchBrowser.svelte | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/web/pw-frontend/src/lib/MatchBrowser.svelte b/web/pw-frontend/src/lib/MatchBrowser.svelte index 71fadb2..6885446 100644 --- a/web/pw-frontend/src/lib/MatchBrowser.svelte +++ b/web/pw-frontend/src/lib/MatchBrowser.svelte @@ -1,6 +1,19 @@ <script lang="ts"> import { onMount } from "svelte"; import Visualizer from "./Visualizer.svelte"; + import moment from "moment"; + + const PLAYER_COLORS = [ + "#FF8000", + "#0080FF", + "#FF6693", + "#3FCB55", + "#CBC33F", + "#CF40E9", + "#FF3F0D", + "#1BEEF0", + "#0DC5FF", + ]; let matches = []; let selectedMatch = null; @@ -21,6 +34,19 @@ selectedMatchLog = log; }); } + + function showTimestamp(dateStr: string): string { + let t = moment(dateStr); + if (t.day() == moment().day()) { + return moment(dateStr).format("HH:mm"); + } else { + return moment(dateStr).format("DD/MM"); + } + } + + function playerColor(player_num: number): string { + return PLAYER_COLORS[player_num % PLAYER_COLORS.length]; + } </script> <div class="container"> @@ -33,7 +59,15 @@ class:selected={selectedMatch === match.name} class="match-card" > - {match.name} + <span class="match-timestamp"> {showTimestamp(match.timestamp)}</span> + <span class="match-mapname">{match.map_name}</span> + <ul class="match-player-list"> + {#each match.players as player, ix} + <li class="match-player" style="color: {playerColor(ix)}"> + {player.name} + </li> + {/each} + </ul> </li> {/each} </ul> @@ -86,4 +120,19 @@ .match-card:hover { background-color: #333; } + + .match-timestamp { + color: #ccc; + } + + .match-mapname { + padding: 0 0.5em; + } + + .match-player-list { + list-style: none; + overflow: hidden; + text-overflow: ellipsis; + padding-left: 18px; + } </style> |