{% extends 'base.html' %}
{% load i18n %}
{% load static %}

{% block title %}{% trans 'Check e-mail or openid' %}{% endblock title %}

{% block content %}

{% if mailurl or openidurl %}
      <h2>This is what the avatars will look like depending on the hash and protocol you use:</h2>
    <p>
        {% if mail_hash %}
          MD5 hash (mail): {{ mail_hash }}<br/>
          SHA256 hash (mail): {{ mail_hash256 }}<br/>
        {% endif %}

        {% if openid_hash %}
          SHA256 hash (OpenID): {{ openid_hash }}<br/>
        {% endif %}
    </p>

    <div class="row">
      {% if mailurl %}
<div class="panel panel-tortin" style="min-width:132px;width:calc({{ size }}px + 33px);float:left;margin-left:20px">
  <div class="panel-heading">
    <h3 class="panel-title">MD5 <i class="fa fa-lock" title="Secure connection (https)"></i>&nbsp;<i class="fa fa-at" title="mail: {{ form.mail.value }}"></i></h3>
  </div>
  <div class="panel-body">
           <a href="{{ mailurl_secure }}">
              <center><img src="{{ mailurl_secure }}" style="max-width: {{ size }}px; max-height: {{ size }}px;"></center>
            </a>
</div>
</div>
<div class="panel panel-tortin" style="min-width:132px;width:calc({{ size }}px + 33px);float:left;margin-left:20px">
  <div class="panel-heading">
    <h3 class="panel-title">SHA256 <i class="fa fa-lock" title="Secure connection (https)"></i>&nbsp;<i class="fa fa-at" title="mail: {{ form.mail.value }}"></i></h3>
  </div>
  <div class="panel-body">
            <a href="{{ mailurl_secure_256 }}">
              <center><img src="{{ mailurl_secure_256 }}" style="max-width: {{ size }}px; max-height: {{ size }}px;"></center>
            </a>
</div>
</div>
      {% endif %}

      {% if openidurl %}
<div class="panel panel-tortin" style="min-width:132px;width:calc({{ size }}px + 33px);float:left;margin-left:20px">
  <div class="panel-heading">
    <h3 class="panel-title">SHA256 <i class="fa fa-lock" title="Secure connection (http)"></i>&nbsp;<i class="fa fa-openid" title="openid: {{ form.openid.value }}"></i></h3>
  </div>
  <div class="panel-body">
            <a href="{{ openidurl_secure }}">
              <center><img src="{{ openidurl_secure }}" style="max-width: {{ size }}px; max-height: {{ size }}px;"></center>
            </a>
</div>
</div>
      {% endif %}
    </div>
{% endif %}

<h1>{% trans 'Check e-mail or openid' %}</h1>

{% if form.errors %}
  {% for error in form.non_field_errors %}
    <div class="alert alert-danger" role="alert">{{ error|escape }}</div>
  {% endfor %}
{% endif %}

<div style="max-width:640px">
<form method="post" name="check">
{% csrf_token %}
<div class="form-group"><label for="id_mail">{% trans 'E-Mail' %}</label>
<input type="email" name="mail" maxlength="254" minlength="6" class="form-control" placeholder="{% trans 'E-Mail' %}" {% if form.mail.value %} value="{{ form.mail.value }}" {% endif %} id="id_mail"></div>
<div class="form-group"><label for="id_openid">{% trans 'OpenID' %}</label>
<input type="text" name="openid" maxlength="255" minlength="11" class="form-control" placeholder="{% trans 'OpenID' %}" {% if form.openid.value %} value="{{ form.openid.value }}" {% endif %} id="id_openid"></div>
<div class="form-group"><label for="id_size">{% trans 'Size' %}</label>
<input type="number" name="size" min="5" max="512" class="form-control" placeholder="{% trans 'Size' %}" {% if form.size.value %} value="{{ form.size.value }}" {% else %} value="100" {% endif %} required id="id_size"></div>
{% if form.default_url.errors %}
<div class="alert alert-danger" role="alert">{{ form.default_url.errors }}</div>
{% endif %}
<div class="form-group"><label for="id_default_url">{% trans 'Default URL or special keyword' %}</label>
<input type="text" name="default_url" class="form-control" placeholder="{% trans 'Default' %}" {% if form.default_url.value %} value="{{ form.default_url.value }}" {% endif %} id="id_default_url"></div>
{% if form.default_opt.errors %}
<div class="alert alert-danger" role="alert">{{ form.default_opt.errors }}</div>
{% endif %}

<div class="form-group"><label for="id_default_opt">{% trans 'Default (special keyword)' %}</label>
  {% for opt in form.default_opt.field.choices %}
  <div class="radio" {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}>
    <input type="radio" name="default_opt" value="{{ opt.0 }}"
      id="default_opt-{{ opt.0 }}"
      {% if form.default_opt.value == opt.0 %}checked{% endif %}
    >
    <label for="default_opt-{{ opt.0 }}">{{ opt.1 }}</label>
  </div>
  {% endfor %}
</div>

  <div class="form-group">
      <button type="submit" class="button">{% trans 'Check' %}</button>
</div>
</form>
</div>

<div style="height:40px"></div>
{% endblock content %}
