|
1 | 1 | {% extends "raw_base.html" %} |
2 | 2 |
|
| 3 | +{# import the macro file to use the password function #} |
| 4 | +{% from "macros.html" import password_input %} |
| 5 | + |
3 | 6 | {% block theme %}light{% endblock %} |
4 | 7 | {% block title %}Sign into Kiwix Admin{% endblock %} |
5 | 8 |
|
|
56 | 59 | --bs-link-hover-color-rgb: 227,130,14; |
57 | 60 | text-decoration: none; |
58 | 61 | } |
| 62 | + |
| 63 | + .password-toggle, .password-toggle:hover, .password-toggle:focus { border-color: var(--bs-border-color); } |
59 | 64 | </style> |
60 | 65 | {% endblock %} |
61 | 66 |
|
|
71 | 76 | <label class="form-label" for="username">Username</label> |
72 | 77 | <input type="text" class="form-control{% if is_incorrect %} is-invalid{% endif %}" name="username" placeholder="Usually “admin”" /> |
73 | 78 | </div> |
74 | | - <div class="mb-3"> |
75 | | - <label class="form-label" for="password">Password</label> |
76 | | - <input type="password" class="form-control{% if is_incorrect %} is-invalid{% endif %}" name="password" aria-describedby="credentialsFeedback"> |
77 | | - {% if is_incorrect and message_content %}<div id="credentialsFeedback" class="invalid-feedback">{{ message_content }}</div>{% endif %} |
78 | | - </div> |
| 79 | + {{ password_input(name="password", error=message_content if is_incorrect else None) }} |
79 | 80 | <div class="d-flex flex-row-reverse"> |
80 | 81 | <input type="submit" class="btn btn-primary" value="Sign-in" /> |
81 | 82 | </div> |
82 | 83 | </form> |
83 | 84 | </div> |
84 | 85 | <div class="mt-1 mb-1 p-3"><a class="returnlink" href="http://{{ ctx.fqdn }}"><i class="fa-solid fa-arrow-left"></i> Return to the Hotspot</a></div> |
85 | 86 | {% endblock %} |
| 87 | + |
| 88 | +{% block javascript %} |
| 89 | +<script type="text/javascript"> |
| 90 | + function run() { |
| 91 | + live('.password-toggle', 'click', function (elem, event) { |
| 92 | + // Find the input that lives in the same group as this button |
| 93 | + const input = elem.parentElement.querySelector('.password-input'); |
| 94 | + const iconShow = elem.querySelector('.icon-show'); |
| 95 | + const iconHide = elem.querySelector('.icon-hide'); |
| 96 | + |
| 97 | + if (input.getAttribute('type') === 'password') { |
| 98 | + input.setAttribute('type', 'text'); |
| 99 | + iconShow.style.display = 'none'; |
| 100 | + iconHide.style.display = 'block'; |
| 101 | + } else { |
| 102 | + input.setAttribute('type', 'password'); |
| 103 | + iconShow.style.display = 'block'; |
| 104 | + iconHide.style.display = 'none'; |
| 105 | + } |
| 106 | + }); |
| 107 | + } |
| 108 | +</script> |
| 109 | +</script> |
| 110 | +{% endblock %} |
0 commit comments