TER/ter/templates/station.html
2023-11-09 08:31:41 +01:00

44 lines
1.2 KiB
HTML

{% extends "/_base.html" %}
{% block content %}
<section id="content">
{% if name is not defined %}
<input
type="text"
placeholder="Sélectionner une gare"
autocomplete="off"
name="search" value="{{ search|default('') }}"
hx-get="/station",
hx-trigger="keyup changed delay:500ms, load"
hx-target="#search-results"
hx-swap="outerHTML"
hx-indicator=".htmx-indicator"
/>
<img id="spinner" class="htmx-indicator" src="/static/img/bars.svg"/>
{% block search_results %}
{% if search_results %}
<ul id="search-results">
{% for (name,) in search_results %}
<li><a
hx-get="/station"
hx-vals='{"name": "{{ name }}"}'
hx-trigger="click"
hx-target="#content"
hx-swap="outerHTML"
hx-push-url="true">{{ name }}</a></li>
{% endfor %}
</ul>
{% elif search | length < 3 %}
<p id="search-results"><i>Il faut au moins 3 caractères</i></p>
{% else %}
<p id="search-results"><b>Pas de résultats</b></p>
{% endif %}
{% endblock %}
{% else %}
<h1>Gare de {{ name }}</h1>
<p>Lat. {{ location[0] }} Long. {{ location[1] }}</p>
{% endif %}
</section>
{% endblock %}