Compare commits

..

4 Commits

Author SHA1 Message Date
Koha9
4003fd5bc1
Merge pull request #5 from Koha9/codex/add-grayout-and-strikethrough-for-user-and-password
UI tweak for token login
2025-07-08 19:56:41 +09:00
Koha9
afd4981ba7 refactor login template 2025-07-08 19:54:32 +09:00
Koha9
77c38cd17d Disable highlight when user/pass grayed out 2025-07-08 19:49:35 +09:00
Koha9
0c3d9d7287 Grey out user/password when token present 2025-07-08 19:44:07 +09:00

View File

@ -6,11 +6,11 @@
<h2>🔐 登录信息</h2>
<form method="post" action="/login">
<div class="mb-3">
<label for="user" class="form-label">用户名</label>
<label for="user" class="form-label" id="user-label">用户名</label>
<input type="text" class="form-control" id="user" name="user">
</div>
<div class="mb-3">
<label for="pw" class="form-label">密码</label>
<label for="pw" class="form-label" id="pw-label">密码</label>
<input type="password" class="form-control" id="pw" name="pw">
</div>
<div class="mb-3">
@ -38,4 +38,31 @@
{% if message %}
<div class="alert alert-{{ 'success' if success else 'danger' }} mt-4">{{ message }}</div>
{% endif %}
{% endblock %}
<script>
document.addEventListener('DOMContentLoaded', () => {
const tokenInput = document.getElementById('token');
const inputs = [document.getElementById('user'), document.getElementById('pw')];
const labels = [document.getElementById('user-label'), document.getElementById('pw-label')];
const fieldClasses = ['bg-body-secondary', 'text-body-secondary', 'text-decoration-line-through'];
function toggleCredFields() {
const inactive = tokenInput.value.trim() !== '';
inputs.forEach(el => {
el.readOnly = inactive;
el.tabIndex = inactive ? -1 : 0;
el.style.pointerEvents = inactive ? 'none' : '';
if (inactive && document.activeElement === el) {
el.blur();
}
fieldClasses.forEach(cls => el.classList.toggle(cls, inactive));
});
labels.forEach(el => {
['text-decoration-line-through', 'text-body-secondary'].forEach(cls => el.classList.toggle(cls, inactive));
});
}
tokenInput.addEventListener('input', toggleCredFields);
toggleCredFields();
});
</script>
{% endblock %}