{% extends "agenda/base.html" %}
{% load compress %}
{% load i18n %}
{% load static %}

{% block container_width %} {% if max_rooms > 6 %}container-wide{% elif max_rooms > 3 %}container-semi-wide{% else %}container-narrow{% endif %}{% endblock %}

{% block agenda_custom_header %}
{% compress js %}
<script src="{% static 'common/js/tabbed.js' %}"></script>
{% endcompress %}
{% endblock %}

{% block agenda_content %}
<span id="offline-vars" data-event="/{{ request.event.urls.schedule }}/"></span>

{% if request.event.settings.use_tracks and request.event.tracks.count > 1 %}
<div id="legend">
  <i class="fa fa-dot-circle-o"></i> ?
  <ul class="tracks">
    {% for track in request.event.tracks.all %}
    <li style="color: {{ track.color }}">{{ track.name }}</li>
    {% endfor %}
  </ul>
</div>
{% endif %}

<div id="fahrplan">
    {% if schedule != schedule.event.current_schedule %}
        <div class="alert alert-warning m-3"><span>
            {% if not schedule.version %}
                {{ phrases.agenda.schedule_editable }}
            {% else %}
                {% blocktrans trimmed with current_url=schedule.event.urls.schedule %}
                    You are currently viewing an older schedule version.
                {% endblocktrans %}
            {% endif %}
            {% if request.event.current_schedule %}
                {% blocktrans trimmed with current_url=schedule.event.urls.schedule %}
                    You can find the current version <a href="{{ current_url }}">here</a>.
                {% endblocktrans %}
            {% endif %}
        </span></div>
    {% endif %}
    <div id="offline-warning" class="alert alert-danger d-none m-3"><span>
      {% blocktrans trimmed %}
      You're currently viewing an offline version of the schedule, so it may be
      outdated. <strong>Refresh</strong> this page once you have an internet
      connection to see the current schedule.
      {% endblocktrans %}
    </span></div>

    {% include "agenda/header_row.html" with with_margin=True with_extra=True %}

    <div class="pretalx-tabbed"><div class="pretalx-tabbed-content">
        {% if day_count > 1 %}
        <div class="pretalx-tabs">
        {% for day in data %}
            <div class="pretalx-tab">
              <label class="pretalx-tab-label" for="{{ day.start.date|date:"c" }}">
                  {{ day.start.date|date:"l" }}, {{ day.start.date|date:"DATE_FORMAT" }}
              </label>
            </div>
        {% endfor %}
        </div>
        {% endif %}
    {% for day in data %}
      {% if day_count > 1 %}
      <input name="tabs" id="{{ day.start.date|date:"c" }}" type="radio" {% if day.start == initial_day %}checked{% endif %}>
      {% endif %}
        <div class="pretalx-schedule-day pretalx-tab-content" data-start="{{ day.display_start|date:"c" }}">
            {% if day.first_start %}
                <div class="pretalx-schedule-day-header-row">
                    <span class="pretalx-schedule-time-column pretalx-schedule-day-header"></span>
                    {% for room in day.rooms %}
                        <div class="pretalx-schedule-day-room-header">{{ room.name }}</div>
                    {% endfor %}
                </div>
                <div class="pretalx-schedule-rooms">
                    <div class="pretalx-schedule-nowline"></div>
                    <div class="pretalx-schedule-time-column">
                        {% for hour in day.hours %}
                            <div class="pretalx-schedule-hour">{{ hour }}</div>
                        {% endfor %}
                    </div>
                    {% for room in day.rooms %}
                    <div class="pretalx-schedule-room">
                        <div class="pretalx-schedule-talk-container" style="height: {{ day.height }}px">
                            {% for talk in room.talks %}
                                {% if not schedule.is_archived and talk.submission and not talk.submission.is_deleted %}
                                  <a href="{{ talk.submission.urls.public }}">
                                {% endif %}

                                <div class="pretalx-schedule-talk{% if request.user in talk.submission.speakers.all %} talk-personal{% endif %}{% if talk.is_active %} active{% endif %}{% if search %} {% if search in talk.submission.title.lower or search in talk.submission.display_speaker_names.lower %} search-hit{% else %} search-fail{% endif %}{% endif %}{% if talk.submission.state == 'accepted' %} accepted{% endif %}{% if not talk.submission %} break{% endif %}"
                                     id="{{ talk.submission.code|default:"break" }}"
                                     {% if not talk.submission.is_deleted %}title="{{ talk.submission.title|default:talk.description }} ({{ talk.submission.display_speaker_names|default:'' }})"{% endif %}
                                     style="height: {{ talk.height }}px; min-height: {% if talk.height >= 30 %}{{ talk.height }}{% else %}30{% endif %}px; top: {{ talk.top }}px;{% if request.event.settings.use_tracks and talk.submission.track %} border-color: {{ talk.submission.track.color }}{% endif %}"
                                     data-time="{{ talk.start|date:"H:i" }}–{{ talk.end|date:"H:i" }}"
                                     data-start="{{ talk.start|date:"c" }}"
                                     data-end="{{ talk.end|date:"c" }}">
                                    <div class="pretalx-schedule-talk-content">
                                      {% if talk.submission %}
                                        {% if talk.submission.do_not_record and not talk.submission.is_deleted %}
                                            <span class="fa-stack">
                                              <i class="fa fa-video-camera fa-stack-1x"></i>
                                              <i class="fa fa-ban do-not-record fa-stack-2x" aria-hidden="true" title="{{ phrases.agenda.schedule_do_not_record }}"></i>
                                            </span>
                                        {% endif %}

                                        {% if talk.submission.is_deleted %}
                                          <span class="pretalx-schedule-talk-title">[{% trans "deleted" %}]</span>
                                        {% else %}
                                            <span class="pretalx-schedule-talk-title">{{ talk.submission.title }}</span>

                                            {% if talk.submission.speakers %}
                                              <span class="pretalx-schedule-talk-speakers">({{ talk.submission.display_speaker_names }})</span><br>
                                            {% endif %}
                                        {% endif %}
                                      {% else %}
                                            <span class="pretalx-schedule-break-title">{{ talk.description }}</span>
                                      {% endif %}
                                    </div>
                                </div>
                            {% if not schedule.is_archived and talk.submission and not talk.submission.is_deleted %}
                            </a>
                            {% endif %}
                            {% endfor %}
                        </div>
                    </div>
                    {% endfor %}
                </div>
            {% else %}
                <div class="no-talks">
                    {% blocktrans with current_day=day.start.date|date:'DATE_FORMAT' weekday=day.start.date|date:'l' trimmed %}
                      No talks on {{ weekday }}, {{ current_day }}.
                    {% endblocktrans %}
                </div>
            {% endif %}
        </div>
    {% endfor %}
</div>

{% compress js %}
  <script defer src="{% static "agenda/js/time.js" %}"></script>
  <script defer src="{% static "agenda/js/schedule.js" %}"></script>
  <script defer src="{% static "agenda/js/offline.js" %}"></script>
{% endcompress %}
{% endblock %}
