{% load static %}
{% load i18n %}
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> Jumpserver </title>
    <link rel="shortcut icon" href="{% static "img/facio.ico" %}" type="image/x-icon">
    {% include '_head_css_js.html' %}
    <link href="{% static "css/jumpserver.css" %}" rel="stylesheet">
    <script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
    <script src="{% static "js/jumpserver.js" %}"></script>
    <script type="text/javascript" src="{% static 'js/pwstrength-bootstrap.js' %}"></script>

</head>

<body class="gray-bg">

    <div class="loginColumns animated fadeInDown">
        <div class="row">

            <div class="col-md-6">
                <h2 class="font-bold">{% trans 'Welcome to the Jumpserver open source fortress' %}</h2>

                <p>
                    {% trans 'Jumpserver is an open source desktop system developed using Python and Django that helps Internet businesses with efficient users, assets, permissions, and audit management' %}
                </p>

                <p>
                    {% trans 'We are from all over the world, we have great admiration and worship for the spirit of open source, we have endless pursuit for perfection, neatness and elegance' %}
                </p>

                <p>
                    {% trans 'We focus on automatic operation and maintenance, and strive to build an easy-to-use, stable, safe and automatic board hopping machine, which is our unremitting pursuit and power' %}
                </p>

                <p>
                    <small>{% trans 'Always young, always with tears in my eyes. Stay foolish Stay hungry' %}</small>
                </p>

            </div>
            <div class="col-md-6">
                <div class="ibox-content">
                    <div><img src="{% static 'img/logo.png' %}" width="82" height="82"> <span class="font-bold text-center" style="font-size: 32px; font-family: inherit">{% trans 'Reset password' %}</span></div>
                    <form class="m-t" role="form" method="post" action="">
                        {% csrf_token %}
                        {% if errors %}
                            <p class="red-fonts">{{ errors }}</p>
                        {% endif %}
                        <div class="form-group">
                            <input type="password" id="id_new_password" class="form-control" name="password" placeholder="{% trans 'Password' %}" required="">
                            {#  密码popover  #}
                            <div id="container">
                                <div class="popover fade bottom in" role="tooltip" id="popover777" style=" display: none; width:260px;">
                                    <div class="arrow" style="left: 50%;"></div>
                                    <h3 class="popover-title" style="display: none;"></h3>
                                    <h4>{% trans 'Your password must satisfy' %}</h4><div id="id_password_rules" style="color: #908a8a; margin-left:20px; font-size:15px;"></div>
                                    <h4 style="margin-top: 10px;">{% trans 'Password strength' %}</h4><div id="id_progress"></div>
                                    <div class="popover-content"></div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <input type="password" id="id_confirm_password" class="form-control" name="password-confirm" placeholder="{% trans 'Password again' %}" required="">
                        </div>
                        <button type="submit" class="btn btn-primary block full-width m-b">{% trans "Setting"  %}</button>

                        <a href="#">
                            <small>Forgot password?</small>
                        </a>

                        <p class="text-muted text-center">
                        </p>
                    </form>
                    <p class="m-t">
                    </p>
                </div>
            </div>
        </div>
        <hr/>
        <div class="row">
            <div class="col-md-12">
                 {% include '_copyright.html' %}
            </div>
        </div>
    </div>

</body>

</html>
 <script>
     $(document).ready(function () {
         // 密码强度校验
         var el = $('#id_password_rules'),
             idPassword = $('#id_new_password'),
             idPopover = $('#popover777'),
             container = $('#container'),
             progress = $('#id_progress'),
             password_check_rules = {{ password_check_rules|safe }},
             minLength = 6,
             top = 146, left = 170,
             i18n_fallback = {
                 "veryWeak": "{% trans 'Very weak' %}",
                 "weak": "{% trans 'Weak' %}",
                 "normal": "{% trans 'Normal' %}",
                 "medium": "{% trans 'Medium' %}",
                 "strong": "{% trans 'Strong' %}",
                 "veryStrong": "{% trans 'Very strong' %}"
             };

         jQuery.each(password_check_rules, function (idx, rules) {
             if(rules.key === 'id_security_password_min_length'){
                 minLength = rules.value
             }
         });

         // 初始化popover
         initPopover(container, progress, idPassword, el, password_check_rules, i18n_fallback);

         // 监听事件
         idPassword.on('focus', function () {
             idPopover.css('top', top);
             idPopover.css('left', left);
             idPopover.css('display', 'block');
         });
         idPassword.on('blur', function () {
             idPopover.css('display', 'none');
         });
         idPassword.on('keyup', function(){
             var password = idPassword.val();
             checkPasswordRules(password, minLength);
         })
     })
 </script>
