{% extends "photos/base.html" %}

{% load i18n %}
{% load humanize %}
{% load pagination_tags %}
{% load tagging_tags %}
{% load photo_tags %}
{% load perm_tags %}

{% block title %}{{ block.super }}{{ photo_set.name }}{% endblock %}

{% block extra_head %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/photos.css">
{% endblock %}

{% block body %}
<div class="t">

    <div class="photos-nav">
		{% photo_set_nav request.user photo_set %}
	</div>

    <h1>{{ photo_set.name }}</h1>
    
    {% if task_id %}
        <div id="zip-wait">
            <p>{% trans "Please wait while we compile the zip file for" %} {{ photo_set.name }}. <img src="{{ STATIC_URL }}images/ajax-loader.gif"></p>
        </div>
    {% endif %}
    
    <div id="zip-done">
        <p>{% trans "Zip file ready for download" %}.</p>
        {% trans "Download" %} <a id='download-link' href="{{ file_path }}">{% trans "here" %}.</a></p>
    </div>
    
</div>

{% endblock %}

{% block extra_body %}
    {{ block.super }}
    <script type="text/javascript">
        {% if task_id %}
            function refresh(){
                $.ajax({
                    url: "{% url photoset_zip_status photo_set.id task_id %}",
                    success: function(data){
                        if (data != "DNE"){
                            $('#zip-wait').hide();
                            $('#download-link').attr('href', data);
                            $('#zip-done').show();
                        } else {
                            setTimeout(refresh, 2000);
                        }
                    }
                });
            }
            $(document).ready(function(){
                $('#zip-done').hide();
                refresh();
            });
        {% endif %}
    </script>
{% endblock %}
