{% extends "myhome_base.html" %}
{% load i18n %}

{% block main_panel %}
<div class="wide-panel">
    <h2>{{repo.name}}</h2>
    <p class="access-notice">{% trans "This library is encrypted. Please input the password if you want to browse it online. And the password will be kept on the server for only 1 hour." %}</p>
    <form action="{% url 'repo' repo.id %}?next={{ next }}" method="post" id="repo-decrypt-form">{% csrf_token %}
        <label>{% trans "Password: " %}</label>
        <input type="hidden" name="repo_id" value="{{ repo.id }}" />
        <input type="hidden" name="username" value="{{ request.user.username }}" />
        <input type="password" name="password" autofocus />
        <input type="submit" value="{% trans "Submit" %}" />
        <p class="error hide"></p>
        {% for error in form.errors.values %}
        {{ error|escape }}
        {% endfor %}

        {% if not force_server_crypto %}
        {% url 'edit_profile' as profile_edit_url %}
        <p class="tip" style="margin-top:3em;">{% blocktrans %}You can change how to view encrypted libraries online <a class="normal" href="{{ profile_edit_url }}#enc-lib-setting">here</a>.{% endblocktrans %}</p>
        {% endif %}
    </form>
</div>
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
$('#repo-decrypt-form').submit(function() {
    var form = $(this),
        pwd = $('[name="password"]', form).val(),
        err = $('.error',form);
    if (!$.trim(pwd)) {
        err.html("{% trans "Please enter the password." %}").removeClass('hide');
        return false;
    }
});
</script>
{% endblock %}
