{% load static %}
{% load front_tags %}
{% load spel_tags %}
{% if annot_chapters %}
<p class="bg-primary info">Chapitres correspondant aux annotations :</p>
{% endif %}
<div class="row">
  <div class="col-md-8">
	<ul class="list-inline chapter-tag-list">
	    {% if start_date != "" or end_date != "" %}<li class="small searched-tag date">
	      {% if start_date != "" %}{{ start_date }} &le; {% endif %}date{% if end_date != "" %} &le; {{ end_date }}{% endif %}
	      <span class="glyphicon glyphicon-remove small"></span></li>
	    {% endif %}
	    {% for t in annot_types %}<li class="small searched-tag type">{{ t|remove_tag_key }} <span class="glyphicon glyphicon-remove small"></span></li>{% endfor %}
	    {% for t in mod_scen %}<li class="small searched-tag modscen">{{ t|remove_tag_key }} <span class="glyphicon glyphicon-remove small"></span></li>{% endfor %}
	    {% for t in perso %}<li class="small searched-tag perso">{{ t|remove_tag_key }} <span class="glyphicon glyphicon-remove small"></span></li>{% endfor %}
	    {% if searched_ref_text %}<li class="small searched-tag reftext">{{ searched_ref_text|first }} &le; ref. texte  &le; {{ searched_ref_text|last }} <span class="glyphicon glyphicon-remove small"></span></li>{% endif %}
	</ul>
    <p>{{ segments|length }} segment(s) trouvé(s)</p>
  </div>
  {% if not annot_chapters %}
  <div class="col-md-4">
    <button class="chapter-to-annot btn btn-info multiline btn-xs">Annotations correspondant aux chapitres</button>
  </div>
  {% endif %}
</div>
<table class="table table-striped table-condensed tablesorter">
    <thead>
        <tr><th>Type</th><th>Ref texte</th><th>Titre de la vidéo</th><th>Date de tournage de la vidéo</th><th class="popinfo">&nbsp;</th></tr>
    </thead>
    <tbody>
  {% for s in segments %}
    <tr class="chapter-data" data-content="{{ s.iri_id }}" data-start="{{ s.start_ts }}" data-end="{{ s.start_ts|add:s.duration }}">
        <td title="{{ s.cutting_id }}">{{ s.cutting_id|slice:":1"|upper }}</td>
        <td>{{ s.tags|get_tags:"ref_text"|join:', ' }}</td>
        <td>{% if annot_chapters %}{{ s.ct }}{% else %}{{ s.content.title }}{% endif %}</td>
		<td>{{ s.content.content_creation_date | date:"Y-m-d" }}</td>
        <td>
          <span class="glyphicon glyphicon-info-sign popinfo" data-trigger="hover" data-container="body" data-toggle="popover" data-placement="auto" 
                  data-content="<strong>Timecodes:</strong> {{ s.start_ts|str_duration }} - {{ s.start_ts|add:s.duration|str_duration }}<br/>{{ s.tags|get_tags:'group'|safe }}"></span>
          <a class="play-button" href="{% url 'spel_player' %}?g={{ s.iri_id }}&d=theatre&f=720p.mp4&p={{ s.project_id }}#id={{ s.element_id }}" target="_blank"><span class="glyphicon glyphicon-play"></span></a>
          <input type="checkbox" class="filter-chapter-annot" />
        </td>
    </tr>
  {% endfor %}
    <tbody>
</table>
