mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
Client UI: - Design system: Colors, Typography, Controls resource dictionaries - Message actions: reply compose bar, hover edit/delete/reply buttons - Rich content: code blocks, attachments, system messages, content parser - Server strip: 72px sidebar with server icons, home button, add server - Status picker: popup for changing online/idle/dnd/invisible status - ConnectPage: server health check dots with auto-refresh - User popup: profile card with banner, avatar, roles, member since - Emoji picker: 6 categories, search, grid of Unicode emojis - Settings overlay: full-screen with sidebar navigation - Friends/DM view: sidebar + friends list with tabs (online/all/pending) - Toast notifications: auto-dismiss after 3s with fade animation Models & services: - Attachment model added to Message, ApiMessage, ChatMessagePayload - EditMessageAsync, DeleteMessageAsync, SendStatusChangeAsync APIs - MessageContentParser (code blocks, inline code, bold, italic) - EmojiData, ToastService, HealthStatusToBrushConverter Server (from prior session): - Voice room management, SFU, speaker detection - ACME/TLS support, config improvements - Protocol and schema updates Tests: 331 passing (61 converter + 24 voice service + 34 voice VM + 41 parser + 9 edit/delete + existing)
1968 lines
83 KiB
HTML
1968 lines
83 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>OwnCord — Connect</title>
|
|
<style>
|
|
/* ═══════════════════════════════════════════
|
|
DESIGN TOKENS (mirrors WPF palette + ui-mockup.html)
|
|
═══════════════════════════════════════════ */
|
|
:root {
|
|
--bg-tertiary: #1e1f22;
|
|
--bg-secondary: #2b2d31;
|
|
--bg-primary: #313338;
|
|
--bg-input: #1e1f22;
|
|
--bg-hover: #35373c;
|
|
--bg-active: #404249;
|
|
--bg-overlay: rgba(0,0,0,.7);
|
|
--accent: #5865f2;
|
|
--accent-hover: #4752c4;
|
|
--accent-active: #3c45a5;
|
|
--accent-glow: rgba(88,101,242,.25);
|
|
--text-normal: #dbdee1;
|
|
--text-muted: #949ba4;
|
|
--text-faint: #80848e;
|
|
--text-micro: #6d6f78;
|
|
--text-link: #00a8fc;
|
|
--green: #23a55a;
|
|
--green-hover: #1a8f4b;
|
|
--yellow: #f0b232;
|
|
--red: #f23f43;
|
|
--red-bg: #2d1214;
|
|
--border: #3f4147;
|
|
--border-strong: #4e5058;
|
|
--font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
|
|
--font-body: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
|
|
--font-mono: "Cascadia Code", "Consolas", monospace;
|
|
--radius-sm: 4px; --radius-md: 8px; --radius-lg: 16px;
|
|
}
|
|
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
html, body { height: 100%; overflow: hidden; }
|
|
body {
|
|
font-family: var(--font-body); font-size: 14px;
|
|
color: var(--text-normal); background: var(--bg-primary);
|
|
-webkit-font-smoothing: antialiased;
|
|
}
|
|
button { font-family: inherit; border: none; cursor: pointer; outline: none; }
|
|
input, select, textarea { font-family: inherit; border: none; outline: none; }
|
|
::-webkit-scrollbar { width: 6px; }
|
|
::-webkit-scrollbar-track { background: transparent; }
|
|
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
|
|
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }
|
|
|
|
/* ═══ Page layout ═══ */
|
|
.connect-page {
|
|
display: flex; height: 100vh; position: relative; overflow: hidden;
|
|
}
|
|
|
|
/* ═══ Animated background ═══ */
|
|
.connect-page::before {
|
|
content: ''; position: absolute; inset: 0;
|
|
background:
|
|
radial-gradient(ellipse 600px 400px at 15% 80%, rgba(88,101,242,.08) 0%, transparent 70%),
|
|
radial-gradient(ellipse 500px 350px at 85% 20%, rgba(88,101,242,.06) 0%, transparent 70%),
|
|
radial-gradient(ellipse 300px 300px at 50% 50%, rgba(35,165,90,.04) 0%, transparent 70%);
|
|
pointer-events: none; z-index: 0;
|
|
animation: bgShift 20s ease-in-out infinite alternate;
|
|
}
|
|
@keyframes bgShift {
|
|
0% { opacity: 1; transform: scale(1); }
|
|
50% { opacity: .7; transform: scale(1.05); }
|
|
100% { opacity: 1; transform: scale(1); }
|
|
}
|
|
|
|
/* ═══ Settings gear (top-right) ═══ */
|
|
.settings-gear {
|
|
position: absolute; top: 16px; right: 16px; z-index: 10;
|
|
width: 36px; height: 36px; border-radius: var(--radius-md);
|
|
background: transparent; color: var(--text-faint);
|
|
display: flex; align-items: center; justify-content: center;
|
|
transition: all .2s;
|
|
}
|
|
.settings-gear:hover { background: var(--bg-hover); color: var(--text-normal); transform: rotate(30deg); }
|
|
.settings-gear svg { width: 20px; height: 20px; }
|
|
|
|
/* ═══════════════════════════════════════════
|
|
LEFT PANEL — Saved Server Profiles
|
|
═══════════════════════════════════════════ */
|
|
.server-panel {
|
|
width: 320px; background: var(--bg-secondary);
|
|
display: flex; flex-direction: column; flex-shrink: 0;
|
|
z-index: 1; position: relative;
|
|
border-right: 1px solid var(--bg-tertiary);
|
|
}
|
|
.server-panel-header {
|
|
padding: 16px 20px 12px;
|
|
border-bottom: 1px solid var(--border);
|
|
flex-shrink: 0;
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
}
|
|
.server-panel-header h2 {
|
|
font-size: 11px; font-weight: 700; color: var(--text-faint);
|
|
letter-spacing: .05em; text-transform: uppercase;
|
|
}
|
|
.header-actions { display: flex; gap: 4px; }
|
|
.header-btn {
|
|
width: 28px; height: 28px; border-radius: var(--radius-sm);
|
|
background: transparent; color: var(--text-faint);
|
|
display: flex; align-items: center; justify-content: center;
|
|
transition: all .15s; font-size: 14px;
|
|
}
|
|
.header-btn:hover { background: var(--bg-hover); color: var(--text-normal); }
|
|
.header-btn svg { width: 14px; height: 14px; }
|
|
|
|
/* Server list */
|
|
.server-list { flex: 1; overflow-y: auto; padding: 8px; }
|
|
.server-item {
|
|
display: flex; align-items: center; gap: 12px;
|
|
padding: 10px 12px; border-radius: 6px;
|
|
cursor: pointer; transition: background .15s;
|
|
position: relative;
|
|
}
|
|
.server-item:hover { background: var(--bg-hover); }
|
|
.server-item.active { background: var(--bg-active); }
|
|
.server-item .srv-icon {
|
|
width: 40px; height: 40px; border-radius: 12px;
|
|
display: flex; align-items: center; justify-content: center;
|
|
font-weight: 700; font-size: 16px; color: white;
|
|
flex-shrink: 0; transition: border-radius .2s;
|
|
position: relative;
|
|
}
|
|
.server-item:hover .srv-icon,
|
|
.server-item.active .srv-icon { border-radius: 10px; }
|
|
.server-item .srv-info { flex: 1; min-width: 0; }
|
|
.server-item .srv-name {
|
|
font-size: 14px; font-weight: 600; color: var(--text-normal);
|
|
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
}
|
|
.server-item .srv-meta {
|
|
display: flex; align-items: center; gap: 6px; margin-top: 2px;
|
|
}
|
|
.server-item .srv-host {
|
|
font-size: 12px; color: var(--text-faint);
|
|
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
}
|
|
.server-item .srv-last {
|
|
font-size: 10px; color: var(--text-micro);
|
|
white-space: nowrap;
|
|
}
|
|
|
|
/* Status dot on icon */
|
|
.srv-status-dot {
|
|
width: 10px; height: 10px; border-radius: 50%;
|
|
position: absolute; bottom: -1px; right: -1px;
|
|
border: 2.5px solid var(--bg-secondary);
|
|
}
|
|
.server-item:hover .srv-status-dot { border-color: var(--bg-hover); }
|
|
.server-item.active .srv-status-dot { border-color: var(--bg-active); }
|
|
.srv-status-dot.online { background: var(--green); }
|
|
.srv-status-dot.slow { background: var(--yellow); }
|
|
.srv-status-dot.offline { background: var(--red); }
|
|
.srv-status-dot.unknown { background: var(--text-micro); }
|
|
.srv-status-dot.checking {
|
|
background: var(--text-micro);
|
|
animation: pulse 1s ease-in-out infinite;
|
|
}
|
|
@keyframes pulse {
|
|
0%,100% { opacity: 1; }
|
|
50% { opacity: .3; }
|
|
}
|
|
|
|
/* Latency badge */
|
|
.srv-latency {
|
|
font-size: 10px; color: var(--text-micro); font-family: var(--font-mono);
|
|
white-space: nowrap;
|
|
}
|
|
.srv-latency.good { color: var(--green); }
|
|
.srv-latency.warn { color: var(--yellow); }
|
|
.srv-latency.bad { color: var(--red); }
|
|
|
|
/* Action buttons on server item */
|
|
.srv-actions {
|
|
display: flex; gap: 2px; opacity: 0; transition: opacity .15s; flex-shrink: 0;
|
|
}
|
|
.server-item:hover .srv-actions { opacity: 1; }
|
|
.srv-btn {
|
|
width: 26px; height: 26px; border-radius: var(--radius-sm);
|
|
background: transparent; color: var(--text-faint);
|
|
display: flex; align-items: center; justify-content: center;
|
|
font-size: 13px; transition: all .15s;
|
|
}
|
|
.srv-btn:hover { background: var(--bg-active); color: var(--text-normal); }
|
|
.srv-btn.danger:hover { background: var(--red); color: white; }
|
|
|
|
/* Auto-connect indicator */
|
|
.srv-auto { font-size: 10px; color: var(--accent); margin-left: 4px; }
|
|
|
|
/* Empty state */
|
|
.server-empty {
|
|
flex: 1; display: flex; flex-direction: column;
|
|
align-items: center; justify-content: center; gap: 8px;
|
|
padding: 40px;
|
|
}
|
|
.server-empty-icon {
|
|
width: 64px; height: 64px; border-radius: 16px;
|
|
background: var(--bg-hover); display: flex;
|
|
align-items: center; justify-content: center;
|
|
margin-bottom: 8px;
|
|
}
|
|
.server-empty-icon svg { width: 28px; height: 28px; color: var(--text-micro); }
|
|
.server-empty h3 { font-size: 16px; color: var(--text-faint); font-weight: 600; }
|
|
.server-empty p { font-size: 13px; color: var(--text-micro); text-align: center; line-height: 1.5; }
|
|
|
|
/* Footer */
|
|
.server-panel-footer {
|
|
padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0;
|
|
display: flex; gap: 6px;
|
|
}
|
|
.btn-add-server {
|
|
flex: 1; padding: 8px; border-radius: var(--radius-sm);
|
|
background: transparent; color: var(--text-muted);
|
|
font-size: 13px; transition: all .15s;
|
|
display: flex; align-items: center; justify-content: center; gap: 6px;
|
|
}
|
|
.btn-add-server:hover { background: var(--bg-hover); color: var(--text-normal); }
|
|
.btn-footer-icon {
|
|
width: 32px; height: 32px; border-radius: var(--radius-sm);
|
|
background: transparent; color: var(--text-faint);
|
|
display: flex; align-items: center; justify-content: center;
|
|
transition: all .15s; flex-shrink: 0;
|
|
}
|
|
.btn-footer-icon:hover { background: var(--bg-hover); color: var(--text-normal); }
|
|
.btn-footer-icon svg { width: 16px; height: 16px; }
|
|
|
|
/* Protocol tip */
|
|
.protocol-tip {
|
|
padding: 6px 20px 10px; font-size: 11px; color: var(--text-micro);
|
|
text-align: center; line-height: 1.4;
|
|
}
|
|
.protocol-tip code {
|
|
font-family: var(--font-mono); font-size: 10px;
|
|
background: var(--bg-hover); padding: 1px 4px; border-radius: 2px;
|
|
color: var(--text-faint);
|
|
}
|
|
|
|
/* ═══════════════════════════════════════════
|
|
RIGHT PANEL — Login / Register / 2FA form
|
|
═══════════════════════════════════════════ */
|
|
.form-panel {
|
|
flex: 1; display: flex; align-items: center; justify-content: center;
|
|
z-index: 1; position: relative; padding: 40px;
|
|
}
|
|
.form-container {
|
|
width: 100%; max-width: 400px;
|
|
animation: formSlideIn .5s cubic-bezier(.16,1,.3,1);
|
|
}
|
|
@keyframes formSlideIn {
|
|
from { opacity: 0; transform: translateY(16px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
|
|
/* Logo */
|
|
.form-logo { text-align: center; margin-bottom: 28px; }
|
|
.form-logo-mark {
|
|
width: 56px; height: 56px; border-radius: 16px;
|
|
background: var(--accent); display: inline-flex;
|
|
align-items: center; justify-content: center;
|
|
margin-bottom: 12px;
|
|
box-shadow: 0 8px 32px var(--accent-glow);
|
|
}
|
|
.form-logo-mark svg { width: 32px; height: 32px; }
|
|
.form-logo h1 {
|
|
font-family: var(--font-display);
|
|
font-size: 28px; font-weight: 700; color: white;
|
|
letter-spacing: -.01em;
|
|
}
|
|
.form-logo p { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
|
|
|
|
/* Banners */
|
|
.error-banner {
|
|
background: var(--red-bg); border-radius: var(--radius-sm);
|
|
padding: 12px 14px; margin-bottom: 16px;
|
|
display: none; align-items: flex-start; gap: 8px;
|
|
animation: shakeX .4s ease-in-out;
|
|
}
|
|
.error-banner.visible { display: flex; }
|
|
.error-banner-icon { color: #f38688; font-size: 16px; flex-shrink: 0; margin-top: 1px; }
|
|
.error-banner-text { color: #f38688; font-size: 13px; line-height: 1.4; }
|
|
@keyframes shakeX {
|
|
0%,100% { transform: translateX(0); }
|
|
20% { transform: translateX(-6px); }
|
|
40% { transform: translateX(5px); }
|
|
60% { transform: translateX(-4px); }
|
|
80% { transform: translateX(2px); }
|
|
}
|
|
.success-banner {
|
|
background: rgba(35,165,90,.12); border-radius: var(--radius-sm);
|
|
padding: 12px 14px; margin-bottom: 16px;
|
|
display: none; align-items: center; gap: 8px;
|
|
}
|
|
.success-banner.visible { display: flex; }
|
|
.success-banner-icon { color: var(--green); font-size: 16px; flex-shrink: 0; }
|
|
.success-banner-text { color: var(--green); font-size: 13px; }
|
|
|
|
/* Form fields */
|
|
.form-group { margin-bottom: 16px; }
|
|
.form-row { display: flex; gap: 12px; }
|
|
.form-row .form-group { flex: 1; }
|
|
.form-row .form-group.port-field { flex: 0 0 100px; }
|
|
.form-label {
|
|
display: block; font-size: 11px; font-weight: 700;
|
|
color: var(--text-muted); letter-spacing: .02em;
|
|
text-transform: uppercase; margin-bottom: 6px;
|
|
}
|
|
.form-label .required { color: var(--red); margin-left: 2px; }
|
|
.form-input {
|
|
width: 100%; padding: 10px 12px;
|
|
background: var(--bg-input); color: var(--text-normal);
|
|
border: 1px solid var(--border); border-radius: var(--radius-sm);
|
|
font-size: 14px; transition: border-color .2s;
|
|
}
|
|
.form-input::placeholder { color: var(--text-micro); }
|
|
.form-input:hover { border-color: var(--border-strong); }
|
|
.form-input:focus { border-color: var(--accent); }
|
|
.form-input.error { border-color: var(--red); }
|
|
|
|
/* Password field */
|
|
.password-wrapper { position: relative; }
|
|
.password-wrapper .form-input { padding-right: 40px; }
|
|
.password-toggle {
|
|
position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
|
|
background: transparent; color: var(--text-faint); padding: 4px;
|
|
border-radius: var(--radius-sm); font-size: 16px; transition: color .15s;
|
|
}
|
|
.password-toggle:hover { color: var(--text-normal); }
|
|
|
|
/* Checkbox */
|
|
.form-checkbox {
|
|
display: flex; align-items: center; gap: 8px;
|
|
cursor: pointer; margin-bottom: 16px; user-select: none;
|
|
}
|
|
.form-checkbox input { display: none; }
|
|
.checkbox-box {
|
|
width: 18px; height: 18px; border-radius: var(--radius-sm);
|
|
border: 2px solid var(--border-strong); background: transparent;
|
|
display: flex; align-items: center; justify-content: center;
|
|
transition: all .15s; flex-shrink: 0;
|
|
}
|
|
.checkbox-box svg { opacity: 0; transition: opacity .15s; }
|
|
.form-checkbox:hover .checkbox-box { border-color: var(--accent); }
|
|
.form-checkbox input:checked + .checkbox-box {
|
|
background: var(--accent); border-color: var(--accent);
|
|
}
|
|
.form-checkbox input:checked + .checkbox-box svg { opacity: 1; }
|
|
.checkbox-label { font-size: 13px; color: var(--text-muted); }
|
|
|
|
/* Primary button */
|
|
.btn-primary {
|
|
width: 100%; padding: 12px; border-radius: var(--radius-sm);
|
|
background: var(--accent); color: white;
|
|
font-size: 14px; font-weight: 600;
|
|
transition: background .15s; position: relative; overflow: hidden;
|
|
}
|
|
.btn-primary:hover { background: var(--accent-hover); }
|
|
.btn-primary:active { background: var(--accent-active); }
|
|
.btn-primary:disabled { background: var(--border-strong); color: var(--text-faint); cursor: not-allowed; }
|
|
.btn-primary.loading { pointer-events: none; }
|
|
.btn-primary.loading .btn-text { opacity: 0; }
|
|
.btn-primary .btn-spinner {
|
|
position: absolute; inset: 0;
|
|
display: none; align-items: center; justify-content: center;
|
|
}
|
|
.btn-primary.loading .btn-spinner { display: flex; }
|
|
.spinner {
|
|
width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3);
|
|
border-top-color: white; border-radius: 50%;
|
|
animation: spin .6s linear infinite;
|
|
}
|
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
|
|
/* Mode switch */
|
|
.form-switch { margin-top: 12px; font-size: 13px; color: var(--text-faint); }
|
|
.form-switch a { color: var(--text-link); cursor: pointer; text-decoration: none; }
|
|
.form-switch a:hover { text-decoration: underline; }
|
|
|
|
/* ═══ 2FA / TOTP ═══ */
|
|
.totp-icon {
|
|
width: 64px; height: 64px; border-radius: 50%;
|
|
background: var(--accent); display: flex;
|
|
align-items: center; justify-content: center;
|
|
margin: 0 auto 20px; box-shadow: 0 8px 32px var(--accent-glow);
|
|
}
|
|
.totp-icon svg { width: 32px; height: 32px; color: white; }
|
|
.totp-title { text-align: center; font-size: 22px; font-weight: 700; color: white; margin-bottom: 6px; }
|
|
.totp-subtitle { text-align: center; font-size: 14px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.5; }
|
|
.totp-inputs {
|
|
display: flex; gap: 8px; justify-content: center; margin-bottom: 24px;
|
|
}
|
|
.totp-digit {
|
|
width: 48px; height: 56px; border-radius: var(--radius-md);
|
|
background: var(--bg-input); border: 2px solid var(--border);
|
|
color: white; font-size: 24px; font-weight: 700;
|
|
text-align: center; transition: border-color .2s;
|
|
font-family: var(--font-mono);
|
|
}
|
|
.totp-digit:focus { border-color: var(--accent); }
|
|
.totp-digit.filled { border-color: var(--accent); }
|
|
.totp-back {
|
|
display: block; text-align: center; margin-top: 16px;
|
|
font-size: 13px; color: var(--text-faint); cursor: pointer;
|
|
}
|
|
.totp-back:hover { color: var(--text-link); }
|
|
.totp-backup-link {
|
|
display: block; text-align: center; margin-top: 8px;
|
|
font-size: 12px; color: var(--text-micro); cursor: pointer;
|
|
}
|
|
.totp-backup-link:hover { color: var(--text-link); text-decoration: underline; }
|
|
|
|
/* ═══════════════════════════════════════════
|
|
MODALS (shared)
|
|
═══════════════════════════════════════════ */
|
|
.modal-overlay {
|
|
position: fixed; inset: 0; background: var(--bg-overlay);
|
|
display: none; align-items: center; justify-content: center;
|
|
z-index: 100;
|
|
}
|
|
.modal-overlay.visible { display: flex; }
|
|
.modal {
|
|
background: var(--bg-primary); border-radius: var(--radius-md);
|
|
width: 440px; max-height: 80vh; overflow-y: auto;
|
|
box-shadow: 0 8px 48px rgba(0,0,0,.5);
|
|
animation: modalSlideIn .3s cubic-bezier(.16,1,.3,1);
|
|
}
|
|
@keyframes modalSlideIn {
|
|
from { opacity: 0; transform: translateY(24px) scale(.96); }
|
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
}
|
|
.modal-header {
|
|
padding: 20px 24px 0; display: flex;
|
|
align-items: center; justify-content: space-between;
|
|
}
|
|
.modal-header h3 { font-size: 18px; font-weight: 700; color: white; }
|
|
.modal-close {
|
|
background: transparent; color: var(--text-faint);
|
|
font-size: 20px; padding: 4px; border-radius: var(--radius-sm);
|
|
transition: color .15s;
|
|
}
|
|
.modal-close:hover { color: var(--text-normal); }
|
|
.modal-body { padding: 20px 24px; }
|
|
.modal-footer {
|
|
padding: 16px 24px; background: var(--bg-secondary);
|
|
border-radius: 0 0 var(--radius-md) var(--radius-md);
|
|
display: flex; justify-content: flex-end; gap: 8px;
|
|
}
|
|
.btn-cancel {
|
|
padding: 8px 16px; border-radius: var(--radius-sm);
|
|
background: transparent; color: var(--text-muted);
|
|
font-size: 13px; transition: all .15s;
|
|
}
|
|
.btn-cancel:hover { color: var(--text-normal); text-decoration: underline; }
|
|
.btn-modal-save {
|
|
padding: 8px 20px; border-radius: var(--radius-sm);
|
|
background: var(--accent); color: white;
|
|
font-size: 13px; font-weight: 600; transition: background .15s;
|
|
}
|
|
.btn-modal-save:hover { background: var(--accent-hover); }
|
|
.modal-danger-text { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 8px; }
|
|
.modal-danger-text strong { color: white; }
|
|
.btn-danger {
|
|
padding: 8px 20px; border-radius: var(--radius-sm);
|
|
background: var(--red); color: white;
|
|
font-size: 13px; font-weight: 600; transition: background .15s;
|
|
}
|
|
.btn-danger:hover { background: #d83135; }
|
|
|
|
/* ═══════════════════════════════════════════
|
|
CERTIFICATE TRUST DIALOG
|
|
═══════════════════════════════════════════ */
|
|
.cert-warning {
|
|
width: 64px; height: 64px; border-radius: 50%;
|
|
background: rgba(240,178,50,.12); display: flex;
|
|
align-items: center; justify-content: center;
|
|
margin: 0 auto 16px;
|
|
}
|
|
.cert-warning svg { width: 32px; height: 32px; color: var(--yellow); }
|
|
.cert-title { text-align: center; font-size: 18px; font-weight: 700; color: white; margin-bottom: 8px; }
|
|
.cert-desc { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }
|
|
.cert-details {
|
|
background: var(--bg-tertiary); border-radius: var(--radius-sm);
|
|
padding: 14px 16px; margin-bottom: 16px; font-size: 12px;
|
|
}
|
|
.cert-row {
|
|
display: flex; padding: 4px 0;
|
|
}
|
|
.cert-label { color: var(--text-faint); width: 90px; flex-shrink: 0; }
|
|
.cert-value { color: var(--text-normal); font-family: var(--font-mono); font-size: 11px; word-break: break-all; }
|
|
.cert-fingerprint { color: var(--yellow); }
|
|
.cert-actions {
|
|
display: flex; gap: 8px; justify-content: center; margin-top: 8px;
|
|
}
|
|
.btn-ghost {
|
|
padding: 8px 16px; border-radius: var(--radius-sm);
|
|
background: var(--bg-hover); color: var(--text-muted);
|
|
font-size: 13px; transition: all .15s;
|
|
}
|
|
.btn-ghost:hover { background: var(--bg-active); color: var(--text-normal); }
|
|
|
|
/* ═══════════════════════════════════════════
|
|
SETTINGS OVERLAY (full-screen, like Discord)
|
|
═══════════════════════════════════════════ */
|
|
.settings-overlay {
|
|
position: fixed; inset: 0; background: var(--bg-primary);
|
|
display: none; z-index: 300; animation: settingsFadeIn .2s;
|
|
}
|
|
.settings-overlay.visible { display: flex; }
|
|
@keyframes settingsFadeIn { from { opacity: 0; } to { opacity: 1; } }
|
|
.settings-layout {
|
|
display: flex; width: 100%; height: 100%;
|
|
}
|
|
.settings-nav {
|
|
width: 220px; background: var(--bg-secondary);
|
|
padding: 60px 8px 20px; overflow-y: auto; flex-shrink: 0;
|
|
display: flex; flex-direction: column;
|
|
}
|
|
.settings-nav-title {
|
|
font-size: 11px; font-weight: 700; color: var(--text-faint);
|
|
letter-spacing: .05em; text-transform: uppercase;
|
|
padding: 8px 12px 4px; margin-top: 8px;
|
|
}
|
|
.settings-nav-title:first-child { margin-top: 0; }
|
|
.settings-nav-item {
|
|
padding: 8px 12px; border-radius: var(--radius-sm);
|
|
font-size: 14px; color: var(--text-muted);
|
|
cursor: pointer; transition: all .15s;
|
|
display: flex; align-items: center; gap: 8px;
|
|
background: transparent; text-align: left; width: 100%;
|
|
}
|
|
.settings-nav-item:hover { background: var(--bg-hover); color: var(--text-normal); }
|
|
.settings-nav-item.active { background: var(--bg-active); color: white; }
|
|
.settings-nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
|
|
.settings-nav-sep {
|
|
height: 1px; background: var(--border); margin: 4px 12px;
|
|
}
|
|
.settings-content {
|
|
flex: 1; padding: 60px 40px 40px; overflow-y: auto; max-width: 740px;
|
|
}
|
|
.settings-close {
|
|
position: absolute; top: 16px; right: 16px;
|
|
width: 36px; height: 36px; border-radius: 50%;
|
|
border: 2px solid var(--border-strong); background: transparent;
|
|
color: var(--text-faint); display: flex;
|
|
align-items: center; justify-content: center;
|
|
font-size: 18px; transition: all .15s; z-index: 310;
|
|
}
|
|
.settings-close:hover { border-color: var(--text-normal); color: var(--text-normal); }
|
|
.settings-section-title {
|
|
font-size: 18px; font-weight: 700; color: white; margin-bottom: 20px;
|
|
}
|
|
|
|
/* Settings form elements */
|
|
.setting-row {
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
padding: 14px 0; border-bottom: 1px solid var(--border);
|
|
}
|
|
.setting-row:last-child { border-bottom: none; }
|
|
.setting-info { flex: 1; }
|
|
.setting-label { font-size: 14px; color: var(--text-normal); margin-bottom: 2px; }
|
|
.setting-desc { font-size: 12px; color: var(--text-faint); }
|
|
.setting-control { flex-shrink: 0; margin-left: 16px; }
|
|
|
|
/* Toggle switch */
|
|
.toggle {
|
|
width: 40px; height: 22px; border-radius: 11px;
|
|
background: var(--border-strong); cursor: pointer;
|
|
position: relative; transition: background .2s;
|
|
}
|
|
.toggle.on { background: var(--green); }
|
|
.toggle::after {
|
|
content: ''; position: absolute;
|
|
width: 16px; height: 16px; border-radius: 50%;
|
|
background: white; top: 3px; left: 3px;
|
|
transition: transform .2s;
|
|
}
|
|
.toggle.on::after { transform: translateX(18px); }
|
|
|
|
/* Select dropdown */
|
|
.setting-select {
|
|
padding: 6px 28px 6px 10px; border-radius: var(--radius-sm);
|
|
background: var(--bg-input); color: var(--text-normal);
|
|
border: 1px solid var(--border); font-size: 13px;
|
|
appearance: none; cursor: pointer;
|
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2380848e' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
|
|
background-repeat: no-repeat; background-position: right 8px center;
|
|
min-width: 180px;
|
|
}
|
|
.setting-select:hover { border-color: var(--border-strong); }
|
|
.setting-select:focus { border-color: var(--accent); }
|
|
|
|
/* Slider */
|
|
.setting-slider {
|
|
width: 160px; height: 6px; border-radius: 3px;
|
|
background: var(--border); appearance: none; cursor: pointer;
|
|
}
|
|
.setting-slider::-webkit-slider-thumb {
|
|
appearance: none; width: 16px; height: 16px;
|
|
border-radius: 50%; background: white;
|
|
box-shadow: 0 1px 4px rgba(0,0,0,.3);
|
|
}
|
|
|
|
/* VU meter mockup */
|
|
.vu-meter {
|
|
height: 6px; border-radius: 3px; background: var(--border);
|
|
overflow: hidden; margin-top: 8px;
|
|
}
|
|
.vu-meter-fill {
|
|
height: 100%; border-radius: 3px; background: var(--green);
|
|
transition: width .1s;
|
|
}
|
|
|
|
/* Keybind capture */
|
|
.keybind-btn {
|
|
padding: 6px 14px; border-radius: var(--radius-sm);
|
|
background: var(--bg-input); border: 1px solid var(--border);
|
|
color: var(--text-normal); font-size: 13px;
|
|
font-family: var(--font-mono); cursor: pointer;
|
|
transition: border-color .2s; min-width: 100px; text-align: center;
|
|
}
|
|
.keybind-btn:hover { border-color: var(--border-strong); }
|
|
.keybind-btn.listening {
|
|
border-color: var(--accent); color: var(--accent);
|
|
animation: pulse 1s ease-in-out infinite;
|
|
}
|
|
|
|
/* Mic test */
|
|
.mic-test-btn {
|
|
padding: 8px 16px; border-radius: var(--radius-sm);
|
|
background: var(--accent); color: white; font-size: 13px;
|
|
font-weight: 600; transition: background .15s;
|
|
}
|
|
.mic-test-btn:hover { background: var(--accent-hover); }
|
|
.mic-test-btn.active { background: var(--red); }
|
|
.mic-test-btn.active:hover { background: #d83135; }
|
|
|
|
/* About section */
|
|
.about-logo { text-align: center; margin-bottom: 24px; }
|
|
.about-version {
|
|
text-align: center; font-size: 13px; color: var(--text-faint); margin-top: 8px;
|
|
}
|
|
.about-links {
|
|
display: flex; gap: 16px; justify-content: center; margin-top: 16px;
|
|
}
|
|
.about-link {
|
|
font-size: 13px; color: var(--text-link); cursor: pointer;
|
|
background: transparent; padding: 0;
|
|
}
|
|
.about-link:hover { text-decoration: underline; }
|
|
|
|
/* ═══════════════════════════════════════════
|
|
CONNECTION STATUS BAR
|
|
═══════════════════════════════════════════ */
|
|
.status-bar {
|
|
position: absolute; bottom: 0; left: 0; right: 0;
|
|
height: 4px; z-index: 50; overflow: hidden; display: none;
|
|
}
|
|
.status-bar.visible { display: block; }
|
|
.status-bar-fill {
|
|
height: 100%; background: var(--accent);
|
|
width: 0; box-shadow: 0 0 12px var(--accent-glow);
|
|
}
|
|
.status-bar.indeterminate .status-bar-fill {
|
|
width: 30%; animation: indeterminate 1.2s ease-in-out infinite;
|
|
}
|
|
@keyframes indeterminate {
|
|
0% { transform: translateX(-100%); }
|
|
100% { transform: translateX(440%); }
|
|
}
|
|
|
|
/* ═══════════════════════════════════════════
|
|
CONNECTED OVERLAY
|
|
═══════════════════════════════════════════ */
|
|
.connected-overlay {
|
|
position: fixed; inset: 0; background: var(--bg-primary);
|
|
display: none; align-items: center; justify-content: center;
|
|
flex-direction: column; gap: 12px; z-index: 200;
|
|
}
|
|
.connected-overlay.visible { display: flex; }
|
|
.connected-icon-wrap {
|
|
position: relative; margin-bottom: 4px;
|
|
}
|
|
.connected-srv-icon {
|
|
width: 72px; height: 72px; border-radius: 20px;
|
|
display: flex; align-items: center; justify-content: center;
|
|
font-size: 28px; font-weight: 700; color: white;
|
|
animation: checkPop .4s cubic-bezier(.16,1,.3,1);
|
|
}
|
|
.connected-check-badge {
|
|
position: absolute; bottom: -4px; right: -4px;
|
|
width: 28px; height: 28px; border-radius: 50%;
|
|
background: var(--green); display: flex;
|
|
align-items: center; justify-content: center;
|
|
border: 3px solid var(--bg-primary);
|
|
animation: checkPop .5s cubic-bezier(.16,1,.3,1) .1s both;
|
|
}
|
|
.connected-check-badge svg { width: 14px; height: 14px; color: white; }
|
|
@keyframes checkPop {
|
|
from { transform: scale(0); opacity: 0; }
|
|
to { transform: scale(1); opacity: 1; }
|
|
}
|
|
.connected-text { font-size: 20px; font-weight: 700; color: white; }
|
|
.connected-user { font-size: 14px; color: var(--text-muted); }
|
|
.connected-motd {
|
|
font-size: 13px; color: var(--text-faint); text-align: center;
|
|
max-width: 340px; line-height: 1.5; margin-top: 4px;
|
|
font-style: italic;
|
|
}
|
|
.connected-loader {
|
|
margin-top: 12px; display: flex; align-items: center; gap: 8px;
|
|
color: var(--text-micro); font-size: 12px;
|
|
}
|
|
.connected-loader .spinner { width: 14px; height: 14px; border-width: 1.5px; }
|
|
|
|
/* ═══ Responsive ═══ */
|
|
@media (max-width: 700px) {
|
|
.server-panel { width: 260px; }
|
|
.form-container { max-width: 340px; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<!-- ═══════════════════════════════════════════════════════
|
|
CONNECT PAGE
|
|
data-wpf-component="ConnectPage"
|
|
data-wpf-notes="Page hosted in MainWindow Frame. Split layout:
|
|
left=ServerProfileListControl, right=LoginFormControl.
|
|
ViewModel: ConnectViewModel with Profiles ObservableCollection,
|
|
SelectedProfile, IsRegisterMode, IsTotpRequired, IsLoading, ErrorMessage.
|
|
Navigation: on successful connect, navigate to MainPage.
|
|
Settings gear opens SettingsDialog window (pre-connection settings).
|
|
Handles chatserver:// URI from command-line args."
|
|
═══════════════════════════════════════════════════════ -->
|
|
<div class="connect-page" data-wpf-component="ConnectPage">
|
|
|
|
<!-- Settings gear -->
|
|
<button class="settings-gear" onclick="openSettings()" title="Settings"
|
|
data-wpf-component="SettingsButton"
|
|
data-wpf-notes="Button that opens SettingsDialog window. Allows configuring
|
|
audio devices, keybinds, appearance, and network settings before connecting.">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/>
|
|
</svg>
|
|
</button>
|
|
|
|
<!-- ═══ Left: Server Profiles ═══ -->
|
|
<div class="server-panel"
|
|
data-wpf-component="ServerProfileListControl"
|
|
data-wpf-notes="ListBox bound to Profiles ObservableCollection<ServerProfile>.
|
|
SelectedItem bound to SelectedProfile. ItemTemplate renders icon with status dot,
|
|
name, host:port, last-connected timestamp, latency badge.
|
|
Edit/Delete buttons in DataTrigger on IsMouseOver.
|
|
ServerProfile model: { Id, Name, Host, Port, LastUsername, Color,
|
|
SavedPassword (DPAPI), AutoConnect, DefaultUsername, Notes, LastConnected }.
|
|
Health check: on load, pings each server's /api/health endpoint in parallel
|
|
with 3s timeout. Updates status dot and latency badge.
|
|
Footer: Add Server + Import/Export buttons.">
|
|
|
|
<div class="server-panel-header">
|
|
<h2>Your Servers</h2>
|
|
<div class="header-actions">
|
|
<button class="header-btn" onclick="refreshAllHealth()" title="Check server status">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/>
|
|
<path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="server-list" id="serverList"><!-- Rendered by JS --></div>
|
|
|
|
<div class="protocol-tip"
|
|
data-wpf-component="ProtocolTip"
|
|
data-wpf-notes="TextBlock. chatserver:// URI handler registered by installer in
|
|
HKCR\\chatserver\\shell\\open\\command. App.xaml.cs OnStartup parses args.">
|
|
Tip: Share <code>chatserver://host:port/invite/CODE</code> links to invite friends
|
|
</div>
|
|
|
|
<div class="server-panel-footer">
|
|
<button class="btn-add-server" onclick="openAddServerModal()">
|
|
<span>+</span> Add Server
|
|
</button>
|
|
<button class="btn-footer-icon" onclick="importProfiles()" title="Import profiles"
|
|
data-wpf-component="ImportButton"
|
|
data-wpf-notes="OpenFileDialog for .json profile file. Deserializes
|
|
List<ServerProfile>, merges by host+port, persists via IProfileService.">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>
|
|
</svg>
|
|
</button>
|
|
<button class="btn-footer-icon" onclick="exportProfiles()" title="Export profiles"
|
|
data-wpf-component="ExportButton"
|
|
data-wpf-notes="SaveFileDialog for .json. Serializes current profiles list.">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══ Right: Login / Register / 2FA ═══ -->
|
|
<div class="form-panel"
|
|
data-wpf-component="LoginFormControl"
|
|
data-wpf-notes="ContentControl with DataTemplateSelector choosing between:
|
|
LoginTemplate (mode='login'|'register'), TotpTemplate (mode='totp'),
|
|
BackupCodeTemplate (mode='backup'). Bound to ConnectViewModel.
|
|
2FA flow: login returns {requires_2fa:true, partial_token:'...'} →
|
|
switch to TotpTemplate → POST /api/auth/verify-totp with partial_token + code.">
|
|
<div class="form-container" id="formContainer"><!-- Rendered by JS --></div>
|
|
</div>
|
|
|
|
<!-- Status bar -->
|
|
<div class="status-bar" id="statusBar">
|
|
<div class="status-bar-fill" id="statusBarFill"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══ Server Add/Edit Modal ═══ -->
|
|
<div class="modal-overlay" id="serverModal"
|
|
data-wpf-component="ServerProfileDialog"
|
|
data-wpf-notes="Window or ContentDialog. Bound to EditingProfile.
|
|
Fields: Name, Host, Port, Color, DefaultUsername, AutoConnect, Notes.
|
|
OK saves to Profiles collection and persists via IServerProfileService.">
|
|
<div class="modal">
|
|
<div class="modal-header">
|
|
<h3 id="modalTitle">Add Server</h3>
|
|
<button class="modal-close" onclick="closeModal()">×</button>
|
|
</div>
|
|
<div class="modal-body" id="modalBody"><!-- Rendered by JS --></div>
|
|
<div class="modal-footer">
|
|
<button class="btn-cancel" onclick="closeModal()">Cancel</button>
|
|
<button class="btn-modal-save" id="modalSaveBtn" onclick="saveServerProfile()">Save</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══ Delete Confirm Modal ═══ -->
|
|
<div class="modal-overlay" id="deleteModal">
|
|
<div class="modal" style="width:380px">
|
|
<div class="modal-header">
|
|
<h3>Delete Server</h3>
|
|
<button class="modal-close" onclick="closeDeleteModal()">×</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p class="modal-danger-text" id="deleteText"></p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn-cancel" onclick="closeDeleteModal()">Cancel</button>
|
|
<button class="btn-danger" onclick="confirmDelete()">Delete</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══ Certificate Trust Dialog ═══ -->
|
|
<div class="modal-overlay" id="certModal"
|
|
data-wpf-component="CertificateTrustDialog"
|
|
data-wpf-notes="Window shown from HttpClientHandler.ServerCertificateCustomValidationCallback.
|
|
Displays cert Subject, Issuer, SHA-256 fingerprint, validity dates.
|
|
Trust: saves fingerprint to trusted_certs.json (TOFU pattern).
|
|
Connect Once: allows this connection only.
|
|
Cancel: aborts connection.">
|
|
<div class="modal" style="width:480px">
|
|
<div class="modal-body" id="certBody"><!-- Rendered by JS --></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══ Connected Overlay ═══ -->
|
|
<div class="connected-overlay" id="connectedOverlay"
|
|
data-wpf-component="ConnectedTransition"
|
|
data-wpf-notes="Overlay shown after successful auth_ok WebSocket response.
|
|
Displays server icon, server name, 'Logged in as username', MOTD.
|
|
Auto-transitions to MainPage after 2s delay.">
|
|
<div class="connected-icon-wrap">
|
|
<div class="connected-srv-icon" id="connectedSrvIcon" style="background:var(--accent)">O</div>
|
|
<div class="connected-check-badge">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
|
|
<polyline points="20 6 9 17 4 12"/>
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
<div class="connected-text" id="connectedText">Connected!</div>
|
|
<div class="connected-user" id="connectedUser">Logged in as LordJebus</div>
|
|
<div class="connected-motd" id="connectedMotd"></div>
|
|
<div class="connected-loader">
|
|
<div class="spinner"></div>
|
|
<span>Loading server data...</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══ Settings Overlay ═══ -->
|
|
<div class="settings-overlay" id="settingsOverlay"
|
|
data-wpf-component="SettingsDialog"
|
|
data-wpf-notes="Window with tabbed left navigation. Bound to SettingsViewModel.
|
|
Audio: NAudio CoreAudioApi MMDeviceEnumerator for device lists.
|
|
Keybinds: SetWindowsHookEx for key capture.
|
|
Settings persisted to settings.json in app data directory.
|
|
Pre-connection: accessible before connecting to any server.">
|
|
<button class="settings-close" onclick="closeSettings()" title="Close (Esc)">×</button>
|
|
<div class="settings-layout">
|
|
<nav class="settings-nav" id="settingsNav"><!-- Rendered by JS --></nav>
|
|
<div class="settings-content" id="settingsContent"><!-- Rendered by JS --></div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
/* ═══════════════════════════════════════════
|
|
CONSTANTS
|
|
═══════════════════════════════════════════ */
|
|
const ACCENT_COLORS = ['#5865f2','#57f287','#fee75c','#eb459e','#ed4245','#f47b67','#e67e22','#9b59b6','#1abc9c'];
|
|
const CHECK_SVG = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="2 6 5 9 10 3"/></svg>';
|
|
|
|
/* ═══════════════════════════════════════════
|
|
MOCK DATA
|
|
═══════════════════════════════════════════ */
|
|
const SAVED_SERVERS = [
|
|
{ id: 1, name: 'Home Server', host: '192.168.1.100', port: 8443, lastUser: 'LordJebus', color: '#5865f2', savedPass: true, autoConnect: true, defaultUser: 'LordJebus', notes: 'Main server at home', lastConnected: '2 hours ago' },
|
|
{ id: 2, name: 'Dev Team', host: 'dev.owncord.local', port: 8443, lastUser: 'LordJebus', color: '#57f287', savedPass: false, autoConnect: false, defaultUser: 'LordJebus', notes: '', lastConnected: 'Yesterday' },
|
|
{ id: 3, name: 'Gaming Squad', host: '10.0.0.50', port: 9443, lastUser: 'LordJebus', color: '#eb459e', savedPass: true, autoConnect: false, defaultUser: 'LordJebus', notes: 'Port forwarded on router', lastConnected: '3 days ago' },
|
|
];
|
|
|
|
/* Simulated health results */
|
|
const HEALTH_RESULTS = {
|
|
1: { status: 'online', latency: 12 },
|
|
2: { status: 'online', latency: 45 },
|
|
3: { status: 'offline', latency: null },
|
|
};
|
|
|
|
/* ═══════════════════════════════════════════
|
|
STATE
|
|
═══════════════════════════════════════════ */
|
|
const state = {
|
|
servers: SAVED_SERVERS.map(s => ({...s})),
|
|
health: {...HEALTH_RESULTS},
|
|
selectedId: 1,
|
|
mode: 'login', // 'login' | 'register' | 'totp' | 'backup'
|
|
loading: false,
|
|
error: null,
|
|
success: null,
|
|
showPassword: false,
|
|
savePassword: true,
|
|
|
|
// Form fields
|
|
host: '192.168.1.100',
|
|
port: '8443',
|
|
username: 'LordJebus',
|
|
password: '',
|
|
inviteCode: '',
|
|
totpCode: ['','','','','',''],
|
|
backupCode: '',
|
|
|
|
// Modal state
|
|
editingServer: null,
|
|
deleteTarget: null,
|
|
modalName: '',
|
|
modalHost: '',
|
|
modalPort: '8443',
|
|
modalColor: '#5865f2',
|
|
modalDefaultUser: '',
|
|
modalAutoConnect: false,
|
|
modalNotes: '',
|
|
|
|
// Settings
|
|
settingsOpen: false,
|
|
settingsTab: 'audio',
|
|
micTesting: false,
|
|
vuLevel: 0,
|
|
listeningKeybind: null,
|
|
|
|
// Settings values
|
|
inputDevice: 'Default - Microphone (Realtek)',
|
|
outputDevice: 'Default - Speakers (Realtek)',
|
|
inputVolume: 80,
|
|
outputVolume: 100,
|
|
voiceMode: 'voice', // 'voice' | 'ptt'
|
|
pttKey: 'V',
|
|
noiseSuppression: true,
|
|
muteKey: 'M',
|
|
deafenKey: 'D',
|
|
uiScale: 100,
|
|
compactMode: false,
|
|
connTimeout: 10,
|
|
autoReconnect: true,
|
|
};
|
|
|
|
/* ═══════════════════════════════════════════
|
|
SVG HELPERS
|
|
═══════════════════════════════════════════ */
|
|
const SVG = {
|
|
edit: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>',
|
|
trash: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>',
|
|
};
|
|
|
|
/* ═══════════════════════════════════════════
|
|
RENDER: Server List
|
|
═══════════════════════════════════════════ */
|
|
function renderServerList() {
|
|
const list = document.getElementById('serverList');
|
|
|
|
if (state.servers.length === 0) {
|
|
list.innerHTML = `
|
|
<div class="server-empty">
|
|
<div class="server-empty-icon">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
<rect x="2" y="2" width="20" height="8" rx="2"/><rect x="2" y="14" width="20" height="8" rx="2"/>
|
|
<circle cx="6" cy="6" r="1"/><circle cx="6" cy="18" r="1"/>
|
|
</svg>
|
|
</div>
|
|
<h3>No saved servers</h3>
|
|
<p>Add a server to get started, or use a <code>chatserver://</code> invite link</p>
|
|
</div>`;
|
|
return;
|
|
}
|
|
|
|
list.innerHTML = state.servers.map(s => {
|
|
const h = state.health[s.id] || { status: 'unknown', latency: null };
|
|
const statusClass = h.status === 'checking' ? 'checking' : h.status;
|
|
let latencyHtml = '';
|
|
if (h.latency !== null) {
|
|
const cls = h.latency < 100 ? 'good' : h.latency < 300 ? 'warn' : 'bad';
|
|
latencyHtml = `<span class="srv-latency ${cls}">${h.latency}ms</span>`;
|
|
}
|
|
return `
|
|
<div class="server-item ${s.id === state.selectedId ? 'active' : ''}"
|
|
onclick="selectServer(${s.id})">
|
|
<div class="srv-icon" style="background:${s.color}">
|
|
${s.name.charAt(0).toUpperCase()}
|
|
<div class="srv-status-dot ${statusClass}"></div>
|
|
</div>
|
|
<div class="srv-info">
|
|
<div class="srv-name">${esc(s.name)}${s.autoConnect ? '<span class="srv-auto" title="Auto-connect on startup">AUTO</span>' : ''}</div>
|
|
<div class="srv-meta">
|
|
<span class="srv-host">${esc(s.host)}:${s.port}</span>
|
|
${latencyHtml}
|
|
</div>
|
|
${s.lastConnected ? `<div class="srv-last">${esc(s.lastConnected)}</div>` : ''}
|
|
</div>
|
|
<div class="srv-actions">
|
|
<button class="srv-btn" onclick="event.stopPropagation(); openEditServerModal(${s.id})" title="Edit">${SVG.edit}</button>
|
|
<button class="srv-btn danger" onclick="event.stopPropagation(); openDeleteModal(${s.id})" title="Delete">${SVG.trash}</button>
|
|
</div>
|
|
</div>`;
|
|
}).join('');
|
|
}
|
|
|
|
/* ═══════════════════════════════════════════
|
|
RENDER: Login / Register / 2FA Form
|
|
═══════════════════════════════════════════ */
|
|
function renderForm() {
|
|
const c = document.getElementById('formContainer');
|
|
if (state.mode === 'totp') return renderTotpForm(c);
|
|
if (state.mode === 'backup') return renderBackupForm(c);
|
|
|
|
const isLogin = state.mode === 'login';
|
|
c.innerHTML = `
|
|
<div class="form-logo">
|
|
<div class="form-logo-mark">
|
|
<svg viewBox="0 0 24 24" fill="white">
|
|
<path d="M12 2L4 5.5v5c0 5.25 3.4 10.15 8 11.5 4.6-1.35 8-6.25 8-11.5v-5L12 2zm0 3l1.5 3h3.2l-2.6 1.9 1 3.1L12 11.1 8.9 13l1-3.1L7.3 8h3.2L12 5z"/>
|
|
</svg>
|
|
</div>
|
|
<h1>OwnCord</h1>
|
|
<p>${isLogin ? 'Welcome back!' : 'Create an account'}</p>
|
|
</div>
|
|
|
|
<div class="error-banner ${state.error ? 'visible' : ''}">
|
|
<span class="error-banner-icon">⚠</span>
|
|
<span class="error-banner-text">${state.error || ''}</span>
|
|
</div>
|
|
<div class="success-banner ${state.success ? 'visible' : ''}">
|
|
<span class="success-banner-icon">✓</span>
|
|
<span class="success-banner-text">${state.success || ''}</span>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label class="form-label">Server Address <span class="required">*</span></label>
|
|
<input class="form-input" type="text" id="hostInput"
|
|
value="${esc(state.host)}" placeholder="192.168.1.100 or my.server.com"
|
|
oninput="state.host=this.value; clearError()">
|
|
</div>
|
|
<div class="form-group port-field">
|
|
<label class="form-label">Port</label>
|
|
<input class="form-input" type="text" id="portInput"
|
|
value="${esc(state.port)}" placeholder="8443"
|
|
oninput="state.port=this.value; clearError()">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">Username <span class="required">*</span></label>
|
|
<input class="form-input" type="text" id="usernameInput"
|
|
value="${esc(state.username)}" placeholder="Enter your username"
|
|
oninput="state.username=this.value; clearError()">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">Password <span class="required">*</span></label>
|
|
<div class="password-wrapper">
|
|
<input class="form-input" type="${state.showPassword ? 'text' : 'password'}" id="passwordInput"
|
|
value="${esc(state.password)}" placeholder="Enter your password"
|
|
oninput="state.password=this.value; clearError()"
|
|
onkeydown="if(event.key==='Enter')connect()">
|
|
<button class="password-toggle" onclick="togglePasswordVisibility()"
|
|
title="${state.showPassword ? 'Hide' : 'Show'} password">
|
|
${state.showPassword ? '👁' : '👀'}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
${!isLogin ? `
|
|
<div class="form-group">
|
|
<label class="form-label">Invite Code <span class="required">*</span></label>
|
|
<input class="form-input" type="text" id="inviteInput"
|
|
value="${esc(state.inviteCode)}" placeholder="Enter your invite code"
|
|
oninput="state.inviteCode=this.value; clearError()">
|
|
</div>` : ''}
|
|
|
|
<label class="form-checkbox" onclick="toggleSavePassword()">
|
|
<input type="checkbox" ${state.savePassword ? 'checked' : ''}>
|
|
<div class="checkbox-box">${CHECK_SVG}</div>
|
|
<span class="checkbox-label">Remember my password</span>
|
|
</label>
|
|
|
|
<button class="btn-primary ${state.loading ? 'loading' : ''}" onclick="connect()" ${state.loading ? 'disabled' : ''}>
|
|
<span class="btn-text">${isLogin ? 'Log In' : 'Register'}</span>
|
|
<div class="btn-spinner"><div class="spinner"></div></div>
|
|
</button>
|
|
|
|
<div class="form-switch">
|
|
${isLogin
|
|
? `Need an account? <a onclick="switchMode('register')">Register</a>`
|
|
: `Already have an account? <a onclick="switchMode('login')">Log In</a>`}
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
function renderTotpForm(c) {
|
|
c.innerHTML = `
|
|
<div class="totp-icon">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>
|
|
</svg>
|
|
</div>
|
|
<div class="totp-title">Two-Factor Authentication</div>
|
|
<div class="totp-subtitle">Enter the 6-digit code from your authenticator app</div>
|
|
|
|
<div class="error-banner ${state.error ? 'visible' : ''}">
|
|
<span class="error-banner-icon">⚠</span>
|
|
<span class="error-banner-text">${state.error || ''}</span>
|
|
</div>
|
|
|
|
<div class="totp-inputs">
|
|
${[0,1,2,3,4,5].map(i => `
|
|
<input class="totp-digit ${state.totpCode[i] ? 'filled' : ''}" type="text" maxlength="1"
|
|
id="totp${i}" value="${state.totpCode[i]}"
|
|
oninput="handleTotpInput(${i}, this)"
|
|
onkeydown="handleTotpKeydown(${i}, event)"
|
|
onpaste="${i === 0 ? 'handleTotpPaste(event)' : ''}"
|
|
autocomplete="off">
|
|
`).join('')}
|
|
</div>
|
|
|
|
<button class="btn-primary ${state.loading ? 'loading' : ''}" onclick="verifyTotp()" ${state.loading ? 'disabled' : ''}>
|
|
<span class="btn-text">Verify</span>
|
|
<div class="btn-spinner"><div class="spinner"></div></div>
|
|
</button>
|
|
|
|
<a class="totp-backup-link" onclick="switchMode('backup')">Use a backup code instead</a>
|
|
<a class="totp-back" onclick="switchMode('login')">Back to login</a>
|
|
`;
|
|
// Focus first empty digit
|
|
setTimeout(() => {
|
|
const firstEmpty = state.totpCode.findIndex(d => !d);
|
|
const el = document.getElementById('totp' + (firstEmpty >= 0 ? firstEmpty : 5));
|
|
if (el) el.focus();
|
|
}, 100);
|
|
}
|
|
|
|
function renderBackupForm(c) {
|
|
c.innerHTML = `
|
|
<div class="totp-icon">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.78 7.78 5.5 5.5 0 0 1 7.78-7.78zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"/>
|
|
</svg>
|
|
</div>
|
|
<div class="totp-title">Backup Code</div>
|
|
<div class="totp-subtitle">Enter one of your 8-digit backup codes</div>
|
|
|
|
<div class="error-banner ${state.error ? 'visible' : ''}">
|
|
<span class="error-banner-icon">⚠</span>
|
|
<span class="error-banner-text">${state.error || ''}</span>
|
|
</div>
|
|
|
|
<div class="form-group" style="margin-bottom:24px">
|
|
<input class="form-input" type="text" id="backupInput" style="text-align:center;font-family:var(--font-mono);font-size:18px;letter-spacing:4px"
|
|
value="${esc(state.backupCode)}" placeholder="XXXX-XXXX"
|
|
oninput="state.backupCode=this.value; clearError()"
|
|
onkeydown="if(event.key==='Enter')verifyBackup()"
|
|
maxlength="9" autocomplete="off">
|
|
</div>
|
|
|
|
<button class="btn-primary ${state.loading ? 'loading' : ''}" onclick="verifyBackup()" ${state.loading ? 'disabled' : ''}>
|
|
<span class="btn-text">Verify</span>
|
|
<div class="btn-spinner"><div class="spinner"></div></div>
|
|
</button>
|
|
|
|
<a class="totp-back" onclick="switchMode('totp')" style="margin-top:16px">Use authenticator app instead</a>
|
|
<a class="totp-back" onclick="switchMode('login')">Back to login</a>
|
|
`;
|
|
setTimeout(() => { const el = document.getElementById('backupInput'); if (el) el.focus(); }, 100);
|
|
}
|
|
|
|
/* ═══════════════════════════════════════════
|
|
RENDER: Settings
|
|
═══════════════════════════════════════════ */
|
|
const SETTINGS_TABS = [
|
|
{ section: 'App Settings' },
|
|
{ id: 'audio', label: 'Audio', icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>' },
|
|
{ id: 'appearance', label: 'Appearance', icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>' },
|
|
{ id: 'keybinds', label: 'Keybinds', icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10"/></svg>' },
|
|
{ id: 'network', label: 'Network', icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>' },
|
|
{ sep: true },
|
|
{ id: 'about', label: 'About', icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>' },
|
|
];
|
|
|
|
function renderSettingsNav() {
|
|
const nav = document.getElementById('settingsNav');
|
|
nav.innerHTML = SETTINGS_TABS.map(t => {
|
|
if (t.section) return `<div class="settings-nav-title">${t.section}</div>`;
|
|
if (t.sep) return `<div class="settings-nav-sep"></div>`;
|
|
return `<button class="settings-nav-item ${state.settingsTab === t.id ? 'active' : ''}"
|
|
onclick="switchSettingsTab('${t.id}')">
|
|
${t.icon}<span>${t.label}</span>
|
|
</button>`;
|
|
}).join('');
|
|
}
|
|
|
|
function renderSettingsContent() {
|
|
const c = document.getElementById('settingsContent');
|
|
const tab = state.settingsTab;
|
|
|
|
if (tab === 'audio') {
|
|
c.innerHTML = `
|
|
<div class="settings-section-title"
|
|
data-wpf-component="AudioSettingsTab"
|
|
data-wpf-notes="Bound to SettingsViewModel audio properties.
|
|
Device dropdowns populated by NAudio MMDeviceEnumerator.
|
|
Volume sliders bound to InputVolume/OutputVolume (0-100).
|
|
VoiceMode: RadioButtons for VoiceActivity vs PushToTalk.
|
|
Mic test: starts NAudio WaveIn recording and displays RMS level.">
|
|
Audio Settings
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Input Device</div>
|
|
<div class="setting-desc">Microphone used for voice chat</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<select class="setting-select" onchange="state.inputDevice=this.value">
|
|
<option ${state.inputDevice.includes('Realtek') ? 'selected' : ''}>Default - Microphone (Realtek)</option>
|
|
<option>Microphone (Blue Yeti)</option>
|
|
<option>Headset Microphone (USB)</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Input Volume</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<input type="range" class="setting-slider" min="0" max="100" value="${state.inputVolume}"
|
|
oninput="state.inputVolume=this.value">
|
|
<span style="font-size:12px;color:var(--text-faint);margin-left:8px">${state.inputVolume}%</span>
|
|
</div>
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Output Device</div>
|
|
<div class="setting-desc">Speakers or headphones for audio playback</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<select class="setting-select" onchange="state.outputDevice=this.value">
|
|
<option ${state.outputDevice.includes('Realtek') ? 'selected' : ''}>Default - Speakers (Realtek)</option>
|
|
<option>Headphones (HyperX Cloud)</option>
|
|
<option>Speakers (USB DAC)</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Output Volume</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<input type="range" class="setting-slider" min="0" max="100" value="${state.outputVolume}"
|
|
oninput="state.outputVolume=this.value">
|
|
<span style="font-size:12px;color:var(--text-faint);margin-left:8px">${state.outputVolume}%</span>
|
|
</div>
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Voice Mode</div>
|
|
<div class="setting-desc">Voice Activity detects when you speak. Push-to-Talk requires holding a key.</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<select class="setting-select" onchange="state.voiceMode=this.value" style="min-width:140px">
|
|
<option value="voice" ${state.voiceMode==='voice'?'selected':''}>Voice Activity</option>
|
|
<option value="ptt" ${state.voiceMode==='ptt'?'selected':''}>Push to Talk</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Noise Suppression</div>
|
|
<div class="setting-desc">Reduce background noise from your microphone</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<div class="toggle ${state.noiseSuppression?'on':''}" onclick="state.noiseSuppression=!state.noiseSuppression; renderSettingsContent()"></div>
|
|
</div>
|
|
</div>
|
|
<div class="setting-row" style="flex-direction:column;align-items:stretch">
|
|
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:8px">
|
|
<div class="setting-label">Microphone Test</div>
|
|
<button class="mic-test-btn ${state.micTesting?'active':''}" onclick="toggleMicTest()">
|
|
${state.micTesting ? 'Stop Test' : 'Test Mic'}
|
|
</button>
|
|
</div>
|
|
<div class="vu-meter"><div class="vu-meter-fill" id="vuFill" style="width:${state.vuLevel}%"></div></div>
|
|
</div>
|
|
`;
|
|
} else if (tab === 'appearance') {
|
|
c.innerHTML = `
|
|
<div class="settings-section-title"
|
|
data-wpf-component="AppearanceSettingsTab"
|
|
data-wpf-notes="Bound to SettingsViewModel. Theme: dark only for now.
|
|
UIScale: Slider 75-150, applies LayoutTransform ScaleTransform to root.
|
|
CompactMode: toggles compact message display DataTemplate.">
|
|
Appearance
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Theme</div>
|
|
<div class="setting-desc">Currently dark mode only</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<select class="setting-select" style="min-width:120px" disabled>
|
|
<option selected>Dark</option>
|
|
<option>Light (coming soon)</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">UI Scale</div>
|
|
<div class="setting-desc">Adjust the size of UI elements (${state.uiScale}%)</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<input type="range" class="setting-slider" min="75" max="150" step="5" value="${state.uiScale}"
|
|
oninput="state.uiScale=parseInt(this.value); renderSettingsContent()">
|
|
<span style="font-size:12px;color:var(--text-faint);margin-left:8px">${state.uiScale}%</span>
|
|
</div>
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Compact Mode</div>
|
|
<div class="setting-desc">Reduce spacing between messages</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<div class="toggle ${state.compactMode?'on':''}" onclick="state.compactMode=!state.compactMode; renderSettingsContent()"></div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
} else if (tab === 'keybinds') {
|
|
c.innerHTML = `
|
|
<div class="settings-section-title"
|
|
data-wpf-component="KeybindsSettingsTab"
|
|
data-wpf-notes="Each keybind: Button that enters 'listening' state on click.
|
|
Uses SetWindowsHookEx (low-level keyboard hook) to capture the next
|
|
keypress. Stores key name in settings. ESC cancels listening.">
|
|
Keybinds
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Push to Talk</div>
|
|
<div class="setting-desc">Hold this key to transmit voice</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<button class="keybind-btn ${state.listeningKeybind==='ptt'?'listening':''}"
|
|
onclick="startListeningKeybind('ptt')">
|
|
${state.listeningKeybind==='ptt' ? 'Press a key...' : state.pttKey}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Toggle Mute</div>
|
|
<div class="setting-desc">Mute or unmute your microphone</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<button class="keybind-btn ${state.listeningKeybind==='mute'?'listening':''}"
|
|
onclick="startListeningKeybind('mute')">
|
|
${state.listeningKeybind==='mute' ? 'Press a key...' : 'Ctrl+' + state.muteKey}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Toggle Deafen</div>
|
|
<div class="setting-desc">Deafen or undeafen audio output</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<button class="keybind-btn ${state.listeningKeybind==='deafen'?'listening':''}"
|
|
onclick="startListeningKeybind('deafen')">
|
|
${state.listeningKeybind==='deafen' ? 'Press a key...' : 'Ctrl+' + state.deafenKey}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
`;
|
|
} else if (tab === 'network') {
|
|
c.innerHTML = `
|
|
<div class="settings-section-title"
|
|
data-wpf-component="NetworkSettingsTab"
|
|
data-wpf-notes="ConnTimeout: Slider 5-30s, used by HttpClient.Timeout and
|
|
WebSocket connect timeout. AutoReconnect: bool, if true reconnects on
|
|
disconnect with exponential backoff (1s, 2s, 4s, max 30s).">
|
|
Network
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Connection Timeout</div>
|
|
<div class="setting-desc">How long to wait before giving up (${state.connTimeout}s)</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<input type="range" class="setting-slider" min="5" max="30" step="1" value="${state.connTimeout}"
|
|
oninput="state.connTimeout=parseInt(this.value); renderSettingsContent()">
|
|
<span style="font-size:12px;color:var(--text-faint);margin-left:8px">${state.connTimeout}s</span>
|
|
</div>
|
|
</div>
|
|
<div class="setting-row">
|
|
<div class="setting-info">
|
|
<div class="setting-label">Auto-Reconnect</div>
|
|
<div class="setting-desc">Automatically reconnect if disconnected</div>
|
|
</div>
|
|
<div class="setting-control">
|
|
<div class="toggle ${state.autoReconnect?'on':''}" onclick="state.autoReconnect=!state.autoReconnect; renderSettingsContent()"></div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
} else if (tab === 'about') {
|
|
c.innerHTML = `
|
|
<div class="settings-section-title">About OwnCord</div>
|
|
<div class="about-logo">
|
|
<div class="form-logo-mark" style="margin:0 auto 12px">
|
|
<svg viewBox="0 0 24 24" fill="white">
|
|
<path d="M12 2L4 5.5v5c0 5.25 3.4 10.15 8 11.5 4.6-1.35 8-6.25 8-11.5v-5L12 2zm0 3l1.5 3h3.2l-2.6 1.9 1 3.1L12 11.1 8.9 13l1-3.1L7.3 8h3.2L12 5z"/>
|
|
</svg>
|
|
</div>
|
|
<div style="font-size:22px;font-weight:700;color:white">OwnCord</div>
|
|
<div class="about-version">Version 1.0.0-dev</div>
|
|
</div>
|
|
<div class="about-links">
|
|
<button class="about-link">Documentation</button>
|
|
<button class="about-link">Source Code</button>
|
|
<button class="about-link">Report Bug</button>
|
|
</div>
|
|
<div style="text-align:center;margin-top:24px;font-size:12px;color:var(--text-micro)">
|
|
Self-hosted chat platform<br>No data leaves your network
|
|
</div>
|
|
`;
|
|
}
|
|
}
|
|
|
|
/* ═══════════════════════════════════════════
|
|
RENDER ALL
|
|
═══════════════════════════════════════════ */
|
|
function renderAll() {
|
|
renderServerList();
|
|
renderForm();
|
|
}
|
|
|
|
/* ═══════════════════════════════════════════
|
|
ACTIONS: Server Selection & Connection
|
|
═══════════════════════════════════════════ */
|
|
function selectServer(id) {
|
|
const srv = state.servers.find(s => s.id === id);
|
|
if (!srv) return;
|
|
state.selectedId = id;
|
|
state.host = srv.host;
|
|
state.port = String(srv.port);
|
|
state.username = srv.defaultUser || srv.lastUser;
|
|
state.password = srv.savedPass ? '\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022' : '';
|
|
state.savePassword = srv.savedPass;
|
|
state.mode = 'login';
|
|
clearError();
|
|
renderAll();
|
|
}
|
|
|
|
function switchMode(mode) {
|
|
state.mode = mode;
|
|
state.error = null;
|
|
state.success = null;
|
|
state.totpCode = ['','','','','',''];
|
|
state.backupCode = '';
|
|
renderForm();
|
|
}
|
|
|
|
function togglePasswordVisibility() {
|
|
state.showPassword = !state.showPassword;
|
|
renderForm();
|
|
const input = document.getElementById('passwordInput');
|
|
if (input) { input.focus(); input.setSelectionRange(input.value.length, input.value.length); }
|
|
}
|
|
|
|
function toggleSavePassword() { state.savePassword = !state.savePassword; }
|
|
|
|
function clearError() {
|
|
state.error = null;
|
|
state.success = null;
|
|
}
|
|
|
|
function connect() {
|
|
if (!state.host.trim()) return showError('Server address is required.');
|
|
if (!state.username.trim()) return showError('Username is required.');
|
|
if (!state.password.trim()) return showError('Password is required.');
|
|
if (state.mode === 'register' && !state.inviteCode.trim()) return showError('Invite code is required for registration.');
|
|
|
|
state.loading = true;
|
|
state.error = null;
|
|
renderForm();
|
|
showStatusBar();
|
|
|
|
setTimeout(() => {
|
|
state.loading = false;
|
|
hideStatusBar();
|
|
|
|
const roll = Math.random();
|
|
if (roll < 0.10) {
|
|
// Simulate certificate trust needed
|
|
showCertDialog();
|
|
renderForm();
|
|
} else if (roll < 0.20) {
|
|
showError('Connection refused. Is the server running?');
|
|
renderForm();
|
|
} else if (roll < 0.30 && state.mode === 'login') {
|
|
// Simulate 2FA required
|
|
state.mode = 'totp';
|
|
state.totpCode = ['','','','','',''];
|
|
renderForm();
|
|
} else if (roll < 0.35) {
|
|
showError('Invalid username or password.');
|
|
renderForm();
|
|
} else {
|
|
showConnected();
|
|
}
|
|
}, 1500 + Math.random() * 1000);
|
|
}
|
|
|
|
function showError(msg) {
|
|
state.error = msg;
|
|
state.success = null;
|
|
renderForm();
|
|
}
|
|
|
|
function showStatusBar() {
|
|
document.getElementById('statusBar').classList.add('visible', 'indeterminate');
|
|
}
|
|
function hideStatusBar() {
|
|
document.getElementById('statusBar').classList.remove('visible', 'indeterminate');
|
|
}
|
|
|
|
/* ═══ 2FA ═══ */
|
|
function handleTotpInput(i, el) {
|
|
const val = el.value.replace(/\D/g, '');
|
|
el.value = val;
|
|
state.totpCode[i] = val;
|
|
if (val && i < 5) {
|
|
document.getElementById('totp' + (i + 1)).focus();
|
|
}
|
|
// Auto-submit when all 6 filled
|
|
if (state.totpCode.every(d => d)) {
|
|
setTimeout(verifyTotp, 200);
|
|
}
|
|
}
|
|
|
|
function handleTotpKeydown(i, e) {
|
|
if (e.key === 'Backspace' && !state.totpCode[i] && i > 0) {
|
|
state.totpCode[i - 1] = '';
|
|
document.getElementById('totp' + (i - 1)).focus();
|
|
}
|
|
}
|
|
|
|
function handleTotpPaste(e) {
|
|
e.preventDefault();
|
|
const text = (e.clipboardData || window.clipboardData).getData('text').replace(/\D/g, '').slice(0, 6);
|
|
for (let i = 0; i < 6; i++) {
|
|
state.totpCode[i] = text[i] || '';
|
|
}
|
|
renderForm();
|
|
if (text.length === 6) setTimeout(verifyTotp, 200);
|
|
}
|
|
|
|
function verifyTotp() {
|
|
const code = state.totpCode.join('');
|
|
if (code.length < 6) return showError('Please enter all 6 digits.');
|
|
state.loading = true;
|
|
renderForm();
|
|
showStatusBar();
|
|
setTimeout(() => {
|
|
state.loading = false;
|
|
hideStatusBar();
|
|
if (Math.random() < 0.2) {
|
|
showError('Invalid code. Please try again.');
|
|
state.totpCode = ['','','','','',''];
|
|
renderForm();
|
|
} else {
|
|
showConnected();
|
|
}
|
|
}, 1000);
|
|
}
|
|
|
|
function verifyBackup() {
|
|
if (!state.backupCode.trim()) return showError('Please enter a backup code.');
|
|
state.loading = true;
|
|
renderForm();
|
|
showStatusBar();
|
|
setTimeout(() => {
|
|
state.loading = false;
|
|
hideStatusBar();
|
|
showConnected();
|
|
}, 1000);
|
|
}
|
|
|
|
/* ═══ Certificate Trust ═══ */
|
|
function showCertDialog() {
|
|
const body = document.getElementById('certBody');
|
|
body.innerHTML = `
|
|
<div class="cert-warning">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>
|
|
<line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/>
|
|
</svg>
|
|
</div>
|
|
<div class="cert-title">Untrusted Certificate</div>
|
|
<div class="cert-desc">The server at <strong>${esc(state.host)}:${esc(state.port)}</strong> presented a certificate that is not trusted by your system.</div>
|
|
<div class="cert-details">
|
|
<div class="cert-row"><span class="cert-label">Subject</span><span class="cert-value">CN=${esc(state.host)}</span></div>
|
|
<div class="cert-row"><span class="cert-label">Issuer</span><span class="cert-value">CN=OwnCord Self-Signed CA</span></div>
|
|
<div class="cert-row"><span class="cert-label">Valid</span><span class="cert-value">2026-01-01 to 2027-01-01</span></div>
|
|
<div class="cert-row"><span class="cert-label">SHA-256</span><span class="cert-value cert-fingerprint">A3:4B:7C:D2:E5:F8:9A:1B:3C:D4:E6:F7:08:19:2A:3B:4C:5D:6E:7F:80:91:A2:B3:C4:D5:E6:F7:08:19:2A:3B</span></div>
|
|
</div>
|
|
<label class="form-checkbox" onclick="event.stopPropagation()">
|
|
<input type="checkbox" checked>
|
|
<div class="checkbox-box">${CHECK_SVG}</div>
|
|
<span class="checkbox-label">Always trust certificates from this server</span>
|
|
</label>
|
|
<div class="cert-actions">
|
|
<button class="btn-primary" style="width:auto;padding:10px 24px" onclick="trustCert()">Trust This Certificate</button>
|
|
<button class="btn-ghost" onclick="trustOnce()">Connect Once</button>
|
|
<button class="btn-cancel" onclick="closeCertDialog()">Cancel</button>
|
|
</div>
|
|
`;
|
|
document.getElementById('certModal').classList.add('visible');
|
|
}
|
|
|
|
function trustCert() { closeCertDialog(); showConnected(); }
|
|
function trustOnce() { closeCertDialog(); showConnected(); }
|
|
function closeCertDialog() { document.getElementById('certModal').classList.remove('visible'); }
|
|
|
|
/* ═══ Connected Overlay ═══ */
|
|
function showConnected() {
|
|
const srv = state.servers.find(s => s.id === state.selectedId);
|
|
const overlay = document.getElementById('connectedOverlay');
|
|
const srvIcon = document.getElementById('connectedSrvIcon');
|
|
|
|
if (srv) {
|
|
srvIcon.style.background = srv.color;
|
|
srvIcon.textContent = srv.name.charAt(0).toUpperCase();
|
|
document.getElementById('connectedText').textContent = srv.name;
|
|
} else {
|
|
srvIcon.style.background = 'var(--accent)';
|
|
srvIcon.textContent = state.host.charAt(0).toUpperCase();
|
|
document.getElementById('connectedText').textContent = state.host;
|
|
}
|
|
document.getElementById('connectedUser').textContent = 'Logged in as ' + state.username;
|
|
document.getElementById('connectedMotd').textContent = 'Welcome! This server is running OwnCord v1.0.0.';
|
|
|
|
overlay.classList.add('visible');
|
|
|
|
setTimeout(() => {
|
|
overlay.classList.remove('visible');
|
|
state.success = 'Connected successfully! (In real app, navigates to MainPage)';
|
|
state.mode = 'login';
|
|
renderForm();
|
|
}, 2500);
|
|
}
|
|
|
|
/* ═══ Server Profile Management ═══ */
|
|
function openAddServerModal() {
|
|
state.editingServer = null;
|
|
state.modalName = '';
|
|
state.modalHost = '';
|
|
state.modalPort = '8443';
|
|
state.modalColor = ACCENT_COLORS[Math.floor(Math.random() * ACCENT_COLORS.length)];
|
|
state.modalDefaultUser = '';
|
|
state.modalAutoConnect = false;
|
|
state.modalNotes = '';
|
|
showModal('Add Server');
|
|
}
|
|
|
|
function openEditServerModal(id) {
|
|
const srv = state.servers.find(s => s.id === id);
|
|
if (!srv) return;
|
|
state.editingServer = srv;
|
|
state.modalName = srv.name;
|
|
state.modalHost = srv.host;
|
|
state.modalPort = String(srv.port);
|
|
state.modalColor = srv.color;
|
|
state.modalDefaultUser = srv.defaultUser || '';
|
|
state.modalAutoConnect = srv.autoConnect || false;
|
|
state.modalNotes = srv.notes || '';
|
|
showModal('Edit Server');
|
|
}
|
|
|
|
function showModal(title) {
|
|
document.getElementById('modalTitle').textContent = title;
|
|
document.getElementById('modalSaveBtn').textContent = state.editingServer ? 'Save Changes' : 'Add Server';
|
|
|
|
document.getElementById('modalBody').innerHTML = `
|
|
<div class="form-group">
|
|
<label class="form-label">Server Name <span class="required">*</span></label>
|
|
<input class="form-input" type="text" id="modalNameInput"
|
|
value="${esc(state.modalName)}" placeholder="e.g. My Home Server"
|
|
oninput="state.modalName=this.value">
|
|
</div>
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label class="form-label">Host Address <span class="required">*</span></label>
|
|
<input class="form-input" type="text" id="modalHostInput"
|
|
value="${esc(state.modalHost)}" placeholder="192.168.1.100 or my.server.com"
|
|
oninput="state.modalHost=this.value">
|
|
</div>
|
|
<div class="form-group port-field">
|
|
<label class="form-label">Port</label>
|
|
<input class="form-input" type="text" id="modalPortInput"
|
|
value="${esc(state.modalPort)}" placeholder="8443"
|
|
oninput="state.modalPort=this.value">
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Default Username</label>
|
|
<input class="form-input" type="text" id="modalUserInput"
|
|
value="${esc(state.modalDefaultUser)}" placeholder="Pre-fills username on select"
|
|
oninput="state.modalDefaultUser=this.value">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Notes</label>
|
|
<input class="form-input" type="text" id="modalNotesInput"
|
|
value="${esc(state.modalNotes)}" placeholder="Optional notes for your reference"
|
|
oninput="state.modalNotes=this.value">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Icon Color</label>
|
|
<div style="display:flex;gap:8px;flex-wrap:wrap;margin-top:4px">
|
|
${ACCENT_COLORS.map(c => `
|
|
<div onclick="state.modalColor='${c}'; showModal('${title}')"
|
|
style="width:32px;height:32px;border-radius:8px;background:${c};cursor:pointer;
|
|
border:2px solid ${c === state.modalColor ? 'white' : 'transparent'};
|
|
transition:border-color .15s" title="${c}"></div>
|
|
`).join('')}
|
|
</div>
|
|
</div>
|
|
<label class="form-checkbox" onclick="state.modalAutoConnect=!state.modalAutoConnect" style="margin-top:8px;margin-bottom:0">
|
|
<input type="checkbox" ${state.modalAutoConnect ? 'checked' : ''}>
|
|
<div class="checkbox-box">${CHECK_SVG}</div>
|
|
<span class="checkbox-label">Auto-connect on startup</span>
|
|
</label>
|
|
`;
|
|
|
|
document.getElementById('serverModal').classList.add('visible');
|
|
}
|
|
|
|
function closeModal() { document.getElementById('serverModal').classList.remove('visible'); }
|
|
|
|
function saveServerProfile() {
|
|
if (!state.modalName.trim() || !state.modalHost.trim()) return;
|
|
|
|
if (state.editingServer) {
|
|
const srv = state.servers.find(s => s.id === state.editingServer.id);
|
|
if (srv) {
|
|
srv.name = state.modalName.trim();
|
|
srv.host = state.modalHost.trim();
|
|
srv.port = parseInt(state.modalPort) || 8443;
|
|
srv.color = state.modalColor;
|
|
srv.defaultUser = state.modalDefaultUser.trim();
|
|
srv.autoConnect = state.modalAutoConnect;
|
|
srv.notes = state.modalNotes.trim();
|
|
}
|
|
} else {
|
|
const newId = Math.max(0, ...state.servers.map(s => s.id)) + 1;
|
|
state.servers.push({
|
|
id: newId,
|
|
name: state.modalName.trim(),
|
|
host: state.modalHost.trim(),
|
|
port: parseInt(state.modalPort) || 8443,
|
|
lastUser: '',
|
|
color: state.modalColor,
|
|
savedPass: false,
|
|
autoConnect: state.modalAutoConnect,
|
|
defaultUser: state.modalDefaultUser.trim(),
|
|
notes: state.modalNotes.trim(),
|
|
lastConnected: null,
|
|
});
|
|
state.health[newId] = { status: 'unknown', latency: null };
|
|
}
|
|
|
|
closeModal();
|
|
renderAll();
|
|
}
|
|
|
|
function openDeleteModal(id) {
|
|
const srv = state.servers.find(s => s.id === id);
|
|
if (!srv) return;
|
|
state.deleteTarget = id;
|
|
document.getElementById('deleteText').innerHTML =
|
|
`Are you sure you want to delete <strong>${esc(srv.name)}</strong>? This will remove the saved server profile and any stored credentials.`;
|
|
document.getElementById('deleteModal').classList.add('visible');
|
|
}
|
|
|
|
function closeDeleteModal() {
|
|
document.getElementById('deleteModal').classList.remove('visible');
|
|
state.deleteTarget = null;
|
|
}
|
|
|
|
function confirmDelete() {
|
|
if (state.deleteTarget === null) return;
|
|
state.servers = state.servers.filter(s => s.id !== state.deleteTarget);
|
|
delete state.health[state.deleteTarget];
|
|
if (state.selectedId === state.deleteTarget) {
|
|
state.selectedId = state.servers.length > 0 ? state.servers[0].id : null;
|
|
if (state.selectedId) {
|
|
const s = state.servers[0];
|
|
state.host = s.host;
|
|
state.port = String(s.port);
|
|
state.username = s.defaultUser || s.lastUser;
|
|
} else {
|
|
state.host = ''; state.port = '8443'; state.username = '';
|
|
}
|
|
}
|
|
closeDeleteModal();
|
|
renderAll();
|
|
}
|
|
|
|
/* ═══ Health Check ═══ */
|
|
function refreshAllHealth() {
|
|
state.servers.forEach(s => {
|
|
state.health[s.id] = { status: 'checking', latency: null };
|
|
});
|
|
renderServerList();
|
|
|
|
// Simulate staggered health check results
|
|
state.servers.forEach((s, i) => {
|
|
setTimeout(() => {
|
|
const roll = Math.random();
|
|
if (roll < 0.6) {
|
|
const lat = Math.floor(5 + Math.random() * 80);
|
|
state.health[s.id] = { status: lat < 200 ? 'online' : 'slow', latency: lat };
|
|
} else if (roll < 0.8) {
|
|
state.health[s.id] = { status: 'slow', latency: Math.floor(200 + Math.random() * 300) };
|
|
} else {
|
|
state.health[s.id] = { status: 'offline', latency: null };
|
|
}
|
|
renderServerList();
|
|
}, 500 + i * 400 + Math.random() * 500);
|
|
});
|
|
}
|
|
|
|
/* ═══ Import/Export ═══ */
|
|
function importProfiles() {
|
|
state.success = 'Import dialog would open here (OpenFileDialog for .json)';
|
|
renderForm();
|
|
}
|
|
function exportProfiles() {
|
|
state.success = `Exported ${state.servers.length} server profiles (SaveFileDialog for .json)`;
|
|
renderForm();
|
|
}
|
|
|
|
/* ═══ Settings ═══ */
|
|
function openSettings() {
|
|
state.settingsOpen = true;
|
|
document.getElementById('settingsOverlay').classList.add('visible');
|
|
renderSettingsNav();
|
|
renderSettingsContent();
|
|
}
|
|
|
|
function closeSettings() {
|
|
state.settingsOpen = false;
|
|
state.micTesting = false;
|
|
state.listeningKeybind = null;
|
|
document.getElementById('settingsOverlay').classList.remove('visible');
|
|
}
|
|
|
|
function switchSettingsTab(tab) {
|
|
state.settingsTab = tab;
|
|
state.listeningKeybind = null;
|
|
renderSettingsNav();
|
|
renderSettingsContent();
|
|
}
|
|
|
|
function toggleMicTest() {
|
|
state.micTesting = !state.micTesting;
|
|
renderSettingsContent();
|
|
if (state.micTesting) animateVu();
|
|
}
|
|
|
|
function animateVu() {
|
|
if (!state.micTesting) { state.vuLevel = 0; return; }
|
|
state.vuLevel = Math.floor(Math.random() * 60 + (Math.random() > 0.7 ? 30 : 5));
|
|
const fill = document.getElementById('vuFill');
|
|
if (fill) fill.style.width = state.vuLevel + '%';
|
|
requestAnimationFrame(() => setTimeout(animateVu, 80));
|
|
}
|
|
|
|
function startListeningKeybind(which) {
|
|
state.listeningKeybind = which;
|
|
renderSettingsContent();
|
|
}
|
|
|
|
/* ═══ Keyboard ═══ */
|
|
document.addEventListener('keydown', (e) => {
|
|
// Keybind capture in settings
|
|
if (state.listeningKeybind && state.settingsOpen) {
|
|
e.preventDefault();
|
|
if (e.key === 'Escape') { state.listeningKeybind = null; renderSettingsContent(); return; }
|
|
const keyName = e.key.length === 1 ? e.key.toUpperCase() : e.key;
|
|
if (state.listeningKeybind === 'ptt') state.pttKey = keyName;
|
|
else if (state.listeningKeybind === 'mute') state.muteKey = keyName;
|
|
else if (state.listeningKeybind === 'deafen') state.deafenKey = keyName;
|
|
state.listeningKeybind = null;
|
|
renderSettingsContent();
|
|
return;
|
|
}
|
|
|
|
if (e.key === 'Escape') {
|
|
if (state.settingsOpen) return closeSettings();
|
|
if (document.getElementById('certModal').classList.contains('visible')) return closeCertDialog();
|
|
if (document.getElementById('deleteModal').classList.contains('visible')) return closeDeleteModal();
|
|
if (document.getElementById('serverModal').classList.contains('visible')) return closeModal();
|
|
}
|
|
});
|
|
|
|
/* ═══ Utility ═══ */
|
|
function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.innerHTML; }
|
|
|
|
/* ═══ Init ═══ */
|
|
renderAll();
|
|
</script>
|
|
</body>
|
|
</html>
|