-
-
+
+
+
+
Paste your 12 or 24 words.
+
+
You'll stay signed in. Sign out from the ⋯ menu.
@@ -687,36 +699,6 @@ $("toggleCreateBtn").addEventListener("click", () => {
$("createBox").classList.toggle("show");
if ($("createBox").classList.contains("show")) $("createHandle").focus();
});
-$("toggleNamePwBtn").addEventListener("click", () => {
- $("createBox").classList.remove("show");
- $("mnemonicBox").classList.remove("show");
- $("namePwBox").classList.toggle("show");
- if ($("namePwBox").classList.contains("show")) $("signinHandle").focus();
-});
-$("useNamePwBtn").addEventListener("click", async () => {
- const handle = $("signinHandle").value.trim();
- const password = $("signinPassword").value;
- if (!handle) { err($("signinErr"), "enter your name"); return; }
- if (!password) { err($("signinErr"), "enter your password"); return; }
- err($("signinErr"), "");
- const btn = $("useNamePwBtn"); const prev = btn.textContent;
- btn.disabled = true; btn.textContent = "Signing in…";
- try {
- const r = await bridge.invoke("getBackup", { password });
- if (!r || !r.ok) throw new Error((r && r.err) || "wrong password or no local account");
- const r2 = await bridge.invoke("init", { mnemonic: r.mnemonic, handle: handle, remember: true });
- if (!r2 || !r2.ok) throw new Error((r2 && r2.err) || "sign-in failed");
- showApp({ pkHex: r2.pkHex, npub: r2.npub, handle: r2.handle || (handle + ".erm") });
- } catch (e) {
- err($("signinErr"), (e && e.message) || String(e));
- } finally { btn.disabled = false; btn.textContent = prev; }
-});
-$("toggleMnemonicBtn").addEventListener("click", () => {
- $("createBox").classList.remove("show");
- $("namePwBox").classList.remove("show");
- $("mnemonicBox").classList.toggle("show");
- if ($("mnemonicBox").classList.contains("show")) $("mnemonicInput").focus();
-});
$("useCreateBtn").addEventListener("click", () => {
const handle = $("createHandle").value.trim();
const p1 = $("createPassword").value;
@@ -726,10 +708,55 @@ $("useCreateBtn").addEventListener("click", () => {
if (p1 !== p2) { err($("signinErr"), "passwords don't match"); return; }
initWithOpts({ create: true, handle, password: p1 });
});
-$("useMnemonicBtn").addEventListener("click", () => {
- const mnemonic = $("mnemonicInput").value;
- initWithOpts({ useVault: false, mnemonic });
+
+// --- unified Sign in button + chip switcher ---
+function switchMethod(name) {
+ for (const c of document.querySelectorAll(".signin-chips .chip")) {
+ const active = c.dataset.method === name;
+ c.classList.toggle("chip-active", active);
+ c.style.background = active ? "var(--sky)" : "var(--panel)";
+ c.style.color = active ? "#06111a" : "var(--ink)";
+ c.style.borderColor = active ? "var(--sky)" : "var(--line)";
+ c.style.fontWeight = active ? "600" : "400";
+ }
+ $("methodNamepw").style.display = name === "namepw" ? "flex" : "none";
+ $("methodSeed").style.display = name === "seed" ? "flex" : "none";
+ state._signinMethod = name;
+ const focusEl = name === "namepw" ? $("signinHandle") : $("mnemonicInput");
+ setTimeout(() => focusEl && focusEl.focus(), 50);
+}
+state._signinMethod = "namepw";
+for (const c of document.querySelectorAll(".signin-chips .chip")) {
+ c.addEventListener("click", () => switchMethod(c.dataset.method));
+}
+$("signinBtn").addEventListener("click", async () => {
+ const m = state._signinMethod || "namepw";
+ err($("signinErr"), "");
+ if (m === "namepw") {
+ const handle = $("signinHandle").value.trim();
+ const password = $("signinPassword").value;
+ if (!handle) { err($("signinErr"), "enter your name"); return; }
+ if (!password) { err($("signinErr"), "enter your password"); return; }
+ const btn = $("signinBtn"); const prev = btn.textContent;
+ btn.disabled = true; btn.textContent = "Signing in\u2026";
+ try {
+ const r = await bridge.invoke("getBackup", { password });
+ if (!r || !r.ok) throw new Error((r && r.err) || "wrong password or no local account");
+ const r2 = await bridge.invoke("init", { mnemonic: r.mnemonic, handle, remember: true });
+ if (!r2 || !r2.ok) throw new Error((r2 && r2.err) || "sign-in failed");
+ showApp({ pkHex: r2.pkHex, npub: r2.npub, handle: r2.handle || handle });
+ } catch (e) {
+ err($("signinErr"), (e && e.message) || String(e));
+ } finally { btn.disabled = false; btn.textContent = prev; }
+ } else {
+ const mnemonic = $("mnemonicInput").value.trim();
+ if (!mnemonic || mnemonic.split(/\s+/).length < 12) {
+ err($("signinErr"), "paste a 12- or 24-word mnemonic"); return;
+ }
+ initWithOpts({ useVault: false, mnemonic });
+ }
});
+
$("popOutBtn").addEventListener("click", () => bridge.invoke("open-messages"));
$("menuBtn").addEventListener("click", (e) => {
e.stopPropagation();