Phase 8: TypeScript migration, i18n rewrite, Activity Tree, Projects API, Heartbeats

This commit is contained in:
Rose
2026-04-29 11:50:00 +02:00
parent c705fad626
commit 255914c9f1
43 changed files with 17948 additions and 6899 deletions

View File

@@ -1,55 +1,55 @@
/* Login page — external script, no inline handlers.
* Loaded by the /login route. Reads data attributes from the form for
* i18n strings so the server does not need to inject JS literals.
*/
document.addEventListener('DOMContentLoaded', function () {
var form = document.getElementById('login-form');
var input = document.getElementById('pw');
if (!form || !input) return;
var invalidPw = form.getAttribute('data-invalid-pw') || 'Invalid password';
var connFailed = form.getAttribute('data-conn-failed') || 'Connection failed';
function showErr(msg) {
var err = document.getElementById('err');
if (err) { err.textContent = msg; err.style.display = 'block'; }
}
function hideErr() {
var err = document.getElementById('err');
if (err) { err.style.display = 'none'; }
}
async function doLogin(e) {
e.preventDefault();
var pw = input.value;
hideErr();
try {
var res = await fetch('api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ password: pw }),
credentials: 'include',
});
var data = {};
try { data = await res.json(); } catch (_) {}
if (res.ok && data.ok) {
window.location.href = './';
} else {
showErr(data.error || invalidPw);
(() => {
document.addEventListener("DOMContentLoaded", function() {
const form = document.getElementById("login-form");
const input = document.getElementById("pw");
if (!form || !input) return;
const invalidPw = form.getAttribute("data-invalid-pw") || "Invalid password";
const connFailed = form.getAttribute("data-conn-failed") || "Connection failed";
function showErr(msg) {
const err = document.getElementById("err");
if (err) {
err.textContent = msg;
err.style.display = "block";
}
} catch (ex) {
showErr(connFailed);
}
}
form.addEventListener('submit', doLogin);
input.addEventListener('keydown', function (e) {
if (e.key === 'Enter') {
function hideErr() {
const err = document.getElementById("err");
if (err) {
err.style.display = "none";
}
}
async function doLogin(e) {
e.preventDefault();
doLogin(e);
const pw = input.value;
hideErr();
try {
const res = await fetch("api/auth/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ password: pw }),
credentials: "include"
});
let data = {};
try {
data = await res.json();
} catch (_) {
}
if (res.ok && data.ok) {
window.location.href = "./";
} else {
showErr(data.error || invalidPw);
}
} catch (ex) {
showErr(connFailed);
}
}
form.addEventListener("submit", doLogin);
input.addEventListener("keydown", function(e) {
if (e.key === "Enter") {
e.preventDefault();
doLogin(e);
}
});
});
});
})();
//# sourceMappingURL=login.js.map