<!-- get nonce -->
<script type="application/javascript">
    document['next_ad_int'] = document['next_ad_int'] || {};
    document['next_ad_int']['security'] = '{{ nonce }}';
</script>

{% set sites = getSites() %}
{% set profileIDs = findAllProfileIds() %}
{% set defaultProfileID = findDefaultProfileId() %}

<h1>{{ i18n.title }}</h1>

<div class="wrap">
    <form method="post">
        <span>{{ i18n.defaultProfile }}</span>
        <span>
            <select name="profile">
                <option value="-1">{{ i18n.noneAssigned }}</option>
                {% for profileID in profileIDs %}
                    {% if profileID == defaultProfileID %}
                        {% set selected = 'selected' %}
                    {% else %}
                        {% set selected = '' %}
                    {% endif %}
                    <option value="{{ profileID }}" {{ selected }}>{{ findProfileName(profileID) }}</option>
                {% endfor %}
            </select>
        </span>

        <button id="assignDefaultProfile" type="submit" class="button adi-button button-primary">{{ i18n.apply
            }}</button>
    </form>
</div>

<div class="wrap">
    <form method="post">
        <div>{{ table.search_box(i18n.search, 'site-list') }}</div>
        <div>{{ table.display() }}</div>
        <div>
            <div>{{ i18n.changeBlogs }}</div>
            <div>
                <select name="profile">
                    <option value="-1">{{ i18n.useDefaultProfile }}</option>
                    {% for profileID in profileIDs %}
                        <option value="{{ profileID }}">{{ findProfileName(profileID) }}</option>
                    {% endfor %}
                </select>

                <button id="assignProfile" type="submit" class="button adi-button button-primary">{{ i18n.apply
                    }}</button>
            </div>
        </div>
    </form>
</div>