{% extends "base_list.html" %}
{% load static %}

{% block title %}{{object.name}}{% if object.tv_series %} - {{object.tv_series}}{% endif %}{% endblock %}

{% block head_extra %}
<style>
.cover   {float:left; width:412px; margin-right:10px; padding-bottom:15px;}
.summary {float:left; width:600px; margin-left:10px;}
.header  {padding-bottom:15px;}
.image-wrapper { contain: content; }
.caption {
     position: fixed;
     top: 15px;
     left: 30px;
     padding: 5px;
     font-size: 110%;
     font-weight: bold;
     color:white;
     background:rgba(0,0,0,0.4);
}
</style>
{% endblock %}

{% block lists %}

<div class="row header">
    <div class="cover image-wrapper">
        {% if object.imdb_rating %}<div class="caption">{{object.imdb_rating}}</div>{% endif %}
        <img src="{% if object.cover_image %}{{object.cover_image.url}}{% else %}{% static 'images/no-video-cover.jpg' %}{% endif %}" width="400px" />
        {% if next_episode_id %}
        <form id="scrobble-form" action="{% url 'scrobbles:lookup-manual-scrobble' %}" method="post">
            {% csrf_token %}
            <input type="hidden" name="item_id" id="id_item_id" value="-i {{next_episode_id}}">
            <button type="submit" class="btn btn-primary">Start next episode</button>
        </form>
        {% endif %}
    </div>
    <div class="summary">
        {% if object.plot%}<p>{{object.plot|safe|linebreaks|truncatewords:160}}</p>{% endif %}
        <hr />
        <p style="float:right;">
            <a href="{{object.imdb_link}}"><img src="{% static "images/imdb_logo.png" %}" width=35></a>
        </p>
    </div>
</div>
<div class="row">
    <div class="col-md">
        <h3>Last scrobbles</h3>
        <div class="table-responsive">
            <table class="table table-striped table-sm">
                <thead>
                    <tr>
                        <th scope="col">Date</th>
                        <th scope="col">Title</th>
                        <th scope="col">Season</th>
                        <th scope="col">Episode</th>
                    </tr>
                </thead>
                <tbody>
                    {% for scrobble in scrobbles %}
                    <tr>
                        <td><a href={{scrobble.get_absolute_url}}>{{scrobble.local_timestamp}}</a></td>
                        <td><a href="{{scrobble.media_obj.get_absolute_url}}">{{scrobble.media_obj.title}}</a></td>
                        <td>{{scrobble.media_obj.season_number}}</td>
                        <td>{{scrobble.media_obj.episode_number}}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}
