refactor: move frontend JS to external files and enable strict CSP

This commit is contained in:
dev
2026-09-09 10:06:49 +03:00
parent d6e589d2f5
commit 018c65adc5
34 changed files with 2444 additions and 2307 deletions
+20
View File
@@ -0,0 +1,20 @@
const API = location.origin;
async function doLogin() {
const pwd = document.getElementById('pwdInput').value;
if (!pwd) return;
try {
const res = await fetch(`${API}/api/stats`, { headers: { 'X-Admin-Token': pwd } });
if (res.ok) {
sessionStorage.setItem('adminToken', pwd);
location.href = 'dashboard.html';
} else {
document.getElementById('loginErr').style.display = 'block';
}
} catch {
document.getElementById('loginErr').style.display = 'block';
}
}
document.getElementById('pwdInput').addEventListener('keydown', e => { if (e.key === 'Enter') doLogin(); });
document.querySelector('.login button').addEventListener('click', doLogin);