{% extends "_page.twig" %}

{% block title %}Search host{% endblock %}
{% block content %}
    <div class="container">
        {% if result|length > 0 %}
            <h3 class="title">Query result for "{{ query }}"</h3>
            <div class="disclaimer">
                <span>
                    Note: only first {{ limit }} record(s) are shown
                </span> 
            </div>
            {% if result.error|length > 0 %}
                <div class="disclaimer">
                    <span>
                        <b>{{ result.error }}</b>
                    </span>
                </div>
            {% else %}
                <table class="table">
                    <thead class="table__head">
                        <tr class="table__row">
                            <th class="table__cell">Domain</th>
                            <th class="table__cell"><abbr title="Address Helper">AH</abbr></th>
                            <th class="table__cell"><abbr title="Base32 address">B32</abbr></th>
                            <th class="table__cell table__cell_full-b32">Full Base32</th>
                            <th class="table__cell table__cell_date">Last seen (UTC)</th>
                        </tr>
                    </thead>
                    <tbody class="table__body">
                        {% for host in result %}
                        <tr class="table__row">
                            <td class="table__cell"><a href="http://{{ host.host }}/" rel="external nofollow noopener noreferrer" target="_blank">{{ host.host }}</a></td>
                            <td class="table__cell table__cell_center-bold"><a href="http://{{ host.host }}/?i2paddresshelper={{ host.base64 }}" rel="external nofollow noopener noreferrer" target="_blank">A</a></td>
                            <td class="table__cell table__cell_center-bold"><a href="http://{{ host.base32 }}.b32.i2p/" rel="external nofollow noopener noreferrer" target="_blank">B</a></td>
                            <td class="table__cell table__cell_full-b32 table__cell_long-ass">{{ host.base32 }}</td>
                            <td class="table__cell table__cell_date">{{ host.last_seen != '0000-00-00 00:00:00' ? host.last_seen : 'Never' }}</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            {% endif %}
        {% endif %}

        <p class="important title">
            Search domain
        </p>
        <form action="/search" method="post">
            {% if all %}
            <input type="hidden" name="all" value="true">
            {% endif %}
            <div class="form__field">
                <label for="q">Query:</label>
                <input class="text-input search-page__text-input" type="text" id="q" name="q" maxlength="67" placeholder="domain.i2p" required>
            </div>
            <div class="form__field">
                <label for="q">Alive only:</label>
                <input type="checkbox" id="a" name="a" value="1">
            </div>
            <input type="submit" value="Submit" class="btn search-page__btn">
        </form>
    </div>
{% endblock %}