{% extends "sickbeard-base.html" %}

{% block sickbeard_content %}

{% macro item(i) -%}
<div class="coming_ep" id="{{i.tvdbid}}_{{i.season}}_{{i.episode}}" tvdb={{i.tvdbid}}>

  <h2><a href="{{ url }}/home/displayShow?show={{i.tvdbid}}" target="_blank">{{ i.show_name }} - {{ i.season }}x{{ i.episode }} - {{ i.ep_name }}</a></h2>

  {% if not compact_view %}
    <img width="100%" src="{{i.image}}" />
  {% endif %}

  <div class="options">
    <img class="banner" src="{{ url_for('static', filename='images/banner_panel.png') }}" id="{{i.tvdbid}}" title="{{i.show_name}} on Maraschino" />
    <a href="http://www.thetvdb.com/?tab=series&id={{i.tvdbid}}" target="_blank"><img class="tvdb" src="{{ url_for('static', filename='images/tvdb.png') }}" title="{{i.show_name}} on TVDB"/></a>
    <img class="search" src="{{ url_for('static', filename='images/search.png') }}" id="{{i.tvdbid}}" episode="{{i.episode}}" season="{{i.season}}" title="Search for episode"/>
  </div>

  <div class="details">
    <div class="airs">{{i.airs}}{% if show_airdate %} ({{i.airdate}}){% endif %}</div>
    {% if i.ep_plot|length > 2 %}

      {% if compact_view %}
        <div class="compact_plot">
          -
          <span class="truncated">
            {{ i.ep_plot|truncate(75) }}
          </span>
          <span class="expanded" style="display: none;">{{ i.ep_plot|truncate(400) }}</span>
          <a class="expand" href="#">[+]</a>
        </div>

      {% else %}
        <div class="plot-title">Plot</div>
        <div class="plot">
          <h4>{{ i.show_name }} - {{ i.season }}x{{ i.episode }} - {{ i.ep_name }}</h4>
          <p>{{ i.ep_plot|truncate(400) }}</p>
        </div>
      {% endif %}
    {% endif %}
  </div>

</div>
{%- endmacro %}

<div id="sb_content">
  <div id="future">
    {% if missed|length %}
    <div id="missed" title="SB has missed {{ missed|length }} episodes">{{ missed|length }}</div>
    <div class="missed">
      {% for show in missed %}
      {{item(show)}}
      {% endfor %}
    </div>
    {% endif %}
    {% if today|length %}
    <div id="today">
      <h3>Today</h3>
      {% for show in today %}
      {{item(show)}}
      {% endfor %}
    </div>
    {% endif %}
    {% if soon|length %}
    <div id="soon">
      <h3>Soon</h3>
      {% for show in soon %}
      {{item(show)}}
      {% endfor %}
    </div>
    {% endif %}
    {% if later|length %}
    <div id="later">
      <h3>Later</h3>
      {% for show in later %}
      {{item(show)}}
      {% endfor %}
    </div>
    {% endif %}
  </div>
</div>

{% endblock %}
