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

{% block main_panel %}
<div class="mt-9 mb-4 mx-auto small-panel">
  <p class="intro">{% trans "Please input the password if you want to browse the shared file/directory." %}</p>
  {% if path %}
  {% if direct_download %}
  <form action="{% url view_name token %}?p={{ path }}&dl=1" method="post" id="share-passwd-form">
  {% else %}
  <form action="{% url view_name token %}?p={{ path }}" method="post" id="share-passwd-form">
  {% endif %}
  {% else %}
  {% if direct_download %}
  <form action="{% url view_name token %}?dl=1" method="post" id="share-passwd-form">
  {% else %}
  <form action="{% url view_name token %}" method="post" id="share-passwd-form">
  {% endif %}
  {% endif %}
    {% csrf_token %}
    <input type="hidden" name="token" value="{{ token }}" />
    <div class="form-group">
      <label for="password">{% trans "Password" %}</label>
      <input type="password" name="password" id="password" class="form-control" autofocus />
    </div>
    {% if err_msg %}
    <p class="error">{{ err_msg }}</p>
    {% endif %}
    <button type="submit" class="btn btn-primary sf-btn-submit">{% trans "Submit" %}</button>
  </form>
</div>
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
$('#share-passwd-form').on('submit', function() {
    var form = $(this),
        pwd = $('[name="password"]', form).val(),
        err = $('.error',form);
    if (!pwd.trim()) {
        err.html("{% trans "Please enter the password." %}").removeClass('hide');
        return false;
    }
});
</script>
{% endblock %}
