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

{% block title %}Change Password Page{% endblock title %}

{% block head_block %}
    <link rel="shortcut icon" href="/media/icons/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="{% static 'css/styles.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'css/webmap.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'css/password_reset.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'css/header.css' %}" />
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script>
{% endblock %}

{% block topbar %}
    <a href="https://reindicator.com" title="Home - REIndicator"><img src="/media/images/logo1.png" align="left" height="50" alt="REIndicator homepage"></a>
    {% if user.is_authenticated %}
    <div class="topbar-dropdown">
        <a href="javascript:void(0);" class="icon dropbtn" onclick="menu_dropdown()">
            <i class="fa fa-bars"></i>
        </a>
        
        <div id="dropdownContent" class="topbar-dropdown-content">
            <a href="/"><i class="fa fa-globe" aria-hidden="true"></i> View Map</a>
            <a href="/admin"><i class="fa fa-cog" aria-hidden="true"></i> Settings</a>
            {% if not user|has_group:"Hiatus" %}
            <a href='https://info.reindicator.com/new-member-welcome-notes/' target='_blank'><i class="fa fa-exclamation-circle" aria-hidden="true"></i> New Members Start Here</a>
            <a href="https://info.reindicator.com/webinar-replays/" target='_blank'><i class="fa fa-play-circle-o" aria-hidden="true"></i> Webinar Replays</a>
            <a href = "https://info.reindicator.com/" target='_blank'><i class="fa fa-life-ring" aria-hidden="true"></i> Support</a>
            {% if not user|has_group:"MDM1" %}
            <a href='#videoPopup' class="versionVideoLink" target='_blank'>Learn About Version 3.6</a>
            <a href='https://us06web.zoom.us/j/86440202851' class="webinarLink-dropdown" target='_blank'>Next Webinar: <span style='color:#ba3b46;'>Friday, December 1, 2PM ET</span>.<br>Preparing Investor Presentations Ep. 2</a>
            {% endif %}
            <a href = "https://calendly.com/reindicator/member-strategy-session" style="position:relative;" target='_blank'> Click here to schedule<br>a Quick Strategy Call with Scott</a>
            {% endif %}
            <a href="/logout"><i class="fa fa-sign-out" aria-hidden="true"></i> Log Out</a>
        </div>
    </div>
    {% if not user|has_group:"Hiatus" and not user|has_group:"MDM1" %}
    <div class="webinarLinkDiv" style="width: 224px;"><a href='https://us06web.zoom.us/j/86440202851' class="webinarLink" target='_blank'>Next Webinar: <span style='color:#e9ff19;'>Friday, December 1, 2PM ET</span>.<br>Preparing Investor Presentations Ep. 2</a></div>
    <div class="versionVideoLinkDiv w100ForSmall"><a href='#videoPopup' class="versionVideoLink" target='_blank'>Learn About Version 3.6</a></div>
    <div id="videoPopup" class="mfp-hide embed-responsive embed-responsive-21by9">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/Kt7NBcIBUps" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
    </div>
    {% endif %}
    <div class = "control-buttons" style="float: right;">
        <a href="/" title="View Map" ><img src="/media/icons/SVG_USA_World.svg" class="menu-button" /></a>
        <a href="/admin" title="Settings" ><img src="/media/icons/setting1.svg" class="settingBtn menu-button" /></a>
        <a href="{% url 'logout' %}?next=/" title="Log Out" style="margin: 0px 15px 0 0;"><img src="/media/icons/logout1.svg" class="logoutBtn menu-button" /></a>
    </div>
    <div class = "welcome-user">
        <div class = 'welcom_msg'>
            <span>
                Welcome,
                <strong>{% firstof user.get_short_name user.get_username %}</strong>.
            </span>
        </div>
    </div>
    {% if not user|has_group:"Hiatus" %}
    <div class = "help-link" style="float: right;">
        <div class="helpLinkDiv w100ForSmall"><a href='https://info.reindicator.com/new-member-welcome-notes/' class="helpLink" target='_blank'>New Members Start Here</a></div>
        <div class="helpLinkDiv"><a href='https://info.reindicator.com/webinar-replays/' class="helpLink" target='_blank'>Replays</a></div>
        <div class="helpLinkDiv"><a href='https://info.reindicator.com/' class="helpLink" target='_blank'>Support</a></div>
        <div class="helpLinkDiv" style="position: relative;">
            <a href='https://calendly.com/reindicator/member-strategy-session' class="helpLink" target='_blank'>Click here to schedule<br>a Quick Strategy Call with Scott</a>
        </div>
    </div>
    {% endif %}
    
    {% else %}
    <a href="/login" title="Log In" style="margin: 15px 15px 0 0;"><img src="/media/icons/login1.svg" class="loginBtn menu-button" /></a>
    {% endif %}
{% endblock %}

{% block content %}
    <div id='userChange'>
        <h2>Change Password</h2>
        <p>Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly.</p>
        <form method="post">
            {% csrf_token %}
            <div>
                {% if form.errors %}
                    <p class="errornote">
                    {% blocktrans count form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
                    </p>
                {% endif %}

                <div class="form-row">
                    {{ form.old_password.errors }}
                    <label for="id_old_password" class="required">{% trans 'Old password' %}:</label>
                    <div class="change_password_field_wrapper">
                        {{ form.old_password }}
                        <img src="/media/icons/eye.png"
                            id="reveal_old_password"
                            style="width:25px;"
                            onclick="togglePasswordReveal('old_password');"
                            onmouseover="onRevealHover('old_password');"
                            onmouseout="offRevealHover('old_password');"
                        />
                    </div>
                </div>

                <div class="form-row">
                    {{ form.new_password1.errors }}
                    <label for="id_new_password1" class="required">{% trans 'New password' %}:</label>
                    <div class="change_password_field_wrapper">
                        {{ form.new_password1 }}
                        <img src="/media/icons/eye.png"
                            id="reveal_new_password1"
                            style="width:25px;"
                            onclick="togglePasswordReveal('new_password1');"
                            onmouseover="onRevealHover('new_password1');"
                            onmouseout="offRevealHover('new_password1');"
                        />
                    </div>
                </div>
                <span class="helptext">
                    <ul>
                        <li>Your password can't be too similar to your other personal information.</li>
                        <li>Your password must contain at least 8 characters.</li>
                        <li>Your password can't be a commonly used password.</li>
                        <li>Your password can't be entirely numeric.</li>
                    </ul>
                </span>
                <div class="form-row">
                {{ form.new_password2.errors }}
                    <label for="id_new_password2" class="required">{% trans 'New password confirmation' %}:</label>
                    <div class="change_password_field_wrapper">
                        {{ form.new_password2 }}
                        <img src="/media/icons/eye.png"
                            id="reveal_new_password2"
                            style="width:25px;"
                            onclick="togglePasswordReveal('new_password2');"
                            onmouseover="onRevealHover('new_password2');"
                            onmouseout="offRevealHover('new_password2');"
                        />
                    </div>
                </div>

                <div class="fieldWrapper setting-submit-flex">
                    <input type="submit" value="Submit">
                    <a href="/editinfo/">{% trans 'Back' %}</a>
                </div>

                <script type="text/javascript">
                    document.getElementById("id_old_password").focus();
                    function onRevealHover(y)
                    {
                        x = document.getElementById("reveal_"+y);
                        x.setAttribute('src', "/media/icons/eye_hover.png");
                    }

                    function offRevealHover(y)
                    {
                        x = document.getElementById("reveal_"+y);
                        x.setAttribute('src', "/media/icons/eye.png");
                    }

                    function togglePasswordReveal(y)
                    {
                        x = document.getElementById("id_"+y);
                        if (x.type === "password") {
                            x.type = "text";
                        } else {
                            x.type = "password";
                        }
                    }
                </script>
            </div>
        </form>
    </div>
{% endblock content %}