{% extends 'minecraft_manager/external/base.html' %}

{% load pretty_print %}

{% block title %}Stats Search{% endblock %}

{% block h1 %}Stats{% endblock %}

{% block method %}GET{% endblock %}

{% block form %}
    <label>Filter: <input id="filter" /></label>
    <br/>
    <label>Stat: <br/>
        <select id="stats" name="stat">
        {% for stat in stats %}
            <option {% if request.GET.stat == stat %}selected{% endif %} value="{{ stat }}">{{ stat|pretty_stat }}</option>
        {% endfor %}
        </select>
    </label>
{% endblock %}

{% block submit %}Search{% endblock %}

{%  block form_bottom %}
    {% if results %}
        <table id="dataTable" class="stripe row-border compact">
            <thead>
                <tr>
                    <th>Rank</th>
                    <th>Username</th>
                    <th>Score</th>
                </tr>
            </thead>
        <tbody>
        {% for result in results %}
            <tr>
                <td>{{ forloop.counter }}</td>
                <td><a href="{% url 'external-stats-player' %}?uuid={{ result.uuid }}">{{ result.username }}</a></td>
                <td>{{ result.score|pretty_score }}</td>
            </tr>
        {% endfor %}
        </tbody>
        </table>
    {% endif %}
{% endblock %}