- Plain HTML + vanilla JS modules, no build step; talks to /api/v1 with a bearer token and only ever inserts server data as text - Overview: now-playing dot-matrix display with live progress, totals, 30-day plays meter, top artists/tracks by period, recent plays - History (paged, grouped by day), Apps (create/delete, reveal/copy keys, player setup details), Sessions (revoke), sign-in approval page for the Last.fm desktop auth flow, sign in and registration - Light and dark themes, responsive to phone widths, vendored fonts (SIL OFL) so the UI has no third-party requests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
30 lines
935 B
JavaScript
30 lines
935 B
JavaScript
import { api, describeError, getToken, safeNext, setToken } from "./api.js";
|
|
import { errorBox, replace } from "./dom.js";
|
|
import { publicPage } from "./layout.js";
|
|
|
|
publicPage();
|
|
const next = safeNext(new URLSearchParams(location.search).get("next"));
|
|
if (getToken()) location.replace(next);
|
|
|
|
const form = document.getElementById("login");
|
|
const messages = document.getElementById("messages");
|
|
|
|
form.addEventListener("submit", async (event) => {
|
|
event.preventDefault();
|
|
const button = form.querySelector("button");
|
|
button.disabled = true;
|
|
replace(messages);
|
|
try {
|
|
const { token } = await api("/auth/login", {
|
|
method: "POST",
|
|
auth: false,
|
|
body: { username: form.elements.username.value.trim(), password: form.elements.password.value },
|
|
});
|
|
setToken(token);
|
|
location.href = next;
|
|
} catch (error) {
|
|
replace(messages, errorBox(describeError(error)));
|
|
button.disabled = false;
|
|
}
|
|
});
|