147 lines
5.9 KiB
Django/Jinja
147 lines
5.9 KiB
Django/Jinja
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
{# Simple driver dropdown. Requires list of drivers. #}
|
|
{% macro driver_select(name='', label='') %}
|
|
<div class="form-floating">
|
|
<select name="{{ name }}" class="form-select" aria-label="{{ name }}">
|
|
<option value="" selected disabled hidden></option>
|
|
{% for driver in drivers %}
|
|
<option value="{{ driver.name }}">{{ driver.abbr }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
<label for="{{ name }}" class="text-primary">{{ label }}</label>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{# Driver dropdown where a value might be preselected. Requires list of drivers. #}
|
|
{% macro driver_select_with_preselect(match='', name='', label='') %}
|
|
<div class="form-floating">
|
|
<select name="{{ name }}" class="form-select" aria-label="{{ name }}">
|
|
{# Use namespace wrapper to persist scope between loop iterations #}
|
|
{% set user_has_chosen = namespace(driverpre="false") %}
|
|
|
|
{% for driver in drivers %}
|
|
{% if match == driver.abbr %}
|
|
{% set user_has_chosen.driverpre = "true" %}
|
|
<option selected="selected" value="{{ driver.name }}">{{ driver.abbr }}</option>
|
|
{% else %}
|
|
<option value="{{ driver.name }}">{{ driver.abbr }}</option>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{# Add an empty default if nothing has been chosen #}
|
|
{% if user_has_chosen.driverpre == "false" %}
|
|
<option value="" selected="selected" disabled="disabled" hidden="hidden"></option>
|
|
{% endif %}
|
|
</select>
|
|
<label for="{{ name }}" class="text-primary">{{ label }}</label>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{# Simple team dropdown. Requires list of teams. #}
|
|
{% macro team_select(name='', label='') %}
|
|
<div class="form-floating">
|
|
<select name="{{ name }}" class="form-select" aria-label="{{ name }}">
|
|
<option value="" selected disabled hidden></option>
|
|
{% for team in teams %}
|
|
<option value="{{ team.name }}">{{ team.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
<label for="{{ name }}" class="text-primary">{{ label }}</label>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{# Team dropdown where a value might be preselected. Requires list of teams. #}
|
|
{% macro team_select_with_preselect(match='', name='', label='') %}
|
|
<div class="form-floating">
|
|
<select name="{{ name }}" class="form-select" aria-label="{{ name }}">
|
|
{# Use namespace wrapper to persist scope between loop iterations #}
|
|
{% set user_has_chosen = namespace(teampre="false") %}
|
|
|
|
{% for team in teams %}
|
|
{% if match == team.name %}
|
|
{% set user_has_chosen.teampre = "true" %}
|
|
<option selected="selected" value="{{ team.name }}">{{ team.name }}</option>
|
|
{% else %}
|
|
<option value="{{ team.name }}">{{ team.name }}</option>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{# Add an empty default if nothing has been chosen #}
|
|
{% if user_has_chosen.teampre == "false" %}
|
|
<option value="" selected="selected" disabled="disabled" hidden="hidden"></option>
|
|
{% endif %}
|
|
</select>
|
|
<label for="{{ name }}" class="text-primary">{{ label }}</label>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{# Easy nav-bar entries. When a page sets the active_page variable, the current entry will be underlined #}
|
|
{% macro nav_selector(page='', text='') %}
|
|
<a class="nav-link text-nowrap" href="{{ page }}">{% if active_page == page %}<u>{% endif %} {{ text }}
|
|
{% if active_page == page %}</u>{% endif %}</a>
|
|
{% endmacro %}
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<!-- Title -->
|
|
<title>{% block title %}{% endblock title %}</title>
|
|
<link rel="icon" href="../static/image/favicon.svg" sizes="any" type="image/svg+xml">
|
|
|
|
<!-- Bootstrap -->
|
|
<link href="../static/style/bootstrap.css" rel="stylesheet">
|
|
<script src="../static/script/bootstrap.bundle.js"></script>
|
|
|
|
{% block head_extra %}{% endblock head_extra %}
|
|
|
|
{# <script defer> #}
|
|
{# {# Initialize Bootstrap Tooltips #} #}
|
|
{# console.log("Initializing Tooltips...") #}
|
|
{# const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]') #}
|
|
{# const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)) #}
|
|
{# </script> #}
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<nav class="navbar fixed-top navbar-expand-lg bg-body-tertiary">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="/race">
|
|
<img src="../static/image/f1_logo.svg" alt="Logo" width="120" height="30"
|
|
class="d-inline-block align-text-top">
|
|
Formula 10
|
|
</a>
|
|
|
|
<button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbarCollapse">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
|
|
<div class="collapse navbar-collapse" id="navbarCollapse">
|
|
<div class="navbar-nav me-2">
|
|
{{ nav_selector("/race/" ~ active_user.name | default("Everyone"), "Race Picks") }}
|
|
{{ nav_selector("/season/" ~ active_user.name | default("Everyone"), "Season Picks") }}
|
|
{{ nav_selector("/graphs", "Statistics") }}
|
|
{{ nav_selector("/rules", "Rules") }}
|
|
</div>
|
|
|
|
{% block navbar_center %}{% endblock navbar_center %}
|
|
<div class="flex-grow-1"></div>
|
|
|
|
<div class="navbar-nav">
|
|
{{ nav_selector("/enter", "Enter Race Result") }}
|
|
{{ nav_selector("/users", "Manage Users") }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="px-2 pt-2" style="margin-top: 32px;">
|
|
{% block body %}{% endblock body %}
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html> |