hanabi-league/templates/main.html

272 lines
11 KiB
HTML
Raw Permalink Normal View History

2023-12-03 21:20:13 +01:00
{% extends "layout.html" %}
2023-12-28 23:13:45 +01:00
{% from "stats_table.html" import player_table_js, games_table_js, stats_list %}
2023-12-05 17:39:33 +01:00
{% block navbar %}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">The Hanabi Pro Hunting League<small class="text-muted"> - Season One</small></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link active" id="summary-tab" data-toggle="tab" href="#summary">Summary</a>
</li>
<li class="nav-item">
<a class="nav-link" id="leaderboards-0-tab" data-toggle="tab" href="#leaderboards-0">No Variant</a>
</li>
<li class="nav-item">
<a class="nav-link" id="leaderboards-1-tab" data-toggle="tab" href="#leaderboards-1">Clue Starved</a>
</li>
<li class="nav-item">
<a class="nav-link" id="players-tab" data-toggle="tab" href="#players">Players</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="variants-dropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Variants
</a>
<div class="dropdown-menu" aria-labelledby="variants-dropdown">
<a class="dropdown-item" id="variant-tab" data-toggle="tab" href="#variants">Overview</a>
<div class="dropdown-divider"></div>
{% for variant in unique_variants %}
<a class="dropdown-item" href="/variant/{{variant.variant_id}}">{{variant.name}}</a>
{% endfor %}
</div>
2023-12-05 17:39:33 +01:00
</li>
<li class="nav-item">
<a class="nav-link" id="info-tab" data-toggle="tab" href="#info">Info</a>
</li>
</ul>
</div>
</div>
</nav>
{% endblock %}
2023-12-03 21:20:13 +01:00
{% block content %}
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade active show" id="summary">
2023-12-04 23:49:42 +01:00
<div class="container my-5">
<!-- Leader Cards -->
{% for rating_type, leaders in leaders.items() %}
2023-12-04 23:49:42 +01:00
<div class="card-deck mb-5">
2023-12-26 12:49:39 +01:00
{% for category, leaders in leaders.items() %}
{% for data in leaders %}
2023-12-04 23:49:42 +01:00
<div class="card text-center">
<div class="card-body">
<h5 class="card-title mb-2">{{ data.title }}</h5>
<p class="leaderboard-category">({{data.category}})</p>
2023-12-10 19:51:21 +01:00
<p class="mb-0 player-name">
<a href="/player/{{data.entry.player_name_encoded}}">{{ data.entry.player_name }}</a>
</p>
2023-12-04 23:49:42 +01:00
<p class="mt-1 alt-name">{{ data.entry.user_accounts }}</p>
<p class="score-large">{{ data.entry.score }}</p>
</div>
2023-12-03 21:20:13 +01:00
</div>
2023-12-04 23:49:42 +01:00
{% endfor %}
2023-12-26 12:49:39 +01:00
{% endfor %}
2023-12-03 21:20:13 +01:00
</div>
{% endfor %}
</div>
</div>
2023-12-27 18:39:51 +01:00
<script>
let tabledata = [
{% for game in games %}
{{- game -}},
{% endfor %}
];
</script>
{% for rating_type, leaders in leaders.items() %}
<div class="tab-pane fade" id="leaderboards-{{rating_type}}">
<div class="container my-5">
2023-12-28 23:13:45 +01:00
<h3>Global Statistics</h3>
{{ stats_list(variant_stats[rating_type], False, False, "{3p,4p,5p}x{5s,6s}") }}
2023-12-03 21:20:13 +01:00
<!-- Leaderboards -->
2023-12-27 18:39:51 +01:00
<h3>Leaderboards</h3>
2023-12-04 00:40:29 +01:00
<div id="leaderboards-{{rating_type}}-data" class="accordion">
2023-12-03 21:20:13 +01:00
{% for category, leaderboard in leaderboards.items() %}
<div class="card">
<div class="card-header">
2023-12-22 11:49:26 +01:00
<button class="btn btn-link btn-block text-left" data-toggle="collapse" data-target="#{{ category|lower|replace(' ', '-')|replace('(', '-')|replace(')', '-') }}">
2023-12-03 21:20:13 +01:00
{{ category }}
</button>
</div>
2023-12-22 11:49:26 +01:00
<div id="{{ category|lower|replace(' ', '-')|replace('(', '-')|replace(')', '-') }}" class="collapse" data-parent="#leaderboards-{{rating_type}}-data">
2023-12-03 21:20:13 +01:00
<div class="card-body">
<table class="table table-striped">
{% for entry in leaderboard[rating_type] %}
2023-12-03 21:20:13 +01:00
<tr>
<td>
2023-12-10 19:51:21 +01:00
<div class="player-name">
<a href="/player/{{entry.player_name_encoded}}">{{ entry.player_name }}</a>
</div>
<div class="alt-name">{{ entry.user_accounts }}</div>
2023-12-03 21:20:13 +01:00
</td>
<td class="score">{{ entry.score }}</td>
{% if entry.current_streak is defined %}
<td class="current-streak">({{ entry.current_streak }})</td>
{% endif %}
2023-12-03 21:20:13 +01:00
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
{% endfor %}
</div>
2023-12-27 18:39:51 +01:00
<br>
<!-- List of games -->
<h3>List of played games</h3>
<div id="table-{{rating_type}}"></div>
<br>
2024-01-10 20:16:23 +01:00
<h3>Variant ELO progression</h3>
2023-12-30 00:41:57 +01:00
<canvas id="chart-{{rating_type}}"></canvas>
2024-01-10 20:16:23 +01:00
<h3>Player ELO progression</h3>
<canvas id="chart-players-{{rating_type}}"></canvas>
2023-12-03 21:20:13 +01:00
</div>
</div>
2023-12-04 00:40:29 +01:00
{% endfor %}
2023-12-04 11:11:02 +01:00
2023-12-27 18:39:51 +01:00
<div class="tab-pane fade" id="players">
<div class="container my-5">
<div id="table-players"></div>
</div>
</div>
<script>
let player_tabledata = [
{% for player_row in players %}
{{- player_row -}},
{% endfor %}
];
{{ player_table_js("player_tabledata", "players") }}
</script>
2023-12-04 11:11:02 +01:00
<!-- Variants -->
<div class="tab-pane fade" id="variants">
<div class="container my-5">
<table class="table table-hover table-striped">
<thead>
<tr>
<th scope="col" class="text-center">Variant</th>
<th scope="col" class="text-center">Player count</th>
<th scope="col" class="text-center">Rating</th>
<th scope="col" class="text-center">Games Played</th>
<th scope="col" class="text-center">Max Scores</th>
</tr>
</thead>
<tbody>
{% for variant in variants_with_player_nums %}
2023-12-04 11:11:02 +01:00
<tr>
2023-12-10 12:04:31 +01:00
<td class="text-center"><strong><a href="/variant/{{variant.variant_id}}">{{ variant.name }}</a></strong></td>
2023-12-04 11:11:02 +01:00
<td class="text-center">{{ variant.num_players }}</td>
2023-12-04 17:52:18 +01:00
<td class="text-center variant-rating">{{ variant.stats.rating | int }}</td>
<td class="text-center">{{ variant.stats.games_played }}</td>
<td class="text-center">{{ variant.stats.games_won }}</td>
2023-12-04 11:11:02 +01:00
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
2023-12-04 11:16:34 +01:00
<div class="tab-pane fade" id="info">
<div class="container my-5">
2023-12-08 22:37:25 +01:00
{% include "info.html" %}
2023-12-04 11:16:34 +01:00
</div>
</div>
2023-12-04 11:11:02 +01:00
2023-12-03 21:20:13 +01:00
</div>
2023-12-27 18:39:51 +01:00
<script>
{% for rating_type in leaders %}
{{ games_table_js("tabledata", rating_type, True, False, False, "Players") }}
2023-12-27 18:39:51 +01:00
table_{{rating_type}}.setFilter("rating_type", "=", {{rating_type}});
{% endfor %}
</script>
2023-12-30 00:41:57 +01:00
<!-- Tables for rating progression-->
<script>
let chart_data = {{ variant_ratings }};
{% for rating_type, r_data in variant_ratings.items() %}
let datasets_{{rating_type}} = [];
{% for name, n_data in r_data.items() %}
{% for num_players, data in n_data.items() %}
datasets_{{rating_type}}.push({
data: chart_data[{{rating_type}}]["{{name}}"][{{num_players}}],
label: "{{name}} - {{num_players}} players"
});
{% endfor %}
{% endfor %}
const config_{{rating_type}} = {
type: 'line',
data: {
datasets: datasets_{{rating_type}}
},
options: {
parsing: {
xAxisKey: "rank",
yAxisKey: "rating"
2023-12-30 00:41:57 +01:00
},
scales: {
x: {
type: 'linear',
text: 'Number of games'
2023-12-30 00:41:57 +01:00
}
}
}
};
const ctx_{{rating_type}} = document.getElementById('chart-{{rating_type}}');
new Chart(ctx_{{rating_type}}, config_{{rating_type}});
{% endfor %}
2024-01-10 20:16:23 +01:00
{% for rating_type, rating_map in player_ratings.items() %}
let datasets_players_{{rating_type}} = [];
{% for player_name, data in rating_map.items() %}
datasets_players_{{rating_type}}.push({
data: {{ data }},
label: "{{player_name}}"
});
{% endfor %}
const config_players_{{rating_type}} = {
type: 'line',
data: {
datasets: datasets_players_{{rating_type}}
},
options: {
parsing: {
xAxisKey: "rank",
yAxisKey: "rating"
},
scales: {
x: {
type: 'linear',
text: 'Number of games'
}
}
}
}
const ctx_players_{{rating_type}} = document.getElementById('chart-players-{{rating_type}}');
new Chart(ctx_players_{{rating_type}}, config_players_{{rating_type}});
{% endfor %}
2023-12-30 00:41:57 +01:00
</script>
2023-12-05 17:39:33 +01:00
{% endblock %}