{% extends 'config/base.html.j2' %}

{% block config_base %}

{% if is_xhr is not defined %}
<div id="page-wifi" class="config-page">
{% include '_messages.html.j2' %}
{% endif %}
{% if not form or form.active_fields|length == 0 %}
    <div class="message warning">{% trans %}We were unable to detect any wireless cards in your router.{% endtrans %}</div>
{% else %}
    <p>{{ description|safe }}</p>
    <form id="main-form" class="config-form config-form-wifi" action="{{ request.fullpath }}" method="post" autocomplete="off" novalidate>
        <input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}">
        {% include 'config/_wifi_form.html.j2' %}
        <script src="{{ static("js/contrib/jquery-qrcode-0.14.0.min.js") }}"></script>
        <script>
            $(document).ready(function() {
                Foris.initWiFiQR();
            });
        </script>
        <div class="form-buttons">
            <a href="{{ request.fullpath }}" class="button grayed">{% trans %}Discard changes{% endtrans %}</a>
            <button type="submit" name="send" class="button {% if form.band_conflict %}grayed{% endif %}"{% if form.band_conflict %} disabled{% endif %}>{% trans %}Save{% endtrans %}</button>
        </div>
    </form>
{% endif %}
    <br />
    <div id="wifi-reset" class="config-description">
      <form id="wifi-reset-form" class="maintenance-form" method="post" action="{{ url("config_action", page_name="wifi", action="reset") }}">
        <input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}">
        <div class="row">
            <p>{% trans %}If a number of wireless cards doesn't match, you may try to reset the Wi-Fi settings. Note that this will remove the current Wi-Fi configuration and restore the default values.{% endtrans %}</p>
            <button type="submit" name="send" class="button">{% trans %}Reset Wi-Fi settings{% endtrans %}</button>
        </div>
      </form>
    </div>
{% if is_xhr is not defined %}
</div>
{% endif %}

{% endblock %}
