Login button with show-password, skip identical photos on upload
A Přihlásit/Odhlásit button in the top bar replaces logging in via Přidat hru. The dialog has an eye toggle, says when it is checking, and keeps the remember box as it was after a wrong password; nothing is stored until the server accepts it. A remembered password that no longer works is dropped on load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HA82gVRDXpoukzgMFumoJt
This commit is contained in:
parent
ab842a1d73
commit
6240907809
6 changed files with 138 additions and 44 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { api, getPassword, clearPassword, esc, $ } from "./api.js";
|
||||
import { api, getPassword, authButton, esc, $ } from "./api.js";
|
||||
|
||||
// Old links (/?postava=Lída or /?hra=…) went straight to the reader.
|
||||
const q = new URLSearchParams(location.search);
|
||||
|
|
@ -7,14 +7,19 @@ if (q.has("hra") || q.has("postava")) location.replace(`read.html${location.sear
|
|||
const fmtDate = (iso) => new Date(iso).toLocaleDateString("cs-CZ", { day: "numeric", month: "numeric", year: "numeric" });
|
||||
|
||||
async function main() {
|
||||
const [cfg, plays] = await Promise.all([api("config"), api("plays")]);
|
||||
const cfg = await api("config");
|
||||
await authButton(document.querySelector(".topbar-actions"), { uploads: cfg.uploads, onChange: render });
|
||||
await render();
|
||||
}
|
||||
|
||||
// Logged in, the list also shows drafts, with buttons to add and edit plays.
|
||||
async function render() {
|
||||
const plays = await api("plays");
|
||||
const loggedIn = Boolean(getPassword());
|
||||
$("add").hidden = !cfg.uploads;
|
||||
$("logout").hidden = !loggedIn;
|
||||
$("logout").addEventListener("click", () => { clearPassword(); location.reload(); });
|
||||
$("add").hidden = !loggedIn;
|
||||
|
||||
if (!plays.length) {
|
||||
$("plays").innerHTML = `<li class="muted">Zatím tu není žádná hra.${cfg.uploads ? " Přidejte první tlačítkem nahoře." : ""}</li>`;
|
||||
$("plays").innerHTML = `<li class="muted">Zatím tu není žádná hra.${loggedIn ? " Přidejte první tlačítkem nahoře." : ""}</li>`;
|
||||
return;
|
||||
}
|
||||
$("plays").innerHTML = plays.map((p) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue