{% extends "two-column-content.html" %}
{% set page_type = 'moss' %}

{% block left_sidebar %}
  {% include "contest/contest-tabs.html" %}
{% endblock %}

{% block two_col_media %}
  <style>
    .panes {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
    }
    .pane {
      padding: 20px;
    }
  </style>
{% endblock %}

{% block two_col_js %}
  <script type="text/javascript">
    $(function () {
      $('.contest-moss').click(function () {
        return confirm('{{ _('Are you sure you want MOSS the contest?') }}');
      });
    });
    $(function () {
      $('.contest-moss-delete').click(function () {
        return confirm('{{ _('Are you sure you want to delete the MOSS results?') }}');
      });
    });
  </script>
{% endblock %}

{% block middle_content %}
  {% if has_results %}
    <table class="table">
      <thead>
        <tr>
          <th class="header">{{ _('Problem') }}</th>
          {% for lang in languages %}
            <th class="header">{{ lang }}</th>
          {% endfor %}
        </tr>
      </thead>
      <tbody>
        {% for problem, results in moss_results %}
          <tr id="problem-{{ problem.code }}">
            <td>
              <a href="{{ url('problem_detail', problem.code) }}">{{ problem.name }}</a>
            </td>
            {% for result in results %}
              <td>
                {% if result.submission_count %}
                  <a href="{{ result.url }}">{{ result.submission_count }} {{_('submissions')}}</a>
                {% else %}
                  {{ _('No submissions') }}
                {% endif %}
              </td>
            {% endfor %}
          </tr>
        {% endfor %}
      </tbody>
    </table>
  {% endif %}
  <div class="panes">
    <div class="pane">
      <form method="post" action="{{ url('contest_moss', contest.key) }}">
        {% csrf_token %}
        <input type="submit" class="unselectable button full contest-moss" style="padding: 10px;"
          value="{% if has_results %} {{ _('Re-MOSS contest') }} {% else %} {{ _('MOSS contest') }} {% endif %}">
      </form>
    </div>
    {% if has_results %}
      <div class="pane">
        <form method="post" action="{{ url('contest_moss_delete', contest.key) }}">
          {% csrf_token %}
          <input type="submit" class="unselectable button full contest-moss-delete" style="padding: 10px;"
            value="{{ _('Delete MOSS results') }}">
        </form>
      </div>
    {% endif %}
  </div>
{% endblock %}
