refactor: replace inline event handlers with bind function for improved readability and maintainability
All checks were successful
Build & Push / Build & Push image (push) Successful in 39s

This commit is contained in:
2026-03-02 22:35:37 +01:00
parent 9f797a211b
commit 771a742c9a
9 changed files with 251 additions and 112 deletions

View File

@@ -244,9 +244,12 @@
</div>
<script nonce="{{ csp_nonce() }}">
document.getElementById('password').addEventListener('keydown', e => {
if (e.key === 'Enter') doLogin();
});
function bind(id, ev, fn) {
const el = document.getElementById(id);
if (el) el.addEventListener(ev, fn);
}
const pwEl = document.getElementById('password'); if (pwEl) pwEl.addEventListener('keydown', e => { if (e.key === 'Enter') doLogin(); });
async function doLogin() {
const errorEl = document.getElementById('errorMsg');
@@ -271,7 +274,7 @@
}
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('btnLogin').addEventListener('click', () => { doLogin() });
bind('btnLogin', 'click', () => { doLogin() });
});
</script>
</body>