@clagentic/console 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CREDITS.md +3 -0
- package/LICENSE +21 -0
- package/README.md +250 -0
- package/bin/cli.js +2812 -0
- package/lib/agents-favorites.js +164 -0
- package/lib/agents.js +282 -0
- package/lib/ask-user-mcp-server.js +120 -0
- package/lib/browser-mcp-server.js +484 -0
- package/lib/build-user-env.js +63 -0
- package/lib/certs/fullchain.pem +47 -0
- package/lib/certs/privkey.pem +5 -0
- package/lib/cli-sessions.js +265 -0
- package/lib/codex-defaults.js +18 -0
- package/lib/config.js +332 -0
- package/lib/crisis-safety.js +60 -0
- package/lib/daemon-projects.js +164 -0
- package/lib/daemon.js +1602 -0
- package/lib/dm.js +128 -0
- package/lib/ipc.js +125 -0
- package/lib/ipv4-only.js +39 -0
- package/lib/mcp-local.js +385 -0
- package/lib/notes.js +141 -0
- package/lib/os-users.js +529 -0
- package/lib/pages.js +1325 -0
- package/lib/project-connection.js +302 -0
- package/lib/project-external-trigger.js +236 -0
- package/lib/project-file-watch.js +120 -0
- package/lib/project-filesystem.js +528 -0
- package/lib/project-http.js +753 -0
- package/lib/project-image.js +95 -0
- package/lib/project-knowledge.js +88 -0
- package/lib/project-loop.js +1304 -0
- package/lib/project-mcp.js +374 -0
- package/lib/project-memory.js +39 -0
- package/lib/project-notifications.js +262 -0
- package/lib/project-sessions.js +1581 -0
- package/lib/project-user-mention.js +193 -0
- package/lib/project-user-message.js +628 -0
- package/lib/project.js +1303 -0
- package/lib/public/app.js +1031 -0
- package/lib/public/apple-touch-icon.png +0 -0
- package/lib/public/claude-code-avatar.png +0 -0
- package/lib/public/codex-avatar.png +0 -0
- package/lib/public/console-icon.png +0 -0
- package/lib/public/css/admin.css +736 -0
- package/lib/public/css/agent-picker.css +119 -0
- package/lib/public/css/base.css +235 -0
- package/lib/public/css/channel-layout.css +441 -0
- package/lib/public/css/command-palette.css +559 -0
- package/lib/public/css/debate.css +1609 -0
- package/lib/public/css/diff.css +139 -0
- package/lib/public/css/filebrowser.css +1976 -0
- package/lib/public/css/highlight.css +144 -0
- package/lib/public/css/home-hub.css +545 -0
- package/lib/public/css/icon-strip.css +1856 -0
- package/lib/public/css/input.css +1349 -0
- package/lib/public/css/loop.css +1248 -0
- package/lib/public/css/mention.css +317 -0
- package/lib/public/css/menus.css +857 -0
- package/lib/public/css/messages.css +1833 -0
- package/lib/public/css/mobile-nav.css +1332 -0
- package/lib/public/css/notifications-center.css +296 -0
- package/lib/public/css/overlays.css +1273 -0
- package/lib/public/css/playbook.css +264 -0
- package/lib/public/css/profile.css +397 -0
- package/lib/public/css/rewind.css +671 -0
- package/lib/public/css/scheduler-modal.css +1495 -0
- package/lib/public/css/scheduler.css +1420 -0
- package/lib/public/css/server-settings.css +909 -0
- package/lib/public/css/session-search.css +159 -0
- package/lib/public/css/sidebar.css +2012 -0
- package/lib/public/css/skills.css +789 -0
- package/lib/public/css/sticky-notes.css +854 -0
- package/lib/public/css/stt.css +155 -0
- package/lib/public/css/title-bar.css +674 -0
- package/lib/public/css/tooltip.css +67 -0
- package/lib/public/css/user-settings.css +702 -0
- package/lib/public/emoji-data.json +1 -0
- package/lib/public/favicon-banded-32.png +0 -0
- package/lib/public/favicon-banded.png +0 -0
- package/lib/public/favicon-dark.svg +32 -0
- package/lib/public/favicon.svg +32 -0
- package/lib/public/icon-192.png +0 -0
- package/lib/public/icon-512.png +0 -0
- package/lib/public/icon-banded-76.png +0 -0
- package/lib/public/icon-banded-96.png +0 -0
- package/lib/public/icon-mono.svg +25 -0
- package/lib/public/icons/email/gmail.svg +7 -0
- package/lib/public/icons/email/outlook.svg +35 -0
- package/lib/public/icons/email/yahoo.svg +1 -0
- package/lib/public/index.html +1946 -0
- package/lib/public/manifest.json +27 -0
- package/lib/public/markdown-worker.js +43 -0
- package/lib/public/marked.min.js +6 -0
- package/lib/public/modules/admin.js +954 -0
- package/lib/public/modules/agent-picker.js +429 -0
- package/lib/public/modules/app-connection.js +216 -0
- package/lib/public/modules/app-cursors.js +492 -0
- package/lib/public/modules/app-dm.js +265 -0
- package/lib/public/modules/app-favicon.js +231 -0
- package/lib/public/modules/app-header.js +242 -0
- package/lib/public/modules/app-home-hub.js +432 -0
- package/lib/public/modules/app-loop-ui.js +691 -0
- package/lib/public/modules/app-loop-wizard.js +439 -0
- package/lib/public/modules/app-messages.js +1415 -0
- package/lib/public/modules/app-misc.js +463 -0
- package/lib/public/modules/app-notifications.js +651 -0
- package/lib/public/modules/app-panels.js +1061 -0
- package/lib/public/modules/app-projects.js +875 -0
- package/lib/public/modules/app-rate-limit.js +529 -0
- package/lib/public/modules/app-rendering.js +739 -0
- package/lib/public/modules/app-skills-install.js +285 -0
- package/lib/public/modules/avatar.js +36 -0
- package/lib/public/modules/command-palette.js +491 -0
- package/lib/public/modules/console-logo.js +162 -0
- package/lib/public/modules/context-sources.js +365 -0
- package/lib/public/modules/diff.js +412 -0
- package/lib/public/modules/dom-refs.js +21 -0
- package/lib/public/modules/emoji-picker.js +222 -0
- package/lib/public/modules/events.js +21 -0
- package/lib/public/modules/filebrowser.js +1966 -0
- package/lib/public/modules/fileicons.js +172 -0
- package/lib/public/modules/icons.js +80 -0
- package/lib/public/modules/input.js +1102 -0
- package/lib/public/modules/longpress.js +74 -0
- package/lib/public/modules/markdown.js +486 -0
- package/lib/public/modules/mcp-ui.js +295 -0
- package/lib/public/modules/mention.js +1093 -0
- package/lib/public/modules/notifications.js +613 -0
- package/lib/public/modules/playbook.js +578 -0
- package/lib/public/modules/profile.js +594 -0
- package/lib/public/modules/project-settings.js +849 -0
- package/lib/public/modules/project-switcher.js +375 -0
- package/lib/public/modules/qrcode.js +87 -0
- package/lib/public/modules/rewind.js +381 -0
- package/lib/public/modules/scheduler-config.js +1611 -0
- package/lib/public/modules/scheduler-history.js +131 -0
- package/lib/public/modules/scheduler.js +1689 -0
- package/lib/public/modules/server-settings.js +842 -0
- package/lib/public/modules/session-search.js +456 -0
- package/lib/public/modules/settings-defaults.js +253 -0
- package/lib/public/modules/sidebar-mobile.js +1425 -0
- package/lib/public/modules/sidebar-projects.js +2022 -0
- package/lib/public/modules/sidebar-sessions.js +1548 -0
- package/lib/public/modules/sidebar-users.js +449 -0
- package/lib/public/modules/sidebar.js +348 -0
- package/lib/public/modules/skills.js +793 -0
- package/lib/public/modules/state.js +3 -0
- package/lib/public/modules/sticky-notes.js +1221 -0
- package/lib/public/modules/store.js +34 -0
- package/lib/public/modules/stt.js +266 -0
- package/lib/public/modules/terminal.js +987 -0
- package/lib/public/modules/theme.js +812 -0
- package/lib/public/modules/tool-palette.js +562 -0
- package/lib/public/modules/tools.js +2285 -0
- package/lib/public/modules/tooltip.js +150 -0
- package/lib/public/modules/user-settings.js +544 -0
- package/lib/public/modules/utils.js +56 -0
- package/lib/public/modules/ws-ref.js +26 -0
- package/lib/public/style.css +34 -0
- package/lib/public/sw.js +159 -0
- package/lib/push.js +149 -0
- package/lib/scheduler.js +471 -0
- package/lib/sdk-bridge.js +1792 -0
- package/lib/sdk-message-processor.js +740 -0
- package/lib/sdk-message-queue.js +42 -0
- package/lib/sdk-skill-discovery.js +131 -0
- package/lib/sdk-worker.js +677 -0
- package/lib/server-admin.js +712 -0
- package/lib/server-auth.js +737 -0
- package/lib/server-dm.js +170 -0
- package/lib/server-palette.js +104 -0
- package/lib/server-settings.js +553 -0
- package/lib/server-skills.js +280 -0
- package/lib/server.js +1390 -0
- package/lib/session-search.js +693 -0
- package/lib/sessions.js +946 -0
- package/lib/smtp.js +221 -0
- package/lib/terminal-manager.js +219 -0
- package/lib/terminal.js +39 -0
- package/lib/themes/ayu-light.json +9 -0
- package/lib/themes/catppuccin-latte.json +9 -0
- package/lib/themes/catppuccin-mocha.json +9 -0
- package/lib/themes/clagentic-dark.json +10 -0
- package/lib/themes/clagentic-light.json +10 -0
- package/lib/themes/dracula.json +9 -0
- package/lib/themes/everforest-light.json +9 -0
- package/lib/themes/everforest.json +9 -0
- package/lib/themes/github-light.json +9 -0
- package/lib/themes/gruvbox-dark.json +9 -0
- package/lib/themes/gruvbox-light.json +9 -0
- package/lib/themes/monokai.json +9 -0
- package/lib/themes/nord-light.json +9 -0
- package/lib/themes/nord.json +9 -0
- package/lib/themes/one-dark.json +9 -0
- package/lib/themes/one-light.json +9 -0
- package/lib/themes/rose-pine-dawn.json +9 -0
- package/lib/themes/rose-pine.json +9 -0
- package/lib/themes/solarized-dark.json +9 -0
- package/lib/themes/solarized-light.json +9 -0
- package/lib/themes/tokyo-night-light.json +9 -0
- package/lib/themes/tokyo-night.json +9 -0
- package/lib/updater.js +124 -0
- package/lib/user-presence.js +92 -0
- package/lib/users-auth.js +146 -0
- package/lib/users-permissions.js +118 -0
- package/lib/users-preferences.js +254 -0
- package/lib/users.js +465 -0
- package/lib/utils.js +64 -0
- package/lib/worktree.js +134 -0
- package/lib/ws-schema.js +464 -0
- package/lib/yoke/adapters/claude-worker.js +759 -0
- package/lib/yoke/adapters/claude.js +1599 -0
- package/lib/yoke/adapters/codex.js +1559 -0
- package/lib/yoke/codex-app-server.js +352 -0
- package/lib/yoke/index.js +319 -0
- package/lib/yoke/instructions.js +61 -0
- package/lib/yoke/interface.js +98 -0
- package/lib/yoke/mcp-bridge-server.js +302 -0
- package/lib/yoke/package.json +7 -0
- package/package.json +72 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// --- Global JS tooltip system ---
|
|
2
|
+
// Unified tooltip using [data-tip] attribute.
|
|
3
|
+
// Usage: initTooltips() auto-binds, converts [title] to [data-tip].
|
|
4
|
+
// Call registerTooltip(el, text) for dynamic elements.
|
|
5
|
+
|
|
6
|
+
var tooltipEl = null;
|
|
7
|
+
var showTimer = null;
|
|
8
|
+
var SHOW_DELAY = 120;
|
|
9
|
+
var currentTarget = null;
|
|
10
|
+
|
|
11
|
+
function initTooltips() {
|
|
12
|
+
// Create singleton tooltip element
|
|
13
|
+
tooltipEl = document.createElement("div");
|
|
14
|
+
tooltipEl.className = "tooltip";
|
|
15
|
+
document.body.appendChild(tooltipEl);
|
|
16
|
+
|
|
17
|
+
// Convert existing title attributes to data-tip in target areas
|
|
18
|
+
convertTitles();
|
|
19
|
+
|
|
20
|
+
// Delegate hover events on document for [data-tip]
|
|
21
|
+
document.addEventListener("mouseover", function (e) {
|
|
22
|
+
var target = e.target.closest("[data-tip], [data-tip-html]");
|
|
23
|
+
if (!target) return;
|
|
24
|
+
if (target === currentTarget) return; // already showing for this target
|
|
25
|
+
scheduleShow(target);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
document.addEventListener("mouseout", function (e) {
|
|
29
|
+
var target = e.target.closest("[data-tip], [data-tip-html]");
|
|
30
|
+
if (!target) return;
|
|
31
|
+
// Only hide if we're leaving the target entirely (not moving to a child)
|
|
32
|
+
if (e.relatedTarget && target.contains(e.relatedTarget)) return;
|
|
33
|
+
cancelShow();
|
|
34
|
+
hideTooltip();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
document.addEventListener("pointerdown", function () {
|
|
38
|
+
cancelShow();
|
|
39
|
+
hideTooltip();
|
|
40
|
+
}, true);
|
|
41
|
+
|
|
42
|
+
document.addEventListener("scroll", function () {
|
|
43
|
+
cancelShow();
|
|
44
|
+
hideTooltip();
|
|
45
|
+
}, true);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function convertTitles() {
|
|
49
|
+
var selectors = [
|
|
50
|
+
"#top-bar [title]",
|
|
51
|
+
".title-bar-content [title]",
|
|
52
|
+
"#input-area [title]",
|
|
53
|
+
];
|
|
54
|
+
var els = document.querySelectorAll(selectors.join(", "));
|
|
55
|
+
for (var i = 0; i < els.length; i++) {
|
|
56
|
+
var el = els[i];
|
|
57
|
+
if (!el.getAttribute("data-tip")) {
|
|
58
|
+
el.setAttribute("data-tip", el.getAttribute("title"));
|
|
59
|
+
el.removeAttribute("title");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function registerTooltip(el, text) {
|
|
65
|
+
el.setAttribute("data-tip", text);
|
|
66
|
+
el.removeAttribute("title");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function scheduleShow(el) {
|
|
70
|
+
cancelShow();
|
|
71
|
+
showTimer = setTimeout(function () {
|
|
72
|
+
showTooltipAt(el);
|
|
73
|
+
}, SHOW_DELAY);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function cancelShow() {
|
|
77
|
+
if (showTimer) {
|
|
78
|
+
clearTimeout(showTimer);
|
|
79
|
+
showTimer = null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function showTooltipAt(target) {
|
|
84
|
+
if (!tooltipEl) return;
|
|
85
|
+
// Suppress tooltip when an associated popover/picker is open
|
|
86
|
+
var suppressSel = target.getAttribute("data-tip-suppress-when-open");
|
|
87
|
+
if (suppressSel) {
|
|
88
|
+
var openEl = document.querySelector(suppressSel);
|
|
89
|
+
if (openEl && !openEl.classList.contains("hidden")) return;
|
|
90
|
+
}
|
|
91
|
+
var html = target.getAttribute("data-tip-html");
|
|
92
|
+
var text = target.getAttribute("data-tip");
|
|
93
|
+
if (!html && !text) return;
|
|
94
|
+
currentTarget = target;
|
|
95
|
+
|
|
96
|
+
if (html) {
|
|
97
|
+
tooltipEl.innerHTML = html;
|
|
98
|
+
tooltipEl.classList.add("multi-line");
|
|
99
|
+
// Render any lucide icons inside the tooltip
|
|
100
|
+
if (typeof window !== "undefined" && window.lucide && window.lucide.createIcons) {
|
|
101
|
+
window.lucide.createIcons({ icons: window.lucide.icons, nameAttr: "data-lucide", root: tooltipEl });
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
tooltipEl.textContent = text;
|
|
105
|
+
if (text.indexOf("\n") !== -1) {
|
|
106
|
+
tooltipEl.classList.add("multi-line");
|
|
107
|
+
} else {
|
|
108
|
+
tooltipEl.classList.remove("multi-line");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
tooltipEl.style.top = "-9999px";
|
|
112
|
+
tooltipEl.style.left = "0";
|
|
113
|
+
tooltipEl.style.right = "";
|
|
114
|
+
tooltipEl.classList.add("visible");
|
|
115
|
+
|
|
116
|
+
// Position after layout
|
|
117
|
+
var tipW = tooltipEl.offsetWidth;
|
|
118
|
+
var tipH = tooltipEl.offsetHeight;
|
|
119
|
+
var rect = target.getBoundingClientRect();
|
|
120
|
+
var gap = 8;
|
|
121
|
+
var winW = window.innerWidth;
|
|
122
|
+
var winH = window.innerHeight;
|
|
123
|
+
|
|
124
|
+
// Prefer bottom, fallback to top
|
|
125
|
+
var top = rect.bottom + gap;
|
|
126
|
+
if (top + tipH > winH - 8) {
|
|
127
|
+
top = rect.top - tipH - gap;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Center horizontally, clamp to viewport
|
|
131
|
+
var centerX = rect.left + rect.width / 2;
|
|
132
|
+
var left = centerX - tipW / 2;
|
|
133
|
+
if (left + tipW > winW - 8) {
|
|
134
|
+
tooltipEl.style.left = "";
|
|
135
|
+
tooltipEl.style.right = "8px";
|
|
136
|
+
} else {
|
|
137
|
+
tooltipEl.style.left = Math.max(8, left) + "px";
|
|
138
|
+
tooltipEl.style.right = "";
|
|
139
|
+
}
|
|
140
|
+
tooltipEl.style.top = top + "px";
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function hideTooltip() {
|
|
144
|
+
if (tooltipEl) {
|
|
145
|
+
tooltipEl.classList.remove("visible");
|
|
146
|
+
}
|
|
147
|
+
currentTarget = null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export { initTooltips, registerTooltip };
|
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
// user-settings.js — Modal dialog for user settings
|
|
2
|
+
// Account management and logout
|
|
3
|
+
|
|
4
|
+
import { refreshIcons } from './icons.js';
|
|
5
|
+
import { showToast } from './utils.js';
|
|
6
|
+
import { toggleDarkMode, getCurrentTheme, getChatLayout, setChatLayout, getBrand, setBrand, applyServerThemePrefs } from './theme.js';
|
|
7
|
+
import { setSTTLang } from './stt.js';
|
|
8
|
+
import { userAvatarUrl } from './avatar.js';
|
|
9
|
+
|
|
10
|
+
var ctx = null;
|
|
11
|
+
var settingsEl = null;
|
|
12
|
+
var openBtn = null;
|
|
13
|
+
var closeBtn = null;
|
|
14
|
+
var backdrop = null;
|
|
15
|
+
var navItems = null;
|
|
16
|
+
var sections = null;
|
|
17
|
+
var pinForm = null;
|
|
18
|
+
var pinSetBtn = null;
|
|
19
|
+
var pinCancelBtn = null;
|
|
20
|
+
var pinEnabled = false;
|
|
21
|
+
var currentProfile = null;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export function initUserSettings(appCtx) {
|
|
25
|
+
ctx = appCtx;
|
|
26
|
+
settingsEl = document.getElementById('user-settings');
|
|
27
|
+
openBtn = document.getElementById('user-settings-btn');
|
|
28
|
+
closeBtn = document.getElementById('user-settings-close');
|
|
29
|
+
backdrop = document.getElementById('user-settings-backdrop');
|
|
30
|
+
|
|
31
|
+
if (!settingsEl || !openBtn) return;
|
|
32
|
+
|
|
33
|
+
navItems = settingsEl.querySelectorAll('.us-nav-item');
|
|
34
|
+
sections = settingsEl.querySelectorAll('.us-section');
|
|
35
|
+
pinForm = document.getElementById('us-pin-form');
|
|
36
|
+
|
|
37
|
+
openBtn.addEventListener('click', function () {
|
|
38
|
+
openUserSettings();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (closeBtn) {
|
|
42
|
+
closeBtn.addEventListener('click', function () {
|
|
43
|
+
closeUserSettings();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (backdrop) {
|
|
48
|
+
backdrop.addEventListener('click', function () {
|
|
49
|
+
closeUserSettings();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
document.addEventListener('keydown', function (e) {
|
|
54
|
+
if (e.key === 'Escape' && isUserSettingsOpen()) {
|
|
55
|
+
closeUserSettings();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
for (var i = 0; i < navItems.length; i++) {
|
|
60
|
+
navItems[i].addEventListener('click', function () {
|
|
61
|
+
var section = this.dataset.section;
|
|
62
|
+
switchSection(section);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Mobile nav dropdown
|
|
67
|
+
var navDropdown = document.getElementById('user-settings-nav-dropdown');
|
|
68
|
+
if (navDropdown) {
|
|
69
|
+
navDropdown.addEventListener('change', function () {
|
|
70
|
+
switchSection(this.value);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// PIN save button
|
|
75
|
+
var pinInput = document.getElementById('us-pin-input');
|
|
76
|
+
var pinConfirmInput = document.getElementById('us-pin-confirm-input');
|
|
77
|
+
var pinCurrentInput = document.getElementById('us-pin-current-input');
|
|
78
|
+
var pinSave = document.getElementById('us-pin-save');
|
|
79
|
+
pinSetBtn = document.getElementById('us-pin-set-btn');
|
|
80
|
+
pinCancelBtn = document.getElementById('us-pin-cancel');
|
|
81
|
+
if (pinInput && pinConfirmInput && pinSave) {
|
|
82
|
+
function validatePin() {
|
|
83
|
+
var validNew = /^\d{6}$/.test(pinInput.value);
|
|
84
|
+
var validConfirm = /^\d{6}$/.test(pinConfirmInput.value);
|
|
85
|
+
var validCurrent = !pinEnabled || (pinCurrentInput && /^\d{6}$/.test(pinCurrentInput.value));
|
|
86
|
+
pinSave.disabled = !(validNew && validConfirm && validCurrent && pinInput.value === pinConfirmInput.value);
|
|
87
|
+
}
|
|
88
|
+
pinInput.addEventListener('input', validatePin);
|
|
89
|
+
pinConfirmInput.addEventListener('input', validatePin);
|
|
90
|
+
if (pinCurrentInput) pinCurrentInput.addEventListener('input', validatePin);
|
|
91
|
+
pinInput.addEventListener('keyup', function (e) { e.stopPropagation(); validatePin(); });
|
|
92
|
+
pinConfirmInput.addEventListener('keyup', function (e) { e.stopPropagation(); validatePin(); });
|
|
93
|
+
if (pinCurrentInput) pinCurrentInput.addEventListener('keyup', function (e) { e.stopPropagation(); validatePin(); });
|
|
94
|
+
pinInput.addEventListener('keydown', function (e) {
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
if (e.key === 'Enter') {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
savePin(pinInput.value);
|
|
99
|
+
}
|
|
100
|
+
if (e.key === 'Escape') {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
hidePinForm();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
pinConfirmInput.addEventListener('keydown', function (e) {
|
|
106
|
+
e.stopPropagation();
|
|
107
|
+
if (e.key === 'Enter') {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
savePin(pinInput.value);
|
|
110
|
+
}
|
|
111
|
+
if (e.key === 'Escape') {
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
hidePinForm();
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
if (pinCurrentInput) {
|
|
117
|
+
pinCurrentInput.addEventListener('keydown', function (e) {
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
if (e.key === 'Enter') {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
savePin(pinInput.value);
|
|
122
|
+
}
|
|
123
|
+
if (e.key === 'Escape') {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
hidePinForm();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
pinInput.addEventListener('keypress', stopProp);
|
|
130
|
+
pinConfirmInput.addEventListener('keypress', stopProp);
|
|
131
|
+
if (pinCurrentInput) pinCurrentInput.addEventListener('keypress', stopProp);
|
|
132
|
+
pinSave.addEventListener('click', function () {
|
|
133
|
+
savePin(pinInput.value);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
if (pinSetBtn) {
|
|
137
|
+
pinSetBtn.addEventListener('click', function () {
|
|
138
|
+
showPinForm();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
if (pinCancelBtn) {
|
|
142
|
+
pinCancelBtn.addEventListener('click', function () {
|
|
143
|
+
hidePinForm();
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
var langSelect = document.getElementById('us-lang-select');
|
|
148
|
+
if (langSelect) {
|
|
149
|
+
langSelect.addEventListener('change', function () {
|
|
150
|
+
saveProfileChange({ lang: this.value });
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Auto-continue toggle
|
|
155
|
+
var autoContinueToggle = document.getElementById('us-auto-continue');
|
|
156
|
+
if (autoContinueToggle) {
|
|
157
|
+
autoContinueToggle.addEventListener('change', function () {
|
|
158
|
+
fetch('/api/user/auto-continue', {
|
|
159
|
+
method: 'PUT',
|
|
160
|
+
headers: { 'Content-Type': 'application/json' },
|
|
161
|
+
body: JSON.stringify({ enabled: this.checked }),
|
|
162
|
+
}).then(function (r) { return r.json(); }).then(function (data) {
|
|
163
|
+
if (data.ok) showToast(data.autoContinueOnRateLimit ? 'Auto-continue on' : 'Auto-continue off');
|
|
164
|
+
}).catch(function () {});
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Brand switcher (Clagentic / Classic)
|
|
169
|
+
var brandSwitcher = document.getElementById('us-brand-switcher');
|
|
170
|
+
if (brandSwitcher) {
|
|
171
|
+
var brandBtns = brandSwitcher.querySelectorAll('.layout-option');
|
|
172
|
+
for (var bi = 0; bi < brandBtns.length; bi++) {
|
|
173
|
+
brandBtns[bi].addEventListener('click', function () {
|
|
174
|
+
var brand = this.dataset.brand;
|
|
175
|
+
setBrand(brand);
|
|
176
|
+
for (var bj = 0; bj < brandBtns.length; bj++) {
|
|
177
|
+
brandBtns[bj].classList.toggle('selected', brandBtns[bj].dataset.brand === brand);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Theme switcher (Light / Dark)
|
|
184
|
+
var themeSwitcher = document.getElementById('us-theme-switcher');
|
|
185
|
+
if (themeSwitcher) {
|
|
186
|
+
var themeBtns = themeSwitcher.querySelectorAll('.layout-option');
|
|
187
|
+
for (var ti = 0; ti < themeBtns.length; ti++) {
|
|
188
|
+
themeBtns[ti].addEventListener('click', function () {
|
|
189
|
+
var mode = this.dataset.theme;
|
|
190
|
+
var current = getCurrentTheme();
|
|
191
|
+
var currentMode = (current && current.variant) || 'dark';
|
|
192
|
+
if (mode !== currentMode) toggleDarkMode();
|
|
193
|
+
for (var tj = 0; tj < themeBtns.length; tj++) {
|
|
194
|
+
themeBtns[tj].classList.toggle('selected', themeBtns[tj].dataset.theme === mode);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Layout switcher (Bubble / Channel)
|
|
201
|
+
var layoutSwitcher = document.getElementById('us-layout-switcher');
|
|
202
|
+
if (layoutSwitcher) {
|
|
203
|
+
var layoutBtns = layoutSwitcher.querySelectorAll('.layout-option');
|
|
204
|
+
for (var li = 0; li < layoutBtns.length; li++) {
|
|
205
|
+
layoutBtns[li].addEventListener('click', function () {
|
|
206
|
+
var layout = this.dataset.layout;
|
|
207
|
+
setChatLayout(layout);
|
|
208
|
+
for (var lj = 0; lj < layoutBtns.length; lj++) {
|
|
209
|
+
layoutBtns[lj].classList.toggle('selected', layoutBtns[lj].dataset.layout === layout);
|
|
210
|
+
}
|
|
211
|
+
// Save to server
|
|
212
|
+
fetch('/api/user/chat-layout', {
|
|
213
|
+
method: 'PUT',
|
|
214
|
+
headers: { 'Content-Type': 'application/json' },
|
|
215
|
+
body: JSON.stringify({ layout: layout }),
|
|
216
|
+
}).catch(function () {});
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Logout button
|
|
222
|
+
var logoutBtn = document.getElementById('us-logout-btn');
|
|
223
|
+
if (logoutBtn) {
|
|
224
|
+
logoutBtn.addEventListener('click', function () {
|
|
225
|
+
fetch('/auth/logout', { method: 'POST' }).then(function () {
|
|
226
|
+
window.location.reload();
|
|
227
|
+
}).catch(function () {
|
|
228
|
+
window.location.reload();
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Optional `initialSection` lets callers deep-link directly into a specific
|
|
236
|
+
// settings tab. Falls back to Account so existing callers and the icon click are unchanged.
|
|
237
|
+
export function openUserSettings(initialSection) {
|
|
238
|
+
settingsEl.classList.remove('hidden');
|
|
239
|
+
openBtn.classList.add('active');
|
|
240
|
+
refreshIcons(settingsEl);
|
|
241
|
+
populateAccount();
|
|
242
|
+
hidePinForm();
|
|
243
|
+
switchSection(initialSection || 'us-account');
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function closeUserSettings() {
|
|
247
|
+
settingsEl.classList.add('hidden');
|
|
248
|
+
openBtn.classList.remove('active');
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function isUserSettingsOpen() {
|
|
252
|
+
return settingsEl && !settingsEl.classList.contains('hidden');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function switchSection(sectionName) {
|
|
256
|
+
for (var i = 0; i < navItems.length; i++) {
|
|
257
|
+
navItems[i].classList.toggle('active', navItems[i].dataset.section === sectionName);
|
|
258
|
+
}
|
|
259
|
+
for (var j = 0; j < sections.length; j++) {
|
|
260
|
+
sections[j].classList.toggle('active', sections[j].dataset.section === sectionName);
|
|
261
|
+
}
|
|
262
|
+
var navDropdown = document.getElementById('user-settings-nav-dropdown');
|
|
263
|
+
if (navDropdown) navDropdown.value = sectionName;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function stopProp(e) {
|
|
267
|
+
e.stopPropagation();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function showPinForm() {
|
|
271
|
+
if (!pinForm) return;
|
|
272
|
+
pinForm.classList.remove('hidden');
|
|
273
|
+
var pinCurrentRow = document.getElementById('us-pin-current-row');
|
|
274
|
+
var pinInput = document.getElementById('us-pin-input');
|
|
275
|
+
var pinConfirmInput = document.getElementById('us-pin-confirm-input');
|
|
276
|
+
var pinCurrentInput = document.getElementById('us-pin-current-input');
|
|
277
|
+
var pinSave = document.getElementById('us-pin-save');
|
|
278
|
+
var pinMsg = document.getElementById('us-pin-msg');
|
|
279
|
+
var pinFormTitle = document.getElementById('us-pin-form-title');
|
|
280
|
+
if (pinFormTitle) {
|
|
281
|
+
pinFormTitle.textContent = pinEnabled ? 'Change PIN' : 'Set PIN';
|
|
282
|
+
}
|
|
283
|
+
if (pinCurrentRow) {
|
|
284
|
+
pinCurrentRow.classList.toggle('hidden', !pinEnabled);
|
|
285
|
+
}
|
|
286
|
+
if (pinInput) {
|
|
287
|
+
pinInput.value = '';
|
|
288
|
+
}
|
|
289
|
+
if (pinConfirmInput) pinConfirmInput.value = '';
|
|
290
|
+
if (pinCurrentInput) pinCurrentInput.value = '';
|
|
291
|
+
if (pinSave) pinSave.disabled = true;
|
|
292
|
+
if (pinSave) pinSave.textContent = 'Save';
|
|
293
|
+
if (pinMsg) {
|
|
294
|
+
pinMsg.textContent = '';
|
|
295
|
+
pinMsg.className = 'settings-hint settings-pin-error hidden';
|
|
296
|
+
}
|
|
297
|
+
if (pinEnabled && pinCurrentInput) {
|
|
298
|
+
pinCurrentInput.focus();
|
|
299
|
+
} else if (pinInput) {
|
|
300
|
+
pinInput.focus();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function hidePinForm() {
|
|
305
|
+
if (!pinForm) return;
|
|
306
|
+
pinForm.classList.add('hidden');
|
|
307
|
+
var pinCurrentRow = document.getElementById('us-pin-current-row');
|
|
308
|
+
var pinInput = document.getElementById('us-pin-input');
|
|
309
|
+
var pinConfirmInput = document.getElementById('us-pin-confirm-input');
|
|
310
|
+
var pinCurrentInput = document.getElementById('us-pin-current-input');
|
|
311
|
+
var pinSave = document.getElementById('us-pin-save');
|
|
312
|
+
var pinMsg = document.getElementById('us-pin-msg');
|
|
313
|
+
if (pinCurrentRow) {
|
|
314
|
+
pinCurrentRow.classList.remove('hidden');
|
|
315
|
+
}
|
|
316
|
+
if (pinInput) pinInput.value = '';
|
|
317
|
+
if (pinConfirmInput) pinConfirmInput.value = '';
|
|
318
|
+
if (pinCurrentInput) pinCurrentInput.value = '';
|
|
319
|
+
if (pinSave) pinSave.disabled = true;
|
|
320
|
+
if (pinSave) pinSave.textContent = 'Save';
|
|
321
|
+
if (pinMsg) {
|
|
322
|
+
pinMsg.textContent = '';
|
|
323
|
+
pinMsg.className = 'settings-hint settings-pin-error hidden';
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// --- Account population ---
|
|
328
|
+
|
|
329
|
+
function populateAccount() {
|
|
330
|
+
fetch('/api/profile').then(function (r) {
|
|
331
|
+
if (!r.ok) return null;
|
|
332
|
+
return r.json();
|
|
333
|
+
}).then(function (data) {
|
|
334
|
+
if (!data) return;
|
|
335
|
+
currentProfile = data;
|
|
336
|
+
var displayName = data.name || data.displayName || data.username || 'Clay User';
|
|
337
|
+
var avatarImg = document.getElementById('us-account-avatar-img');
|
|
338
|
+
var avatarFallback = document.getElementById('us-account-avatar-fallback');
|
|
339
|
+
var accountName = document.getElementById('us-account-name');
|
|
340
|
+
var accountSubline = document.getElementById('us-account-subline');
|
|
341
|
+
var langSelect = document.getElementById('us-lang-select');
|
|
342
|
+
var pinSetBtnEl = document.getElementById('us-pin-set-btn');
|
|
343
|
+
var pinFormTitle = document.getElementById('us-pin-form-title');
|
|
344
|
+
if (accountName) {
|
|
345
|
+
accountName.textContent = displayName;
|
|
346
|
+
}
|
|
347
|
+
if (accountSubline) {
|
|
348
|
+
var parts = [];
|
|
349
|
+
if (data.username) parts.push('@' + data.username);
|
|
350
|
+
if (data.role) parts.push(data.role.charAt(0).toUpperCase() + data.role.slice(1));
|
|
351
|
+
accountSubline.textContent = parts.length ? parts.join(' · ') : 'Local profile';
|
|
352
|
+
}
|
|
353
|
+
pinEnabled = !!data.pinEnabled;
|
|
354
|
+
if (pinSetBtnEl) {
|
|
355
|
+
pinSetBtnEl.textContent = pinEnabled ? 'Change PIN' : 'Set PIN';
|
|
356
|
+
}
|
|
357
|
+
if (pinFormTitle) {
|
|
358
|
+
pinFormTitle.textContent = pinEnabled ? 'Change PIN' : 'Set PIN';
|
|
359
|
+
}
|
|
360
|
+
if (langSelect) {
|
|
361
|
+
langSelect.value = data.lang || 'en-US';
|
|
362
|
+
}
|
|
363
|
+
if (data.lang) {
|
|
364
|
+
setSTTLang(data.lang);
|
|
365
|
+
}
|
|
366
|
+
if (avatarImg && avatarFallback) {
|
|
367
|
+
var avatarUrl = getCurrentUserAvatarSrc(data);
|
|
368
|
+
avatarImg.alt = displayName;
|
|
369
|
+
avatarImg.classList.remove('hidden');
|
|
370
|
+
avatarFallback.classList.remove('hidden');
|
|
371
|
+
avatarFallback.textContent = avatarInitials(displayName);
|
|
372
|
+
avatarImg.onload = function () {
|
|
373
|
+
avatarFallback.classList.add('hidden');
|
|
374
|
+
};
|
|
375
|
+
avatarImg.onerror = function () {
|
|
376
|
+
avatarFallback.classList.remove('hidden');
|
|
377
|
+
};
|
|
378
|
+
avatarImg.src = avatarUrl;
|
|
379
|
+
if (avatarImg.complete && avatarImg.naturalWidth > 0) {
|
|
380
|
+
avatarFallback.classList.add('hidden');
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
// Hide account section in single-user mode (no username)
|
|
384
|
+
var accountNav = settingsEl.querySelector('[data-section="us-account"]');
|
|
385
|
+
if (accountNav) accountNav.style.display = data.username ? '' : 'none';
|
|
386
|
+
// Auto-continue toggle
|
|
387
|
+
var acToggle = document.getElementById('us-auto-continue');
|
|
388
|
+
if (acToggle) acToggle.checked = !!data.autoContinueOnRateLimit;
|
|
389
|
+
// Apply server-side theme preferences (overrides stale localStorage on mobile/cross-device)
|
|
390
|
+
applyServerThemePrefs(data.themeMode, data.themeBrand);
|
|
391
|
+
// Brand switcher
|
|
392
|
+
var bSwitcher = document.getElementById('us-brand-switcher');
|
|
393
|
+
if (bSwitcher) {
|
|
394
|
+
var currentBrand = getBrand();
|
|
395
|
+
var bBtns = bSwitcher.querySelectorAll('.layout-option');
|
|
396
|
+
for (var bi = 0; bi < bBtns.length; bi++) {
|
|
397
|
+
bBtns[bi].classList.toggle('selected', bBtns[bi].dataset.brand === currentBrand);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
// Theme switcher
|
|
401
|
+
var tSwitcher = document.getElementById('us-theme-switcher');
|
|
402
|
+
if (tSwitcher) {
|
|
403
|
+
var currentMode = (getCurrentTheme() && getCurrentTheme().variant) || 'dark';
|
|
404
|
+
var tBtns = tSwitcher.querySelectorAll('.layout-option');
|
|
405
|
+
for (var ti = 0; ti < tBtns.length; ti++) {
|
|
406
|
+
tBtns[ti].classList.toggle('selected', tBtns[ti].dataset.theme === currentMode);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
// Layout switcher: sync from server response
|
|
410
|
+
if (data.chatLayout) {
|
|
411
|
+
setChatLayout(data.chatLayout); // update local cache + CSS
|
|
412
|
+
}
|
|
413
|
+
var lSwitcher = document.getElementById('us-layout-switcher');
|
|
414
|
+
if (lSwitcher) {
|
|
415
|
+
var currentLayout = getChatLayout();
|
|
416
|
+
var lBtns = lSwitcher.querySelectorAll('.layout-option');
|
|
417
|
+
for (var li = 0; li < lBtns.length; li++) {
|
|
418
|
+
lBtns[li].classList.toggle('selected', lBtns[li].dataset.layout === currentLayout);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}).catch(function () {});
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function saveProfileChange(updates) {
|
|
425
|
+
if (!currentProfile) return;
|
|
426
|
+
var nextProfile = {};
|
|
427
|
+
var payload = {};
|
|
428
|
+
var key;
|
|
429
|
+
for (key in currentProfile) {
|
|
430
|
+
if (Object.prototype.hasOwnProperty.call(currentProfile, key)) {
|
|
431
|
+
nextProfile[key] = currentProfile[key];
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
for (key in updates) {
|
|
435
|
+
if (Object.prototype.hasOwnProperty.call(updates, key)) {
|
|
436
|
+
nextProfile[key] = updates[key];
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
currentProfile = nextProfile;
|
|
440
|
+
if (updates.lang) {
|
|
441
|
+
setSTTLang(updates.lang);
|
|
442
|
+
}
|
|
443
|
+
payload.name = nextProfile.name;
|
|
444
|
+
payload.lang = nextProfile.lang;
|
|
445
|
+
payload.avatarColor = nextProfile.avatarColor;
|
|
446
|
+
payload.avatarStyle = nextProfile.avatarStyle;
|
|
447
|
+
payload.avatarSeed = nextProfile.avatarSeed;
|
|
448
|
+
payload.avatarCustom = nextProfile.avatarCustom;
|
|
449
|
+
fetch('/api/profile', {
|
|
450
|
+
method: 'PUT',
|
|
451
|
+
headers: { 'Content-Type': 'application/json' },
|
|
452
|
+
body: JSON.stringify(payload),
|
|
453
|
+
}).catch(function () {});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function avatarInitials(value) {
|
|
457
|
+
var text = (value || '').trim();
|
|
458
|
+
if (!text) return '?';
|
|
459
|
+
var parts = text.split(/\s+/);
|
|
460
|
+
var first = parts[0].charAt(0);
|
|
461
|
+
var second = parts.length > 1 ? parts[1].charAt(0) : parts[0].charAt(1);
|
|
462
|
+
var out = first + (second || '');
|
|
463
|
+
return out.toUpperCase();
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function getCurrentUserAvatarSrc(data) {
|
|
467
|
+
var islandAvatar = document.querySelector('.user-island-avatar img');
|
|
468
|
+
if (islandAvatar && islandAvatar.src) return islandAvatar.src;
|
|
469
|
+
if (data && data.avatarCustom) return data.avatarCustom;
|
|
470
|
+
return userAvatarUrl(data, 96);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function savePin(pin) {
|
|
474
|
+
var pinInput = document.getElementById('us-pin-input');
|
|
475
|
+
var pinConfirmInput = document.getElementById('us-pin-confirm-input');
|
|
476
|
+
var pinCurrentInput = document.getElementById('us-pin-current-input');
|
|
477
|
+
var pinSave = document.getElementById('us-pin-save');
|
|
478
|
+
var pinMsg = document.getElementById('us-pin-msg');
|
|
479
|
+
var currentPin = pinCurrentInput ? pinCurrentInput.value.trim() : '';
|
|
480
|
+
var confirmPin = pinConfirmInput ? pinConfirmInput.value.trim() : '';
|
|
481
|
+
var newPin = pinInput ? pinInput.value.trim() : '';
|
|
482
|
+
|
|
483
|
+
if (!/^\d{6}$/.test(newPin)) {
|
|
484
|
+
if (pinMsg) {
|
|
485
|
+
pinMsg.textContent = 'PIN must be exactly 6 digits.';
|
|
486
|
+
pinMsg.className = 'settings-hint settings-pin-error us-pin-msg-err';
|
|
487
|
+
pinMsg.classList.remove('hidden');
|
|
488
|
+
}
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (confirmPin !== newPin) {
|
|
492
|
+
if (pinMsg) {
|
|
493
|
+
pinMsg.textContent = 'PINs do not match.';
|
|
494
|
+
pinMsg.className = 'settings-hint settings-pin-error us-pin-msg-err';
|
|
495
|
+
pinMsg.classList.remove('hidden');
|
|
496
|
+
}
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
if (pinEnabled && !/^\d{6}$/.test(currentPin)) {
|
|
500
|
+
if (pinMsg) {
|
|
501
|
+
pinMsg.textContent = 'Current PIN is required.';
|
|
502
|
+
pinMsg.className = 'settings-hint settings-pin-error us-pin-msg-err';
|
|
503
|
+
pinMsg.classList.remove('hidden');
|
|
504
|
+
}
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
pinSave.disabled = true;
|
|
509
|
+
pinSave.textContent = 'Saving\u2026';
|
|
510
|
+
|
|
511
|
+
fetch('/api/user/pin', {
|
|
512
|
+
method: 'PUT',
|
|
513
|
+
headers: { 'Content-Type': 'application/json' },
|
|
514
|
+
body: JSON.stringify({ currentPin: currentPin, newPin: newPin }),
|
|
515
|
+
}).then(function (r) { return r.json(); }).then(function (data) {
|
|
516
|
+
if (data.ok) {
|
|
517
|
+
showToast('PIN changed');
|
|
518
|
+
hidePinForm();
|
|
519
|
+
} else {
|
|
520
|
+
pinSave.disabled = false;
|
|
521
|
+
pinSave.textContent = 'Save';
|
|
522
|
+
if (pinMsg) {
|
|
523
|
+
pinMsg.textContent = data.error || 'Could not change your PIN. Please try again.';
|
|
524
|
+
pinMsg.className = 'settings-hint settings-pin-error us-pin-msg-err';
|
|
525
|
+
pinMsg.classList.remove('hidden');
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}).catch(function () {
|
|
529
|
+
pinSave.disabled = false;
|
|
530
|
+
pinSave.textContent = 'Save';
|
|
531
|
+
if (pinMsg) {
|
|
532
|
+
pinMsg.textContent = 'Connection lost. Check your network and try again.';
|
|
533
|
+
pinMsg.className = 'settings-hint settings-pin-error us-pin-msg-err';
|
|
534
|
+
pinMsg.classList.remove('hidden');
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
function escHtml(str) {
|
|
541
|
+
var d = document.createElement('div');
|
|
542
|
+
d.textContent = str;
|
|
543
|
+
return d.innerHTML;
|
|
544
|
+
}
|