derpherp
This commit is contained in:
+25
-30
@@ -5,45 +5,40 @@ import { enqueue, flushQueue } from "./lib/offlineQueue.js";
|
|||||||
import { registerPwa, wirePwaInstall, subscribePush } from "./lib/pwa.js";
|
import { registerPwa, wirePwaInstall, subscribePush } from "./lib/pwa.js";
|
||||||
import { renderSlots, renderHeatmap, updateStats, showToast, showConfetti, showEasterEgg } from "./lib/ui.js";
|
import { renderSlots, renderHeatmap, updateStats, showToast, showConfetti, showEasterEgg } from "./lib/ui.js";
|
||||||
|
|
||||||
let pinBuffer = "";
|
|
||||||
|
|
||||||
const STATUS = { upcoming: "Noch nicht", pending: "Jetzt!", overdue: "Überfällig", snoozed: "Snoozed", taken: "Genommen", missed: "Verpasst" };
|
const STATUS = { upcoming: "Noch nicht", pending: "Jetzt!", overdue: "Überfällig", snoozed: "Snoozed", taken: "Genommen", missed: "Verpasst" };
|
||||||
|
|
||||||
function showScreen(id) {
|
function showScreen(id) {
|
||||||
document.querySelectorAll(".screen").forEach((s) => { s.hidden = s.id !== id; });
|
document.querySelectorAll(".screen").forEach((s) => { s.hidden = s.id !== id; });
|
||||||
}
|
}
|
||||||
|
|
||||||
function wirePinPad() {
|
function wirePinForm() {
|
||||||
const pad = document.getElementById("pinPad");
|
const form = document.getElementById("pinForm");
|
||||||
const keys = ["1","2","3","4","5","6","7","8","9","⌫","0","✓"];
|
const input = document.getElementById("pinInput");
|
||||||
pad.innerHTML = keys.map((k) =>
|
const errEl = document.getElementById("loginError");
|
||||||
`<button type="button" class="pinKey${k.length > 1 ? " wide" : ""}" data-key="${k}">${k}</button>`
|
|
||||||
).join("");
|
|
||||||
|
|
||||||
pad.addEventListener("click", async (e) => {
|
input.addEventListener("input", () => {
|
||||||
const btn = e.target.closest("[data-key]");
|
const digits = input.value.replace(/\D/g, "").slice(0, 6);
|
||||||
if (!btn) return;
|
if (input.value !== digits) input.value = digits;
|
||||||
const key = btn.dataset.key;
|
|
||||||
const errEl = document.getElementById("loginError");
|
|
||||||
errEl.hidden = true;
|
errEl.hidden = true;
|
||||||
|
});
|
||||||
|
|
||||||
if (key === "⌫") { pinBuffer = pinBuffer.slice(0, -1); }
|
form.addEventListener("submit", async (e) => {
|
||||||
else if (key === "✓") {
|
e.preventDefault();
|
||||||
if (pinBuffer.length < 4) return;
|
const pin = input.value.trim();
|
||||||
try {
|
if (pin.length < 4) return;
|
||||||
const { token } = await api.login(pinBuffer);
|
|
||||||
setToken(token);
|
errEl.hidden = true;
|
||||||
pinBuffer = "";
|
try {
|
||||||
await initApp();
|
const { token } = await api.login(pin);
|
||||||
} catch {
|
setToken(token);
|
||||||
errEl.textContent = "Falscher PIN. Dein Gehirn auch.";
|
input.value = "";
|
||||||
errEl.hidden = false;
|
await initApp();
|
||||||
pinBuffer = "";
|
} catch {
|
||||||
}
|
errEl.textContent = "Falscher PIN. Dein Gehirn auch.";
|
||||||
} else if (pinBuffer.length < 6) {
|
errEl.hidden = false;
|
||||||
pinBuffer += key;
|
input.value = "";
|
||||||
|
input.focus();
|
||||||
}
|
}
|
||||||
document.getElementById("pinDisplay").textContent = "•".repeat(pinBuffer.length) || "••••";
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +162,7 @@ async function boot() {
|
|||||||
try { await initApp(); return; } catch { clearToken(); }
|
try { await initApp(); return; } catch { clearToken(); }
|
||||||
}
|
}
|
||||||
showScreen("loginScreen");
|
showScreen("loginScreen");
|
||||||
wirePinPad();
|
wirePinForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
boot();
|
boot();
|
||||||
|
|||||||
+4
-2
@@ -22,8 +22,10 @@
|
|||||||
<h1>TakeYourMeds</h1>
|
<h1>TakeYourMeds</h1>
|
||||||
<p class="tagline">Dein Gehirn. Deine Medis. Unser Sarkasmus.</p>
|
<p class="tagline">Dein Gehirn. Deine Medis. Unser Sarkasmus.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="pinDisplay" id="pinDisplay">••••</div>
|
<form id="pinForm" class="pinForm">
|
||||||
<div class="pinPad" id="pinPad"></div>
|
<input type="number" id="pinInput" class="pinInput" inputmode="numeric" min="0" max="999999" step="1" placeholder="PIN" autocomplete="off" required>
|
||||||
|
<button type="submit" class="btn btn-primary pinSubmit">Anmelden</button>
|
||||||
|
</form>
|
||||||
<p class="loginError" id="loginError" hidden></p>
|
<p class="loginError" id="loginError" hidden></p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
+17
-15
@@ -43,25 +43,27 @@ body {
|
|||||||
.loginHero h1 { font-size: 2rem; color: var(--primary); text-shadow: 0 2px 12px rgba(241,47,18,.5); }
|
.loginHero h1 { font-size: 2rem; color: var(--primary); text-shadow: 0 2px 12px rgba(241,47,18,.5); }
|
||||||
.tagline { color: var(--text-muted); margin-top: .5rem; font-size: .95rem; }
|
.tagline { color: var(--text-muted); margin-top: .5rem; font-size: .95rem; }
|
||||||
|
|
||||||
.pinDisplay {
|
.pinForm {
|
||||||
text-align: center; font-size: 2rem; letter-spacing: .5rem;
|
display: flex; flex-direction: column; gap: .75rem;
|
||||||
margin: 1rem 0; color: var(--accent-cyan); min-height: 2.5rem;
|
max-width: 280px; margin: 1rem auto 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pinPad {
|
.pinInput {
|
||||||
display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem;
|
width: 100%; padding: .85rem 1rem;
|
||||||
max-width: 280px; margin: 0 auto;
|
border: 2px solid var(--bg-card-hover); border-radius: var(--radius);
|
||||||
}
|
background: var(--bg-card); color: var(--accent-cyan);
|
||||||
|
|
||||||
.pinKey {
|
|
||||||
aspect-ratio: 1; border: none; border-radius: var(--radius);
|
|
||||||
background: var(--bg-card); color: var(--text);
|
|
||||||
font-family: inherit; font-size: 1.5rem; font-weight: 600;
|
font-family: inherit; font-size: 1.5rem; font-weight: 600;
|
||||||
cursor: pointer; transition: transform .1s, background .15s;
|
text-align: center; letter-spacing: .5rem;
|
||||||
box-shadow: 0 4px 12px rgba(0,0,0,.3);
|
-moz-appearance: textfield;
|
||||||
}
|
}
|
||||||
.pinKey:active { transform: scale(.93); background: var(--primary); }
|
.pinInput:focus {
|
||||||
.pinKey.wide { grid-column: span 1; font-size: 1rem; }
|
outline: none; border-color: var(--accent-cyan);
|
||||||
|
box-shadow: 0 0 0 3px rgba(0, 229, 255, .2);
|
||||||
|
}
|
||||||
|
.pinInput::-webkit-outer-spin-button,
|
||||||
|
.pinInput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
|
||||||
|
|
||||||
|
.pinSubmit { width: 100%; }
|
||||||
|
|
||||||
.loginError { text-align: center; color: var(--danger); margin-top: 1rem; }
|
.loginError { text-align: center; color: var(--danger); margin-top: 1rem; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user