{% extends "base_list.html" %}

{% block title %}Long Plays{% endblock %}

{% block head_extra %}
<style>
 dl { width: 210px; float:left; margin-right: 10px; }
 dt a { color:white; text-decoration: none; font-size:smaller; }
 img { height:200px; width: 200px; object-fit: cover; }
 dd .right { float:right; }
</style>
{% endblock  %}

{% block lists %}
<div class="row">

    {% if view == 'grid' %}
    {% for period, medias in in_progress.items %}
    {% if medias %}
    <h2>{% if period == "active" %}Recently played{% else %}More than a week ago{% endif %}</h2>
    <div class="col-md">
        {% for media in medias %}
        <dl>
            <dt><a href="{{media.get_absolute_url}}">{{media.title}}</a></dt>
            {% if media.hltb_cover %}
            <dd><a href="{{media.get_absolute_url}}"><img src="{{media.hltb_cover_medium.url}}" width=200 height=200 /></a></dd>
            {% elif media.cover %}
            <dd><a href="{{media.get_absolute_url}}"><img src="{{media.cover_medium.url}}" style="width: 200px; height: 200px; object-fit:cover; " /></a></dd>
            {% endif %}
            <dd>
                {% if media.is_long_play_in_progress %}Playing{% else %}<a type="button" class="btn btn-sm btn-primary" href="{{media.start_url}}">Resume</a>{% endif %}
                <a type="button" class="right btn btn-sm " href="{{media.get_longplay_finish_url}}">Finish</a>
            </dd>
        </dl>
        {% endfor %}
    </div>
    {% endif %}
    {% endfor %}
    {% else %}
    <div class="col-md">
        <div class="table-responsive">
            <table class="table table-striped table-sm">
                <thead>
                    <tr>
                        <th scope="col">Scrobbles</th>
                        <th scope="col">Title</th>
                        <th scope="col"></th>
                        <th scope="col">Resume</th>
                        <th scope="col">Finish</th>
                    </tr>
                </thead>
                <tbody>
                    {% for media in in_progress %}
                    <tr>
                        <td>{{media.scrobble_set.count}}</td>
                        <td><a href="{{media.get_absolute_url}}">{{media}}</a></td>
                        <td>{% if media.author %}{{media.author}}{% else %}{{media.platforms.first}}{% endif %}</td>
                        <td><a type="button" class="btn btn-sm btn-primary" href="{{media.start_url}}">Resume</a></td>
                        <td><a type="button" class="right btn btn-sm " href="{{media.get_longplay_finish_url}}">Finish</a></td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
    {% endif %}

    <hr/>
    <h2>Completed</h2>
    {% if view == 'grid' %}
    <div>
        {% for media in completed %}
        {% if media.hltb_cover %}
        <dl>
            <dd><a href="{{media.get_absolute_url}}"><img src="{{media.hltb_cover_medium.url}}" width=200 /></a></dd>
            <dt><a href="{{media.get_absolute_url}}">{{media.title}}</a></dt>
        </dl>
        {% elif media.cover %}
        <dl>
            <dd><a href="{{media.get_absolute_url}}"><img src="{{media.cover_medium.url}}" width=200 /></a></dd>
            <dt><a href="{{media.get_absolute_url}}">{{media.title}}</a></dt>
        </dl>
        {% endif %}
        {% endfor %}
    </div>
    {% else %}
    <div class="col-md">
        <div class="table-responsive">
            <table class="table table-striped table-sm">
                <thead>
                    <tr>
                        <th scope="col">Scrobbles</th>
                        <th scope="col">Title</th>
                        <th scope="col"></th>
                    </tr>
                </thead>
                <tbody>
                    {% for media in completed %}
                    <tr>
                        <td>{{media.scrobble_set.count}}</td>
                        <td><a href="{{media.get_absolute_url}}">{{media}}</a></td>
                        <td>{% if media.author %}{{media.author}}{% else %}{{media.platforms.first}}{% endif %}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
    {% endif %}
</div>
{% endblock %}
