feat: add password reveal toggle JS
This commit is contained in:
parent
e75feb0649
commit
d9aa6bd395
1 changed files with 13 additions and 0 deletions
13
l4d2web/static/js/password-reveal.js
Normal file
13
l4d2web/static/js/password-reveal.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
document.addEventListener('click', (e) => {
|
||||
const btn = e.target.closest('[data-password-toggle]');
|
||||
if (!btn) return;
|
||||
const id = btn.dataset.passwordToggle;
|
||||
const mask = document.querySelector(`[data-password-field="${id}"].password-mask`);
|
||||
const value = document.querySelector(`[data-password-field="${id}"].password-value`);
|
||||
if (!mask || !value) return;
|
||||
const hidden = value.hidden;
|
||||
value.hidden = !hidden;
|
||||
mask.hidden = hidden;
|
||||
btn.textContent = hidden ? 'hide' : 'show';
|
||||
btn.setAttribute('aria-label', hidden ? 'Hide RCON password' : 'Show RCON password');
|
||||
});
|
||||
Loading…
Reference in a new issue