2448 lines
91 KiB
HTML
2448 lines
91 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>KittyRec — Dashboard</title>
|
|
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
|
<link rel="icon" type="image/png" sizes="32x32" href="/static/kittyrec_icon.png">
|
|
<link rel="apple-touch-icon" href="/static/kittyrec_icon.png">
|
|
<style>
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
:root {
|
|
--bg: #06050f; --bg2: #0c0a1e; --bg3: #13102e; --bg4: #1a1640;
|
|
--border: #251f52;
|
|
--purple: #8b5cf6; --purple-l: #a78bfa; --purple-xl: #c4b5fd; --purple-d: #6d3bef;
|
|
--teal: #2dd4bf; --green: #34d399; --yellow: #fbbf24; --red: #f87171; --pink: #f472b6;
|
|
--text: #ede9fe; --text2: #a39dc8; --text3: #5c5488;
|
|
--sidebar-w: 220px;
|
|
--topbar-h: 56px;
|
|
--radius: 2px;
|
|
--radius-lg: 4px;
|
|
--trans: 0.15s ease;
|
|
}
|
|
|
|
html, body { height: 100%; overflow: hidden; }
|
|
|
|
body {
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
|
|
font-size: 14px;
|
|
line-height: 1.5;
|
|
-webkit-font-smoothing: antialiased;
|
|
}
|
|
|
|
::-webkit-scrollbar { width: 6px; height: 6px; }
|
|
::-webkit-scrollbar-track { background: transparent; }
|
|
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
|
|
::-webkit-scrollbar-thumb:hover { background: var(--purple-d); }
|
|
|
|
#app {
|
|
display: flex;
|
|
height: 100vh;
|
|
width: 100vw;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#sidebar {
|
|
width: var(--sidebar-w);
|
|
min-width: var(--sidebar-w);
|
|
background: var(--bg2);
|
|
border-right: 1px solid var(--border);
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
z-index: 10;
|
|
}
|
|
|
|
#sidebar-brand {
|
|
padding: 16px 14px 12px;
|
|
border-bottom: 1px solid var(--border);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.brand-icon {
|
|
width: 30px; height: 30px;
|
|
background: linear-gradient(135deg, var(--purple), var(--purple-d));
|
|
border-radius: 2px;
|
|
display: flex; align-items: center; justify-content: center;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.brand-icon-shape {
|
|
width: 12px; height: 12px;
|
|
border: 2px solid rgba(255,255,255,0.9);
|
|
border-radius: 2px;
|
|
transform: rotate(45deg);
|
|
}
|
|
|
|
.brand-name {
|
|
font-size: 15px;
|
|
font-weight: 700;
|
|
color: var(--text);
|
|
letter-spacing: -0.02em;
|
|
}
|
|
|
|
.brand-sub {
|
|
font-size: 10px;
|
|
color: var(--text3);
|
|
letter-spacing: 0.05em;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
#server-status-pill {
|
|
margin: 8px 10px;
|
|
background: var(--bg3);
|
|
border: 1px solid var(--border);
|
|
border-radius: 2px;
|
|
padding: 6px 10px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.status-dot {
|
|
width: 7px; height: 7px;
|
|
border-radius: 50%;
|
|
background: var(--green);
|
|
box-shadow: 0 0 6px var(--green);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.status-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); }
|
|
|
|
.status-text { font-size: 12px; color: var(--text2); }
|
|
.status-count { font-weight: 600; color: var(--text); font-size: 12px; margin-left: auto; }
|
|
|
|
#nav-list {
|
|
list-style: none;
|
|
padding: 6px 8px;
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.nav-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 9px;
|
|
padding: 8px 10px;
|
|
border-radius: var(--radius);
|
|
cursor: pointer;
|
|
color: var(--text2);
|
|
font-size: 13.5px;
|
|
font-weight: 500;
|
|
transition: background var(--trans), color var(--trans), border-color var(--trans);
|
|
position: relative;
|
|
user-select: none;
|
|
border-left: 2px solid transparent;
|
|
}
|
|
|
|
.nav-item:hover { background: var(--bg3); color: var(--text); }
|
|
.nav-item.active { background: rgba(139,92,246,0.18); color: var(--purple-l); border-left-color: var(--purple); }
|
|
.nav-item.active .nav-icon { color: var(--purple-l); }
|
|
|
|
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
|
|
.nav-icon svg { width: 16px; height: 16px; }
|
|
|
|
.nav-badge {
|
|
margin-left: auto;
|
|
background: var(--red);
|
|
color: #fff;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
border-radius: 2px;
|
|
padding: 1px 6px;
|
|
min-width: 18px;
|
|
text-align: center;
|
|
}
|
|
|
|
#sidebar-user {
|
|
border-top: 1px solid var(--border);
|
|
padding: 10px 12px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 9px;
|
|
flex-shrink: 0;
|
|
cursor: pointer;
|
|
transition: background var(--trans);
|
|
}
|
|
|
|
#sidebar-user:hover { background: var(--bg3); }
|
|
|
|
.user-avatar-sm {
|
|
width: 30px; height: 30px;
|
|
border-radius: 50%;
|
|
background: linear-gradient(135deg, var(--purple-d), var(--purple));
|
|
display: flex; align-items: center; justify-content: center;
|
|
font-size: 13px;
|
|
font-weight: 700;
|
|
color: #fff;
|
|
overflow: hidden;
|
|
flex-shrink: 0;
|
|
border: 2px solid var(--border);
|
|
}
|
|
|
|
.user-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
|
|
|
|
.user-info-sm { flex: 1; min-width: 0; }
|
|
.user-display-sm { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
.user-level-sm { font-size: 10.5px; color: var(--text3); }
|
|
|
|
#main {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
min-width: 0;
|
|
}
|
|
|
|
#topbar {
|
|
height: var(--topbar-h);
|
|
min-height: var(--topbar-h);
|
|
background: var(--bg2);
|
|
border-bottom: 1px solid var(--border);
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 0 20px;
|
|
gap: 12px;
|
|
z-index: 5;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
#topbar-title {
|
|
font-size: 15px;
|
|
font-weight: 700;
|
|
color: var(--text);
|
|
letter-spacing: -0.02em;
|
|
flex: 1;
|
|
}
|
|
|
|
#search-box {
|
|
display: flex;
|
|
align-items: center;
|
|
background: var(--bg3);
|
|
border: 1px solid var(--border);
|
|
border-radius: 2px;
|
|
padding: 6px 12px;
|
|
gap: 8px;
|
|
width: 220px;
|
|
transition: border-color var(--trans);
|
|
}
|
|
|
|
#search-box:focus-within { border-color: var(--purple); }
|
|
#search-box input { background: none; border: none; outline: none; color: var(--text); font-size: 13px; width: 100%; }
|
|
#search-box input::placeholder { color: var(--text3); }
|
|
#search-box .search-icon { color: var(--text3); display: flex; align-items: center; }
|
|
#search-box .search-icon svg { width: 14px; height: 14px; }
|
|
|
|
#notif-btn {
|
|
position: relative;
|
|
width: 34px; height: 34px;
|
|
background: var(--bg3);
|
|
border: 1px solid var(--border);
|
|
border-radius: 2px;
|
|
display: flex; align-items: center; justify-content: center;
|
|
cursor: pointer;
|
|
color: var(--text2);
|
|
transition: background var(--trans), color var(--trans);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
#notif-btn:hover { background: var(--bg4); color: var(--text); }
|
|
#notif-btn svg { width: 16px; height: 16px; }
|
|
|
|
#notif-badge {
|
|
position: absolute;
|
|
top: -3px; right: -3px;
|
|
background: var(--red);
|
|
color: #fff;
|
|
font-size: 9px;
|
|
font-weight: 700;
|
|
border-radius: 10px;
|
|
padding: 1px 4px;
|
|
min-width: 16px;
|
|
text-align: center;
|
|
display: none;
|
|
}
|
|
|
|
#notif-panel {
|
|
position: absolute;
|
|
top: calc(var(--topbar-h) + 4px);
|
|
right: 20px;
|
|
width: 340px;
|
|
background: var(--bg3);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-lg);
|
|
box-shadow: 0 16px 48px rgba(0,0,0,0.6);
|
|
z-index: 100;
|
|
display: none;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#notif-panel.open { display: block; }
|
|
|
|
.notif-header {
|
|
padding: 12px 16px 10px;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: var(--text);
|
|
border-bottom: 1px solid var(--border);
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.notif-header button {
|
|
background: none;
|
|
border: none;
|
|
color: var(--text3);
|
|
font-size: 11px;
|
|
cursor: pointer;
|
|
padding: 2px 6px;
|
|
border-radius: 4px;
|
|
transition: color var(--trans);
|
|
}
|
|
|
|
.notif-header button:hover { color: var(--text2); }
|
|
|
|
#notif-list {
|
|
max-height: 360px;
|
|
overflow-y: auto;
|
|
padding: 6px;
|
|
}
|
|
|
|
.notif-item {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 10px;
|
|
padding: 10px;
|
|
border-radius: 2px;
|
|
transition: background var(--trans);
|
|
position: relative;
|
|
}
|
|
|
|
.notif-item:hover { background: var(--bg4); }
|
|
|
|
.notif-avatar {
|
|
width: 32px; height: 32px;
|
|
border-radius: 50%;
|
|
background: linear-gradient(135deg, var(--purple-d), var(--purple));
|
|
display: flex; align-items: center; justify-content: center;
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
overflow: hidden;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.notif-avatar img { width: 100%; height: 100%; object-fit: cover; }
|
|
|
|
.notif-body { flex: 1; min-width: 0; }
|
|
.notif-text { font-size: 12.5px; color: var(--text2); line-height: 1.4; }
|
|
.notif-text strong { color: var(--text); }
|
|
.notif-time { font-size: 10px; color: var(--text3); margin-top: 2px; }
|
|
|
|
.notif-actions { display: flex; gap: 4px; margin-top: 6px; }
|
|
|
|
.btn-xs {
|
|
padding: 3px 8px;
|
|
border-radius: 2px;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
border: 1px solid transparent;
|
|
transition: all var(--trans);
|
|
}
|
|
|
|
.btn-xs.primary { background: var(--purple); color: #fff; }
|
|
.btn-xs.primary:hover { background: var(--purple-d); }
|
|
.btn-xs.ghost { background: transparent; border-color: var(--border); color: var(--text2); }
|
|
.btn-xs.ghost:hover { border-color: var(--text3); color: var(--text); }
|
|
|
|
.notif-dismiss {
|
|
position: absolute;
|
|
top: 6px; right: 6px;
|
|
background: none;
|
|
border: none;
|
|
color: var(--text3);
|
|
cursor: pointer;
|
|
font-size: 12px;
|
|
padding: 2px 4px;
|
|
border-radius: 4px;
|
|
opacity: 0;
|
|
transition: opacity var(--trans), color var(--trans);
|
|
}
|
|
|
|
.notif-item:hover .notif-dismiss { opacity: 1; }
|
|
.notif-dismiss:hover { color: var(--red); }
|
|
|
|
.notif-empty { padding: 24px; text-align: center; color: var(--text3); font-size: 13px; }
|
|
|
|
#content-area {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
position: relative;
|
|
}
|
|
|
|
.section {
|
|
display: none;
|
|
padding: 20px;
|
|
animation: fadeIn 0.2s ease;
|
|
min-height: 100%;
|
|
}
|
|
|
|
.section.active { display: block; }
|
|
|
|
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
|
|
|
|
.card {
|
|
background: var(--bg2);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-lg);
|
|
padding: 16px;
|
|
}
|
|
|
|
.card-title {
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
color: var(--text3);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.08em;
|
|
margin-bottom: 12px;
|
|
padding-left: 8px;
|
|
border-left: 3px solid var(--purple);
|
|
}
|
|
|
|
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
|
|
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
|
|
|
|
.stat-card {
|
|
background: var(--bg2);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-lg);
|
|
padding: 14px 16px 14px 20px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
.stat-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0; left: 0;
|
|
width: 3px; height: 100%;
|
|
}
|
|
.stat-card:nth-child(1)::before { background: var(--purple); }
|
|
.stat-card:nth-child(2)::before { background: var(--teal); }
|
|
.stat-card:nth-child(3)::before { background: var(--green); }
|
|
|
|
.stat-icon {
|
|
width: 38px; height: 38px;
|
|
border-radius: 2px;
|
|
display: flex; align-items: center; justify-content: center;
|
|
flex-shrink: 0;
|
|
border: 1px solid var(--border);
|
|
}
|
|
|
|
.stat-icon svg { width: 18px; height: 18px; }
|
|
|
|
.stat-icon.purple { background: rgba(139,92,246,0.15); color: var(--purple-l); }
|
|
.stat-icon.teal { background: rgba(45,212,191,0.12); color: var(--teal); }
|
|
.stat-icon.green { background: rgba(52,211,153,0.12); color: var(--green); }
|
|
.stat-icon.yellow { background: rgba(251,191,36,0.12); color: var(--yellow); }
|
|
|
|
.stat-val { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.1; }
|
|
.stat-label { font-size: 12px; color: var(--text2); margin-top: 2px; }
|
|
|
|
.section-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-bottom: 14px;
|
|
padding-bottom: 10px;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
|
|
.section-title {
|
|
font-size: 14px;
|
|
font-weight: 700;
|
|
color: var(--text);
|
|
letter-spacing: -0.01em;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.section-title::before {
|
|
content: '';
|
|
display: inline-block;
|
|
width: 3px;
|
|
height: 14px;
|
|
background: var(--purple);
|
|
border-radius: 0;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.room-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 8px 10px;
|
|
border-radius: 2px;
|
|
transition: background var(--trans);
|
|
}
|
|
|
|
.room-row:hover { background: var(--bg3); }
|
|
|
|
.room-activity-dot {
|
|
width: 8px; height: 8px;
|
|
border-radius: 50%;
|
|
background: var(--teal);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.room-name { font-size: 13.5px; font-weight: 600; color: var(--text); flex: 1; }
|
|
.room-activity { font-size: 11px; color: var(--text2); }
|
|
.room-count { font-size: 12px; color: var(--text3); flex-shrink: 0; }
|
|
|
|
.friend-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
padding: 7px 8px;
|
|
border-radius: 2px;
|
|
transition: background var(--trans);
|
|
cursor: default;
|
|
}
|
|
|
|
.friend-row:hover { background: var(--bg3); }
|
|
|
|
.online-dot {
|
|
width: 8px; height: 8px;
|
|
border-radius: 50%;
|
|
background: var(--text3);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.online-dot.on { background: var(--green); box-shadow: 0 0 5px var(--green); }
|
|
|
|
.friend-name { font-size: 13px; font-weight: 500; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
.friend-level { font-size: 11px; color: var(--text3); flex-shrink: 0; }
|
|
|
|
.avatar {
|
|
border-radius: 50%;
|
|
background: linear-gradient(135deg, var(--purple-d), var(--purple));
|
|
display: flex; align-items: center; justify-content: center;
|
|
font-weight: 700;
|
|
color: #fff;
|
|
overflow: hidden;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
|
|
|
|
.avatar-md { width: 44px; height: 44px; font-size: 16px; }
|
|
.avatar-lg { width: 80px; height: 80px; font-size: 28px; border: 3px solid var(--border); }
|
|
.avatar-xl { width: 100px; height: 100px; font-size: 36px; border: 3px solid var(--border); }
|
|
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 7px 14px;
|
|
border-radius: 2px;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
border: 1px solid transparent;
|
|
transition: all var(--trans);
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
|
|
|
|
.btn-primary { background: var(--purple); color: #fff; }
|
|
.btn-primary:hover:not(:disabled) { background: var(--purple-d); }
|
|
.btn-secondary { background: var(--bg4); border-color: var(--border); color: var(--text2); }
|
|
.btn-secondary:hover:not(:disabled) { border-color: var(--purple); color: var(--text); }
|
|
.btn-danger { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.3); color: var(--red); }
|
|
.btn-danger:hover:not(:disabled) { background: rgba(248,113,113,0.2); }
|
|
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 2px; }
|
|
.btn-teal { background: rgba(45,212,191,0.15); border-color: rgba(45,212,191,0.3); color: var(--teal); }
|
|
.btn-teal:hover:not(:disabled) { background: rgba(45,212,191,0.25); }
|
|
|
|
.xp-bar-wrap { background: var(--bg3); border-radius: 1px; height: 4px; overflow: hidden; margin-top: 6px; }
|
|
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--purple), var(--purple-l)); border-radius: 0; transition: width 0.6s ease; }
|
|
|
|
.badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
padding: 2px 6px;
|
|
border-radius: 2px;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.badge-purple { background: rgba(139,92,246,0.2); color: var(--purple-l); border: 1px solid rgba(139,92,246,0.3); }
|
|
.badge-green { background: rgba(52,211,153,0.15); color: var(--green); border: 1px solid rgba(52,211,153,0.25); }
|
|
.badge-yellow { background: rgba(251,191,36,0.15); color: var(--yellow); border: 1px solid rgba(251,191,36,0.25); }
|
|
.badge-red { background: rgba(248,113,113,0.15); color: var(--red); border: 1px solid rgba(248,113,113,0.25); }
|
|
.badge-teal { background: rgba(45,212,191,0.12); color: var(--teal); border: 1px solid rgba(45,212,191,0.25); }
|
|
|
|
.form-group { margin-bottom: 12px; }
|
|
.form-label { font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 6px; display: block; }
|
|
|
|
.form-input {
|
|
width: 100%;
|
|
background: var(--bg3);
|
|
border: 1px solid var(--border);
|
|
border-radius: 2px;
|
|
padding: 8px 12px;
|
|
color: var(--text);
|
|
font-size: 13px;
|
|
outline: none;
|
|
transition: border-color var(--trans);
|
|
}
|
|
|
|
.form-input:focus { border-color: var(--purple); }
|
|
.form-input::placeholder { color: var(--text3); }
|
|
|
|
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }
|
|
.form-success { font-size: 12px; color: var(--green); margin-top: 4px; }
|
|
|
|
.data-table { width: 100%; border-collapse: collapse; }
|
|
.data-table th {
|
|
padding: 7px 12px;
|
|
text-align: left;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.06em;
|
|
color: var(--text3);
|
|
border-bottom: 1px solid var(--border);
|
|
cursor: pointer;
|
|
user-select: none;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.data-table th:hover { color: var(--text2); }
|
|
.data-table th.sorted { color: var(--purple-l); }
|
|
|
|
.data-table td {
|
|
padding: 9px 12px;
|
|
font-size: 13px;
|
|
color: var(--text2);
|
|
border-bottom: 1px solid rgba(37,31,82,0.5);
|
|
vertical-align: middle;
|
|
}
|
|
|
|
.data-table tr:last-child td { border-bottom: none; }
|
|
.data-table tr:hover td { background: rgba(26,22,64,0.5); }
|
|
.data-table .rank { color: var(--text3); font-size: 12px; font-weight: 600; }
|
|
.data-table .player-cell { display: flex; align-items: center; gap: 10px; }
|
|
.data-table .player-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
|
|
.data-table .player-username { font-size: 11px; color: var(--text3); }
|
|
|
|
.tab-bar {
|
|
display: flex;
|
|
gap: 2px;
|
|
background: var(--bg3);
|
|
border-radius: 2px;
|
|
padding: 3px;
|
|
width: fit-content;
|
|
margin-bottom: 14px;
|
|
}
|
|
|
|
.tab {
|
|
padding: 5px 14px;
|
|
border-radius: 2px;
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
color: var(--text3);
|
|
cursor: pointer;
|
|
transition: all var(--trans);
|
|
position: relative;
|
|
}
|
|
|
|
.tab:hover { color: var(--text2); }
|
|
.tab.active { background: var(--bg4); color: var(--text); }
|
|
.tab .tab-badge { margin-left: 5px; background: var(--red); color: #fff; font-size: 9px; font-weight: 700; border-radius: 10px; padding: 1px 5px; vertical-align: middle; }
|
|
|
|
#msg-layout {
|
|
display: flex;
|
|
gap: 0;
|
|
height: calc(100vh - var(--topbar-h) - 48px - 48px);
|
|
min-height: 400px;
|
|
}
|
|
|
|
#thread-list {
|
|
width: 240px;
|
|
min-width: 240px;
|
|
border-right: 1px solid var(--border);
|
|
overflow-y: auto;
|
|
background: var(--bg2);
|
|
border-radius: 0;
|
|
}
|
|
|
|
#chat-pane {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: var(--bg2);
|
|
border-radius: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#chat-header {
|
|
padding: 12px 16px;
|
|
border-bottom: 1px solid var(--border);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
#chat-messages {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 12px 16px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 2px;
|
|
}
|
|
|
|
.chat-msg {
|
|
display: flex;
|
|
gap: 10px;
|
|
padding: 4px 0;
|
|
}
|
|
|
|
.chat-msg-avatar {
|
|
width: 28px; height: 28px;
|
|
flex-shrink: 0;
|
|
margin-top: 2px;
|
|
}
|
|
|
|
.chat-msg-body { flex: 1; min-width: 0; }
|
|
.chat-msg-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
|
|
.chat-msg-name { font-size: 13px; font-weight: 600; color: var(--text); }
|
|
.chat-msg-time { font-size: 10px; color: var(--text3); }
|
|
.chat-msg-text { font-size: 13px; color: var(--text2); word-break: break-word; line-height: 1.5; }
|
|
|
|
#chat-input-wrap {
|
|
padding: 10px 14px;
|
|
border-top: 1px solid var(--border);
|
|
display: flex;
|
|
gap: 8px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
#chat-input {
|
|
flex: 1;
|
|
background: var(--bg3);
|
|
border: 1px solid var(--border);
|
|
border-radius: 2px;
|
|
padding: 8px 12px;
|
|
color: var(--text);
|
|
font-size: 13px;
|
|
font-family: inherit;
|
|
line-height: 1.4;
|
|
outline: none;
|
|
resize: none;
|
|
height: 36px;
|
|
overflow: hidden;
|
|
transition: border-color var(--trans);
|
|
}
|
|
|
|
#chat-input:focus { border-color: var(--purple); }
|
|
|
|
.thread-item {
|
|
padding: 10px 14px;
|
|
border-bottom: 1px solid rgba(37,31,82,0.4);
|
|
cursor: pointer;
|
|
transition: background var(--trans);
|
|
display: flex;
|
|
gap: 10px;
|
|
align-items: center;
|
|
}
|
|
|
|
.thread-item:hover { background: var(--bg3); }
|
|
.thread-item.active { background: rgba(139,92,246,0.12); }
|
|
|
|
.thread-info { flex: 1; min-width: 0; }
|
|
.thread-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
.thread-preview { font-size: 11px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
|
|
.thread-unread { background: var(--purple); color: #fff; font-size: 10px; font-weight: 700; border-radius: 10px; padding: 1px 5px; flex-shrink: 0; }
|
|
|
|
#pfp-drop-zone {
|
|
border: 2px dashed var(--border);
|
|
border-radius: var(--radius-lg);
|
|
padding: 28px;
|
|
text-align: center;
|
|
cursor: pointer;
|
|
transition: all var(--trans);
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
#pfp-drop-zone:hover, #pfp-drop-zone.drag-over { border-color: var(--purple); background: rgba(139,92,246,0.05); }
|
|
|
|
.pfp-drop-icon { width: 36px; height: 36px; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; color: var(--text3); }
|
|
.pfp-drop-icon svg { width: 32px; height: 32px; }
|
|
.pfp-drop-text { font-size: 13px; color: var(--text2); }
|
|
.pfp-drop-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }
|
|
|
|
.pfp-history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 10px; }
|
|
.pfp-hist-item { position: relative; }
|
|
.pfp-hist-img {
|
|
width: 100%; aspect-ratio: 1;
|
|
border-radius: 2px;
|
|
object-fit: cover;
|
|
border: 2px solid var(--border);
|
|
cursor: pointer;
|
|
transition: border-color var(--trans);
|
|
}
|
|
.pfp-hist-img:hover { border-color: var(--purple); }
|
|
.pfp-hist-restore { position: absolute; bottom: 4px; right: 4px; background: rgba(6,5,15,0.85); border: 1px solid var(--border); border-radius: 5px; padding: 2px 5px; font-size: 10px; color: var(--text2); cursor: pointer; opacity: 0; transition: opacity var(--trans); }
|
|
.pfp-hist-item:hover .pfp-hist-restore { opacity: 1; }
|
|
|
|
.spinner {
|
|
width: 24px; height: 24px;
|
|
border: 2px solid var(--border);
|
|
border-top-color: var(--purple);
|
|
border-radius: 50%;
|
|
animation: spin 0.7s linear infinite;
|
|
display: inline-block;
|
|
}
|
|
|
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
|
|
.skeleton {
|
|
background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
|
|
background-size: 200% 100%;
|
|
animation: shimmer 1.4s infinite;
|
|
border-radius: 6px;
|
|
}
|
|
|
|
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
|
|
|
|
.loading-center { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text3); gap: 10px; }
|
|
|
|
#auth-overlay {
|
|
position: fixed;
|
|
inset: 0;
|
|
background: rgba(6,5,15,0.75);
|
|
backdrop-filter: blur(8px);
|
|
z-index: 1000;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
#auth-modal {
|
|
background: var(--bg2);
|
|
border: 1px solid var(--border);
|
|
border-radius: 4px;
|
|
padding: 30px;
|
|
width: 360px;
|
|
box-shadow: 0 24px 64px rgba(0,0,0,0.7);
|
|
}
|
|
|
|
.auth-brand { text-align: center; margin-bottom: 22px; }
|
|
.auth-brand-icon {
|
|
width: 48px; height: 48px;
|
|
background: linear-gradient(135deg, var(--purple), var(--purple-d));
|
|
border-radius: 4px;
|
|
display: flex; align-items: center; justify-content: center;
|
|
margin: 0 auto 10px;
|
|
}
|
|
.auth-brand-icon-shape {
|
|
width: 18px; height: 18px;
|
|
border: 2.5px solid rgba(255,255,255,0.9);
|
|
border-radius: 3px;
|
|
transform: rotate(45deg);
|
|
}
|
|
.auth-brand h2 { font-size: 20px; color: var(--text); }
|
|
.auth-brand p { font-size: 13px; color: var(--text3); margin-top: 2px; }
|
|
|
|
.auth-tabs { display: flex; gap: 0; margin-bottom: 20px; background: var(--bg3); border-radius: 2px; padding: 3px; }
|
|
.auth-tab { flex: 1; padding: 7px; text-align: center; border-radius: 2px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text3); transition: all var(--trans); }
|
|
.auth-tab.active { background: var(--bg4); color: var(--text); }
|
|
|
|
#auth-error { font-size: 12px; color: var(--red); margin-top: -8px; margin-bottom: 10px; display: none; }
|
|
|
|
.profile-header {
|
|
display: flex;
|
|
gap: 18px;
|
|
align-items: flex-start;
|
|
margin-bottom: 18px;
|
|
}
|
|
|
|
.profile-details { flex: 1; }
|
|
.profile-display { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2; }
|
|
.profile-username { font-size: 13px; color: var(--text3); margin-top: 2px; }
|
|
.profile-badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
|
|
.profile-xp-label { font-size: 12px; color: var(--text3); margin-top: 10px; }
|
|
|
|
.token-display {
|
|
display: flex; align-items: center; gap: 6px;
|
|
background: var(--bg3); border: 1px solid var(--border); border-radius: 2px;
|
|
padding: 7px 12px; margin-top: 10px; width: fit-content;
|
|
}
|
|
|
|
.token-icon { display: flex; align-items: center; color: var(--yellow); }
|
|
.token-icon svg { width: 15px; height: 15px; }
|
|
.token-val { font-size: 15px; font-weight: 700; color: var(--yellow); }
|
|
.token-label { font-size: 11px; color: var(--text3); }
|
|
|
|
#player-popup {
|
|
position: fixed;
|
|
inset: 0;
|
|
z-index: 500;
|
|
display: none;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background: rgba(6,5,15,0.6);
|
|
backdrop-filter: blur(4px);
|
|
}
|
|
|
|
#player-popup.open { display: flex; }
|
|
|
|
#player-popup-inner {
|
|
background: var(--bg2);
|
|
border: 1px solid var(--border);
|
|
border-radius: 4px;
|
|
padding: 26px;
|
|
width: 320px;
|
|
box-shadow: 0 20px 60px rgba(0,0,0,0.6);
|
|
position: relative;
|
|
}
|
|
|
|
.popup-close {
|
|
position: absolute;
|
|
top: 14px; right: 14px;
|
|
background: var(--bg3);
|
|
border: 1px solid var(--border);
|
|
border-radius: 2px;
|
|
width: 28px; height: 28px;
|
|
display: flex; align-items: center; justify-content: center;
|
|
cursor: pointer;
|
|
color: var(--text3);
|
|
font-size: 14px;
|
|
transition: color var(--trans);
|
|
}
|
|
|
|
.popup-close:hover { color: var(--text); }
|
|
|
|
.empty-state { text-align: center; padding: 36px; color: var(--text3); font-size: 13px; }
|
|
.empty-state .empty-icon { display: block; width: 28px; height: 28px; margin: 0 auto 10px; opacity: 0.4; }
|
|
.empty-state .empty-icon svg { width: 28px; height: 28px; }
|
|
.divider { height: 1px; background: var(--border); margin: 14px 0; }
|
|
.text-muted { color: var(--text3); }
|
|
.text-sm { font-size: 12px; }
|
|
.mt-2 { margin-top: 8px; }
|
|
.mt-3 { margin-top: 12px; }
|
|
.mt-4 { margin-top: 16px; }
|
|
.mb-3 { margin-bottom: 12px; }
|
|
.mb-4 { margin-bottom: 16px; }
|
|
.flex { display: flex; }
|
|
.flex-center { display: flex; align-items: center; }
|
|
.gap-2 { gap: 8px; }
|
|
.gap-3 { gap: 12px; }
|
|
.flex-1 { flex: 1; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="auth-overlay">
|
|
<div id="auth-modal">
|
|
<div class="auth-brand">
|
|
<img src="/static/kittyrec_icon.png" style="width:56px;height:56px;border-radius:12px;margin-bottom:4px">
|
|
<h2>KittyRec</h2>
|
|
<p>she be kittying on thy rec till i jumbotron</p>
|
|
</div>
|
|
<div class="auth-tabs">
|
|
<div class="auth-tab active" onclick="switchAuthTab('login')">Sign In</div>
|
|
<div class="auth-tab" onclick="switchAuthTab('register')">Register</div>
|
|
</div>
|
|
<div id="auth-error"></div>
|
|
|
|
<div id="auth-login-form">
|
|
<div class="form-group">
|
|
<label class="form-label">Username</label>
|
|
<input class="form-input" id="login-user" type="text" placeholder="Enter username" autocomplete="username">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Password</label>
|
|
<input class="form-input" id="login-pass" type="password" placeholder="Enter password" autocomplete="current-password">
|
|
</div>
|
|
<button class="btn btn-primary" style="width:100%" onclick="doLogin()" id="login-btn">Sign In</button>
|
|
</div>
|
|
|
|
<div id="auth-reg-form" style="display:none">
|
|
<div class="form-group">
|
|
<label class="form-label">Display Name</label>
|
|
<input class="form-input" id="reg-display" type="text" placeholder="Your display name">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Username</label>
|
|
<input class="form-input" id="reg-user" type="text" placeholder="Choose a username" autocomplete="username">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Password</label>
|
|
<input class="form-input" id="reg-pass" type="password" placeholder="Choose a password" autocomplete="new-password">
|
|
</div>
|
|
<button class="btn btn-primary" style="width:100%" onclick="doRegister()" id="reg-btn">Create Account</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="app">
|
|
<nav id="sidebar">
|
|
<div id="sidebar-brand">
|
|
<img src="/static/kittyrec_icon.png" style="width:28px;height:28px;border-radius:2px;flex-shrink:0">
|
|
<div>
|
|
<div class="brand-name">KittyRec</div>
|
|
<div class="brand-sub"><a href="/" style="color:var(--text3); font-size:11px; display:inline-flex; align-items:center; gap:4px;">← Back to Home</a></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="server-status-pill">
|
|
<div class="status-dot" id="srv-dot"></div>
|
|
<span class="status-text">Server</span>
|
|
<span class="status-count" id="srv-count">—</span>
|
|
</div>
|
|
|
|
<ul id="nav-list">
|
|
<li class="nav-item active" data-section="home" onclick="navigate('home')">
|
|
<span class="nav-icon"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M1.5 6.5L8 1.5l6.5 5V14a.5.5 0 01-.5.5H10V10H6v4.5H2a.5.5 0 01-.5-.5V6.5z"/></svg></span> Home
|
|
</li>
|
|
<li class="nav-item" data-section="profile" onclick="navigate('profile')">
|
|
<span class="nav-icon"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="5.5" r="2.5"/><path d="M2.5 13.5c0-2.76 2.46-5 5.5-5s5.5 2.24 5.5 5"/></svg></span> Profile
|
|
</li>
|
|
<li class="nav-item" data-section="leaderboard" onclick="navigate('leaderboard')">
|
|
<span class="nav-icon"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="1.5" y="8" width="3" height="6.5" rx=".5"/><rect x="6.5" y="5" width="3" height="9.5" rx=".5"/><rect x="11.5" y="2" width="3" height="12.5" rx=".5"/></svg></span> Leaderboard
|
|
</li>
|
|
<li class="nav-item" data-section="friends" onclick="navigate('friends')">
|
|
<span class="nav-icon"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="5" r="2.5"/><path d="M1 13c0-2.21 2.24-4 5-4s5 1.79 5 4"/><path d="M11.5 2.5a2 2 0 010 4M14.5 13c0-1.66-1.34-3-3-3"/></svg></span> Friends
|
|
<span class="nav-badge" id="friend-req-badge" style="display:none">0</span>
|
|
</li>
|
|
<li class="nav-item" data-section="messages" onclick="navigate('messages')">
|
|
<span class="nav-icon"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M13.5 2.5h-11A1 1 0 001.5 3.5v7a1 1 0 001 1h3l2.5 2.5 2.5-2.5h3a1 1 0 001-1v-7a1 1 0 00-1-1z"/></svg></span> Messages
|
|
<span class="nav-badge" id="msg-badge" style="display:none">0</span>
|
|
</li>
|
|
<li class="nav-item" data-section="photos" onclick="navigate('photos')">
|
|
<span class="nav-icon"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="1.5" y="3.5" width="13" height="10" rx="1"/><circle cx="8" cy="8.5" r="2.5"/><path d="M5.5 3.5l1-2h3l1 2"/></svg></span> Photos
|
|
</li>
|
|
<li class="nav-item" data-section="settings" onclick="navigate('settings')">
|
|
<span class="nav-icon"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="8" r="2"/><path d="M8 1.5v1M8 13.5v1M1.5 8h1M13.5 8h1M3.4 3.4l.7.7M11.9 11.9l.7.7M3.4 12.6l.7-.7M11.9 4.1l.7-.7"/></svg></span> Settings
|
|
</li>
|
|
</ul>
|
|
|
|
<div id="sidebar-user" onclick="navigate('profile')">
|
|
<div class="user-avatar-sm avatar" id="sidebar-avatar">?</div>
|
|
<div class="user-info-sm">
|
|
<div class="user-display-sm" id="sidebar-display">—</div>
|
|
<div class="user-level-sm" id="sidebar-level">Level —</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div id="main">
|
|
<div id="topbar">
|
|
<div id="topbar-title">Home</div>
|
|
<div id="search-box">
|
|
<span class="search-icon"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="6.5" cy="6.5" r="4"/><path d="M11 11l2.5 2.5"/></svg></span>
|
|
<input type="text" placeholder="Search players..." id="global-search" oninput="onSearchInput(this.value)">
|
|
</div>
|
|
<div id="notif-btn" onclick="toggleNotifPanel()">
|
|
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M8 1.5A4.5 4.5 0 003.5 6v3L2 11h12l-1.5-2V6A4.5 4.5 0 008 1.5z"/><path d="M6.5 11.5a1.5 1.5 0 003 0"/></svg>
|
|
<div id="notif-badge"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="notif-panel">
|
|
<div class="notif-header">
|
|
Notifications
|
|
<button onclick="dismissAllNotifs()">Clear all</button>
|
|
</div>
|
|
<div id="notif-list"></div>
|
|
</div>
|
|
|
|
<div id="content-area">
|
|
|
|
<div class="section active" id="sec-home">
|
|
<div class="grid-3 mb-4" id="home-stats">
|
|
<div class="stat-card">
|
|
<div class="stat-icon purple"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="5" r="2.5"/><path d="M1 13c0-2.21 2.24-4 5-4s5 1.79 5 4"/><path d="M11.5 2.5a2 2 0 010 4M14.5 13c0-1.66-1.34-3-3-3"/></svg></div>
|
|
<div>
|
|
<div class="stat-val" id="stat-online">—</div>
|
|
<div class="stat-label">Players Online</div>
|
|
</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-icon teal"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="12" height="9" rx="1.5"/><path d="M5.5 14.5h5M8 12v2.5"/></svg></div>
|
|
<div>
|
|
<div class="stat-val" id="stat-rooms">—</div>
|
|
<div class="stat-label">Active Sessions</div>
|
|
</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-icon green"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="6" r="3"/><path d="M2 14c0-3.31 2.69-6 6-6s6 2.69 6 6"/></svg></div>
|
|
<div>
|
|
<div class="stat-val" id="stat-total">—</div>
|
|
<div class="stat-label">Total Players</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="grid-2">
|
|
<div>
|
|
<div class="card">
|
|
<div class="card-title">Active Sessions</div>
|
|
<div id="home-rooms-list"><div class="loading-center"><div class="spinner"></div></div></div>
|
|
</div>
|
|
<div class="card mt-4">
|
|
<div class="section-header">
|
|
<div class="section-title">Top Players</div>
|
|
<span class="text-sm text-muted">By XP</span>
|
|
</div>
|
|
<div id="home-leaderboard"></div>
|
|
</div>
|
|
</div>
|
|
<div class="card">
|
|
<div class="section-header">
|
|
<div class="section-title">Friends Online</div>
|
|
<span class="text-sm text-muted" id="friends-online-count"></span>
|
|
</div>
|
|
<div id="home-friends-list"><div class="loading-center"><div class="spinner"></div></div></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section" id="sec-profile">
|
|
<div class="grid-2">
|
|
<div>
|
|
<div class="card mb-4">
|
|
<div class="profile-header">
|
|
<div class="avatar avatar-xl" id="profile-avatar-lg">?</div>
|
|
<div class="profile-details">
|
|
<div class="profile-display" id="profile-display-name">—</div>
|
|
<div class="profile-username" id="profile-username">@—</div>
|
|
<div class="profile-badges" id="profile-badges"></div>
|
|
<div class="profile-xp-label">
|
|
<span id="profile-xp-val">0</span> XP · Level <span id="profile-level-val">0</span>
|
|
</div>
|
|
<div class="xp-bar-wrap mt-2" style="width:180px">
|
|
<div class="xp-bar-fill" id="profile-xp-bar" style="width:0%"></div>
|
|
</div>
|
|
<div class="token-display mt-3">
|
|
<span class="token-icon"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="8" r="6"/><path d="M8 5v6M6 6.5h2.5a1 1 0 010 2H7a1 1 0 000 2H10"/></svg></span>
|
|
<span class="token-val" id="profile-tokens">—</span>
|
|
<span class="token-label">tokens</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="text-sm text-muted">Player ID: <span id="profile-id">—</span></div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-title">Change Profile Picture</div>
|
|
<div style="font-size:12px;color:var(--text3);margin-bottom:12px">Costs <span style="color:var(--yellow);font-weight:600">9,000 tokens</span> · Max 2MB · PNG/JPEG/GIF</div>
|
|
<div id="pfp-drop-zone">
|
|
<div class="pfp-drop-icon"><svg viewBox="0 0 32 32" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 20l-4-4-4 4M16 16v10"/><path d="M27.3 23.3A7 7 0 0020 10h-1.3A11 11 0 103 21"/></svg></div>
|
|
<div class="pfp-drop-text">Drag & drop or click to upload</div>
|
|
<div class="pfp-drop-sub">PNG, JPEG, or GIF</div>
|
|
<input type="file" id="pfp-file-input" accept="image/png,image/jpeg,image/gif" style="display:none">
|
|
</div>
|
|
<div id="pfp-upload-msg"></div>
|
|
<button class="btn btn-primary btn-sm" id="pfp-upload-btn" style="display:none" onclick="uploadPfp()">Upload Picture</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-title">Picture History</div>
|
|
<div id="pfp-history-content"><div class="loading-center"><div class="spinner"></div></div></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section" id="sec-leaderboard">
|
|
<div class="card">
|
|
<div class="section-header mb-4">
|
|
<div class="section-title">All Players</div>
|
|
<div style="display:flex;gap:8px;align-items:center">
|
|
<input type="text" class="form-input" style="width:200px" placeholder="Filter players..." id="lb-filter" oninput="filterLeaderboard(this.value)">
|
|
</div>
|
|
</div>
|
|
<div style="overflow-x:auto">
|
|
<table class="data-table" id="lb-table">
|
|
<thead>
|
|
<tr>
|
|
<th onclick="sortLB('rank')">#</th>
|
|
<th onclick="sortLB('display_name')">Player</th>
|
|
<th onclick="sortLB('level')">Level ↕</th>
|
|
<th onclick="sortLB('xp')">XP ↕</th>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="lb-tbody">
|
|
<tr><td colspan="6"><div class="loading-center"><div class="spinner"></div> Loading players...</div></td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section" id="sec-friends">
|
|
<div class="tab-bar">
|
|
<div class="tab active" id="friends-tab-friends" onclick="switchFriendsTab('friends')">Friends</div>
|
|
<div class="tab" id="friends-tab-requests" onclick="switchFriendsTab('requests')">
|
|
Requests <span class="tab-badge" id="friends-req-count" style="display:none">0</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="friends-pane-friends" class="card">
|
|
<div id="friends-list-content"><div class="loading-center"><div class="spinner"></div></div></div>
|
|
</div>
|
|
|
|
<div id="friends-pane-requests" style="display:none">
|
|
<div class="card">
|
|
<div class="card-title">Incoming Requests</div>
|
|
<div id="friends-req-content"><div class="loading-center"><div class="spinner"></div></div></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section" id="sec-messages">
|
|
<div class="card" style="padding:48px 32px;text-align:center;border-left:3px solid var(--yellow)">
|
|
<div style="display:flex;align-items:center;justify-content:center;margin-bottom:16px">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="var(--yellow)" stroke-width="1.5" stroke-linecap="square" stroke-linejoin="miter" style="width:40px;height:40px"><path d="M12 2L13.5 8.5H20L14.5 12.5L16.5 19L12 15L7.5 19L9.5 12.5L4 8.5H10.5L12 2Z"/></svg>
|
|
</div>
|
|
<div style="font-size:16px;font-weight:700;color:var(--text);margin-bottom:8px;text-transform:uppercase;letter-spacing:1px">Under Construction</div>
|
|
<div style="font-size:13px;color:var(--text2)">Messages are coming soon. Check back later!</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section" id="sec-photos">
|
|
<div class="card">
|
|
<div class="section-header mb-4">
|
|
<div class="section-title">My Photos</div>
|
|
<div id="photos-count" style="font-size:12px;color:var(--text3)"></div>
|
|
</div>
|
|
<div id="photos-grid" style="display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:10px"></div>
|
|
<div id="photos-load-more" style="display:none;text-align:center;margin-top:16px">
|
|
<button class="btn btn-secondary btn-sm" onclick="loadMorePhotos()">Load more</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section" id="sec-settings">
|
|
<div class="grid-2">
|
|
<div>
|
|
<div class="card mb-4">
|
|
<div class="card-title">Account Info</div>
|
|
<div style="display:flex;flex-direction:column;gap:10px">
|
|
<div>
|
|
<div class="form-label">Display Name</div>
|
|
<div style="font-size:15px;font-weight:600;color:var(--text)" id="settings-display-name">—</div>
|
|
</div>
|
|
<div>
|
|
<div class="form-label">Username</div>
|
|
<div style="font-size:13px;color:var(--text2)" id="settings-username">—</div>
|
|
</div>
|
|
<div>
|
|
<div class="form-label">Player ID</div>
|
|
<div style="font-size:13px;color:var(--text3);font-family:monospace" id="settings-id">—</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-title">Change Password</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Current Password</label>
|
|
<input class="form-input" type="password" id="pw-current" placeholder="Current password">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">New Password</label>
|
|
<input class="form-input" type="password" id="pw-new" placeholder="New password">
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Confirm New Password</label>
|
|
<input class="form-input" type="password" id="pw-confirm" placeholder="Confirm new password">
|
|
</div>
|
|
<div id="pw-msg"></div>
|
|
<button class="btn btn-primary btn-sm mt-2" onclick="changePassword()">Update Password</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-title">Session</div>
|
|
<p style="font-size:13px;color:var(--text2);margin-bottom:16px">You are currently signed in as <strong id="settings-signed-as">—</strong>.</p>
|
|
<button class="btn btn-danger" onclick="doLogout()">Sign Out</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="player-popup" onclick="closePlayerPopup(event)">
|
|
<div id="player-popup-inner">
|
|
<div class="popup-close" onclick="closePlayerPopupDirect()">✕</div>
|
|
<div id="player-popup-content"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
'use strict';
|
|
|
|
const S = {
|
|
token: null,
|
|
player: null,
|
|
currentSection: 'home',
|
|
notifications: [],
|
|
notifOpen: false,
|
|
threads: [],
|
|
activeThread: null,
|
|
chatPollTimer: null,
|
|
heartbeatTimer: null,
|
|
notifTimer: null,
|
|
statusTimer: null,
|
|
lbData: [],
|
|
lbSort: { key: 'xp', dir: -1 },
|
|
pfpFile: null,
|
|
friendsTab: 'friends',
|
|
friendsData: [],
|
|
lastMsgId: 0,
|
|
photosOffset: 0,
|
|
photosTotal: 0,
|
|
photosLoaded: false,
|
|
lbTimer: null,
|
|
homeRefreshTimer: null,
|
|
};
|
|
|
|
function esc(str) {
|
|
if (str == null) return '';
|
|
return String(str)
|
|
.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>')
|
|
.replace(/"/g, '"')
|
|
.replace(/'/g, ''');
|
|
}
|
|
|
|
function fmtXP(n) {
|
|
if (n >= 1000000) return (n/1000000).toFixed(1) + 'M';
|
|
if (n >= 1000) return (n/1000).toFixed(1) + 'K';
|
|
return String(n);
|
|
}
|
|
|
|
function fmtTime(iso) {
|
|
if (!iso) return '';
|
|
try {
|
|
const d = new Date(iso);
|
|
const now = new Date();
|
|
const diff = now - d;
|
|
if (diff < 60000) return 'just now';
|
|
if (diff < 3600000) return Math.floor(diff/60000) + 'm ago';
|
|
if (diff < 86400000) return Math.floor(diff/3600000) + 'h ago';
|
|
return d.toLocaleDateString();
|
|
} catch { return ''; }
|
|
}
|
|
|
|
function initials(name) {
|
|
if (!name) return '?';
|
|
return name.trim().charAt(0).toUpperCase();
|
|
}
|
|
|
|
function avatarEl(pid, name, size, extraStyle) {
|
|
const letter = esc(initials(name));
|
|
const sz = size || 36;
|
|
const style = `width:${sz}px;height:${sz}px;font-size:${Math.floor(sz*0.38)}px;${extraStyle||''}`;
|
|
const img = pid ? `<img src="/alt/${esc(pid)}" alt="" onerror="this.style.display='none'" onload="this.nextSibling&&(this.nextSibling.style.display='none')">` : '';
|
|
return `<div class="avatar" style="${style}">${img}<span>${letter}</span></div>`;
|
|
}
|
|
|
|
async function api(method, path, body, isFormData) {
|
|
const opts = { method, headers: {} };
|
|
if (S.token) opts.headers['Authorization'] = 'Bearer ' + S.token;
|
|
if (body && !isFormData) {
|
|
opts.headers['Content-Type'] = 'application/json';
|
|
opts.body = JSON.stringify(body);
|
|
} else if (body && isFormData) {
|
|
opts.body = body;
|
|
}
|
|
try {
|
|
const r = await fetch(path, opts);
|
|
const ct = r.headers.get('content-type') || '';
|
|
if (ct.includes('application/json')) {
|
|
const data = await r.json();
|
|
return { ok: r.ok, status: r.status, data };
|
|
}
|
|
return { ok: r.ok, status: r.status, data: null };
|
|
} catch (e) {
|
|
return { ok: false, status: 0, data: { error: e.message } };
|
|
}
|
|
}
|
|
|
|
function showMsg(el, text, type) {
|
|
el.innerHTML = `<div style="font-size:12px;color:var(--${type==='error'?'red':'green'});margin-top:6px">${esc(text)}</div>`;
|
|
}
|
|
|
|
function switchAuthTab(tab) {
|
|
document.querySelectorAll('.auth-tab').forEach((t, i) => {
|
|
t.classList.toggle('active', (tab==='login' && i===0) || (tab==='register' && i===1));
|
|
});
|
|
document.getElementById('auth-login-form').style.display = tab === 'login' ? '' : 'none';
|
|
document.getElementById('auth-reg-form').style.display = tab === 'register' ? '' : 'none';
|
|
document.getElementById('auth-error').style.display = 'none';
|
|
}
|
|
|
|
function showAuthError(msg) {
|
|
const el = document.getElementById('auth-error');
|
|
el.textContent = msg;
|
|
el.style.display = 'block';
|
|
}
|
|
|
|
async function doLogin() {
|
|
const btn = document.getElementById('login-btn');
|
|
const user = document.getElementById('login-user').value.trim();
|
|
const pass = document.getElementById('login-pass').value;
|
|
if (!user || !pass) { showAuthError('Please fill in all fields.'); return; }
|
|
btn.disabled = true; btn.textContent = 'Signing in…';
|
|
const r = await api('POST', '/api/platformlogin/v1/loginaccount', { Username: user, Password: pass, CacheLogin: true });
|
|
btn.disabled = false; btn.textContent = 'Sign In';
|
|
if (!r.ok || !r.data?.Token) { showAuthError(r.data?.error || r.data?.message || 'Login failed.'); return; }
|
|
onLoggedIn(r.data.Token, r.data.Player);
|
|
}
|
|
|
|
async function doRegister() {
|
|
const btn = document.getElementById('reg-btn');
|
|
const display = document.getElementById('reg-display').value.trim();
|
|
const user = document.getElementById('reg-user').value.trim();
|
|
const pass = document.getElementById('reg-pass').value;
|
|
if (!display || !user || !pass) { showAuthError('Please fill in all fields.'); return; }
|
|
btn.disabled = true; btn.textContent = 'Creating…';
|
|
const r = await api('POST', '/api/platformlogin/v1/createaccount', { Username: user, Password: pass, DisplayName: display });
|
|
btn.disabled = false; btn.textContent = 'Create Account';
|
|
if (!r.ok || !r.data?.Token) { showAuthError(r.data?.error || r.data?.message || 'Registration failed.'); return; }
|
|
onLoggedIn(r.data.Token, r.data.Player);
|
|
}
|
|
|
|
function onLoggedIn(token, player) {
|
|
S.token = token;
|
|
S.player = player;
|
|
localStorage.setItem('kr_token', token);
|
|
localStorage.setItem('kr_player', JSON.stringify(player));
|
|
document.getElementById('auth-overlay').style.display = 'none';
|
|
updateSidebarUser();
|
|
startHeartbeat();
|
|
startNotifPoll();
|
|
startStatusPoll();
|
|
loadSection(S.currentSection);
|
|
}
|
|
|
|
async function doLogout() {
|
|
await api('POST', '/api/platformlogin/v1/logout');
|
|
localStorage.removeItem('kr_token');
|
|
localStorage.removeItem('kr_player');
|
|
S.token = null; S.player = null;
|
|
clearInterval(S.heartbeatTimer);
|
|
clearInterval(S.notifTimer);
|
|
clearInterval(S.statusTimer);
|
|
clearInterval(S.chatPollTimer);
|
|
clearInterval(S.homeRefreshTimer);
|
|
clearInterval(S.lbTimer);
|
|
document.getElementById('auth-overlay').style.display = 'flex';
|
|
}
|
|
|
|
async function tryResumeSession() {
|
|
const token = localStorage.getItem('kr_token');
|
|
const playerRaw = localStorage.getItem('kr_player');
|
|
if (!token || !playerRaw) return false;
|
|
S.token = token;
|
|
try { S.player = JSON.parse(playerRaw); } catch { return false; }
|
|
const r = await api('GET', '/web/token-balance');
|
|
if (!r.ok) { S.token = null; S.player = null; return false; }
|
|
document.getElementById('auth-overlay').style.display = 'none';
|
|
updateSidebarUser();
|
|
startHeartbeat();
|
|
startNotifPoll();
|
|
startStatusPoll();
|
|
return true;
|
|
}
|
|
|
|
function updateSidebarUser() {
|
|
if (!S.player) return;
|
|
const p = S.player;
|
|
const avEl = document.getElementById('sidebar-avatar');
|
|
avEl.innerHTML = `<img src="/alt/${esc(p.Id||p.id)}" alt="" onerror="this.style.display='none'" onload="this.nextSibling&&(this.nextSibling.style.display='none')"><span>${esc(initials(p.DisplayName||p.display_name))}</span>`;
|
|
document.getElementById('sidebar-display').textContent = p.DisplayName || p.display_name || p.Username || p.username || '—';
|
|
document.getElementById('sidebar-level').textContent = 'Level ' + (p.Level || p.level || '?');
|
|
}
|
|
|
|
function navigate(section) {
|
|
if (S.currentSection === section) return;
|
|
document.querySelectorAll('.nav-item').forEach(el => {
|
|
el.classList.toggle('active', el.dataset.section === section);
|
|
});
|
|
document.querySelectorAll('.section').forEach(el => el.classList.remove('active'));
|
|
document.getElementById('sec-' + section).classList.add('active');
|
|
S.currentSection = section;
|
|
|
|
const titles = { home:'Home', profile:'Profile', leaderboard:'Leaderboard', friends:'Friends', messages:'Messages', photos:'Photos', settings:'Settings' };
|
|
document.getElementById('topbar-title').textContent = titles[section] || section;
|
|
|
|
if (S.notifOpen) toggleNotifPanel();
|
|
|
|
clearInterval(S.chatPollTimer);
|
|
S.chatPollTimer = null;
|
|
clearInterval(S.homeRefreshTimer);
|
|
S.homeRefreshTimer = null;
|
|
clearInterval(S.lbTimer);
|
|
S.lbTimer = null;
|
|
|
|
loadSection(section);
|
|
}
|
|
|
|
function loadSection(s) {
|
|
if (s === 'home') loadHome();
|
|
else if (s === 'profile') loadProfile();
|
|
else if (s === 'leaderboard') loadLeaderboard();
|
|
else if (s === 'friends') loadFriends();
|
|
else if (s === 'messages') loadMessages();
|
|
else if (s === 'photos') loadPhotos();
|
|
else if (s === 'settings') loadSettings();
|
|
}
|
|
|
|
async function fetchStatus() {
|
|
const r = await api('GET', '/web/status');
|
|
if (!r.ok) return;
|
|
const d = r.data;
|
|
const dot = document.getElementById('srv-dot');
|
|
const cnt = document.getElementById('srv-count');
|
|
dot.className = 'status-dot' + (d.online ? '' : ' offline');
|
|
cnt.textContent = (d.online || 0) + ' online';
|
|
document.getElementById('stat-online').textContent = d.online || 0;
|
|
document.getElementById('stat-rooms').textContent = (d.rooms || []).length;
|
|
|
|
if (S.currentSection === 'home') {
|
|
renderRooms(d.rooms || []);
|
|
}
|
|
}
|
|
|
|
function startStatusPoll() {
|
|
fetchStatus();
|
|
S.statusTimer = setInterval(fetchStatus, 6000);
|
|
}
|
|
|
|
async function loadHome() {
|
|
fetchStatus();
|
|
loadHomeLeaderboard();
|
|
loadHomeFriends();
|
|
clearInterval(S.homeRefreshTimer);
|
|
S.homeRefreshTimer = setInterval(() => { loadHomeLeaderboard(); loadHomeFriends(); }, 12000);
|
|
}
|
|
|
|
function renderRooms(rooms) {
|
|
const el = document.getElementById('home-rooms-list');
|
|
if (!rooms.length) { el.innerHTML = '<div class="empty-state"><span class="empty-icon"><svg viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="22" height="16" rx="2"/><path d="M9 21v2M19 21v2M6 21h16"/></svg></span>No active sessions</div>'; return; }
|
|
el.innerHTML = rooms.map(r => `
|
|
<div class="room-row">
|
|
<div class="room-activity-dot"></div>
|
|
<div>
|
|
<div class="room-name">${esc(r.name || 'Room')}</div>
|
|
<div class="room-activity">${esc(r.activity || '')}</div>
|
|
</div>
|
|
<div class="room-count">${esc(r.players||0)}/${esc(r.max||8)}</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
async function loadHomeLeaderboard() {
|
|
const r = await api('GET', '/api/public/v1/leaderboard');
|
|
if (!r.ok) return;
|
|
const players = (r.data || []).slice(0,5);
|
|
document.getElementById('stat-total').textContent = r.data.length;
|
|
const el = document.getElementById('home-leaderboard');
|
|
if (!players.length) { el.innerHTML = '<div class="empty-state">No players yet</div>'; return; }
|
|
el.innerHTML = players.map((p,i) => `
|
|
<div class="friend-row" style="cursor:pointer" onclick="openPlayerPopup(${esc(p.id)})">
|
|
<div style="width:20px;text-align:center;font-size:12px;color:var(--text3);font-weight:700">${i+1}</div>
|
|
${avatarEl(p.id, p.display_name||p.username, 30)}
|
|
<div class="friend-name">${esc(p.display_name||p.username)}</div>
|
|
<div class="friend-level" style="color:var(--yellow)">${fmtXP(p.xp||0)} XP</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
async function loadHomeFriends() {
|
|
const r = await api('GET', '/web/friends');
|
|
const el = document.getElementById('home-friends-list');
|
|
if (!r.ok) { el.innerHTML = '<div class="empty-state">Could not load friends</div>'; return; }
|
|
const friends = r.data || [];
|
|
const onlineFirst = [...friends].sort((a,b) => (b.online?1:0)-(a.online?1:0));
|
|
const onlineCnt = friends.filter(f=>f.online).length;
|
|
document.getElementById('friends-online-count').textContent = onlineCnt + ' online';
|
|
|
|
const online = friends.filter(f => f.online);
|
|
const offline = friends.filter(f => !f.online && !f.pending_request);
|
|
|
|
if (!friends.length) { el.innerHTML = '<div class="empty-state"><span class="empty-icon"><svg viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="9" r="4"/><path d="M2 23c0-4 4-7 9-7s9 3 9 7"/><path d="M20 5a3.5 3.5 0 010 7M26 23c0-3-2.5-5.5-6-6"/></svg></span>No friends yet</div>'; return; }
|
|
|
|
const friendRowHtml = f => `
|
|
<div class="friend-row" style="cursor:pointer" onclick="openPlayerPopup(${f.id})">
|
|
<div class="avatar" style="width:32px;height:32px;font-size:13px;flex-shrink:0">
|
|
<img src="/alt/${esc(f.id)}" alt="" onerror="this.style.display='none'" onload="this.nextSibling&&(this.nextSibling.style.display='none')"><span>${esc(initials(f.display_name))}</span>
|
|
</div>
|
|
<div class="online-dot ${f.online ? 'on' : ''}"></div>
|
|
<div class="friend-name">${esc(f.display_name || f.username)}</div>
|
|
<div class="friend-level">Lv.${esc(f.level||'?')}</div>
|
|
</div>`;
|
|
|
|
let html = online.length ? online.map(friendRowHtml).join('') : '<div class="empty-state" style="font-size:12px;padding:10px 0">No friends online</div>';
|
|
|
|
if (offline.length) {
|
|
html += `<details style="margin-top:8px">
|
|
<summary style="font-size:11px;font-weight:600;color:var(--text3);text-transform:uppercase;letter-spacing:.06em;cursor:pointer;padding:4px 0;list-style:none;display:flex;align-items:center;gap:6px">
|
|
<svg viewBox="0 0 10 10" width="8" height="8" fill="currentColor" style="transition:transform .2s"><path d="M2 3l3 4 3-4"/></svg>
|
|
Offline (${offline.length})
|
|
</summary>
|
|
${offline.map(friendRowHtml).join('')}
|
|
</details>`;
|
|
}
|
|
|
|
el.innerHTML = html;
|
|
}
|
|
|
|
async function loadProfile() {
|
|
if (!S.player) return;
|
|
const pid = S.player.Id || S.player.id;
|
|
|
|
const r = await api('GET', '/api/public/v1/profile/' + pid);
|
|
const p = r.ok ? r.data : S.player;
|
|
|
|
const dn = p.display_name || p.DisplayName || S.player.DisplayName || '—';
|
|
const un = p.username || p.Username || S.player.Username || '—';
|
|
const level = p.level || p.Level || S.player.Level || 0;
|
|
const xp = p.xp || p.XP || S.player.XP || 0;
|
|
|
|
document.getElementById('profile-display-name').textContent = dn;
|
|
document.getElementById('profile-username').textContent = '@' + un;
|
|
document.getElementById('profile-xp-val').textContent = fmtXP(xp);
|
|
document.getElementById('profile-level-val').textContent = level;
|
|
document.getElementById('profile-id').textContent = pid;
|
|
|
|
const xpPct = Math.min(100, ((xp % 1000) / 1000) * 100);
|
|
document.getElementById('profile-xp-bar').style.width = xpPct + '%';
|
|
|
|
const avLg = document.getElementById('profile-avatar-lg');
|
|
avLg.innerHTML = `<img src="/alt/${esc(pid)}" alt="" onerror="this.style.display='none'" onload="this.nextSibling&&(this.nextSibling.style.display='none')"><span>${esc(initials(dn))}</span>`;
|
|
|
|
const badges = document.getElementById('profile-badges');
|
|
badges.innerHTML = '';
|
|
if (p.developer || p.Developer || S.player.Developer) {
|
|
badges.innerHTML += `<span class="badge badge-purple">Developer</span>`;
|
|
}
|
|
if (level >= 50) badges.innerHTML += `<span class="badge badge-yellow">Veteran</span>`;
|
|
|
|
const tr = await api('GET', '/web/token-balance');
|
|
if (tr.ok) document.getElementById('profile-tokens').textContent = (tr.data.tokens || 0).toLocaleString();
|
|
|
|
document.getElementById('settings-display-name').textContent = dn;
|
|
document.getElementById('settings-username').textContent = '@' + un;
|
|
document.getElementById('settings-id').textContent = pid;
|
|
document.getElementById('settings-signed-as').textContent = dn;
|
|
|
|
loadPfpHistory(pid);
|
|
}
|
|
|
|
async function loadPfpHistory(pid) {
|
|
const el = document.getElementById('pfp-history-content');
|
|
const r = await api('GET', '/web/pfp-history');
|
|
if (!r.ok || !r.data?.length) {
|
|
el.innerHTML = '<div class="empty-state"><span class="empty-icon"><svg viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="22" height="22" rx="2"/><circle cx="9.5" cy="9.5" r="2"/><path d="M3 19l6-6 4 4 3-3 9 9"/></svg></span>No picture history</div>';
|
|
return;
|
|
}
|
|
el.innerHTML = '<div class="pfp-history-grid">' +
|
|
r.data.map(h => `
|
|
<div class="pfp-hist-item">
|
|
<img class="pfp-hist-img" src="/web/pfp-history/${esc(h.id)}?token=${esc(S.token)}" alt=""
|
|
onerror="this.src=''" title="${esc(fmtTime(h.created_at))}">
|
|
<div class="pfp-hist-restore" onclick="restorePfp(${esc(h.id)})">Restore</div>
|
|
</div>
|
|
`).join('') +
|
|
'</div>';
|
|
}
|
|
|
|
async function restorePfp(id) {
|
|
const r = await api('POST', '/web/restore-pfp/' + id);
|
|
if (r.ok) {
|
|
showToast('Profile picture restored!', 'green');
|
|
loadPfpHistory(S.player.Id || S.player.id);
|
|
} else {
|
|
showToast(r.data?.error || 'Restore failed', 'red');
|
|
}
|
|
}
|
|
|
|
function initPfpDrop() {
|
|
const zone = document.getElementById('pfp-drop-zone');
|
|
const fileInput = document.getElementById('pfp-file-input');
|
|
|
|
zone.onclick = (e) => { if (e.target !== fileInput) fileInput.click(); };
|
|
fileInput.onchange = () => { if (fileInput.files[0]) selectPfpFile(fileInput.files[0]); };
|
|
|
|
zone.ondragover = (e) => { e.preventDefault(); zone.classList.add('drag-over'); };
|
|
zone.ondragleave = () => zone.classList.remove('drag-over');
|
|
zone.ondrop = (e) => {
|
|
e.preventDefault();
|
|
zone.classList.remove('drag-over');
|
|
if (e.dataTransfer.files[0]) selectPfpFile(e.dataTransfer.files[0]);
|
|
};
|
|
}
|
|
|
|
function selectPfpFile(file) {
|
|
const msg = document.getElementById('pfp-upload-msg');
|
|
const allowed = ['image/png', 'image/jpeg', 'image/gif'];
|
|
if (!allowed.includes(file.type)) {
|
|
msg.innerHTML = '<div class="form-error">Only PNG, JPEG, or GIF files are allowed.</div>';
|
|
document.getElementById('pfp-upload-btn').style.display = 'none';
|
|
return;
|
|
}
|
|
if (file.size > 2 * 1024 * 1024) {
|
|
msg.innerHTML = '<div class="form-error">File must be under 2MB.</div>';
|
|
document.getElementById('pfp-upload-btn').style.display = 'none';
|
|
return;
|
|
}
|
|
S.pfpFile = file;
|
|
msg.innerHTML = `<div style="font-size:12px;color:var(--text2);margin:6px 0">Selected: <strong>${esc(file.name)}</strong> (${(file.size/1024).toFixed(1)}KB)</div>`;
|
|
document.getElementById('pfp-upload-btn').style.display = 'inline-flex';
|
|
}
|
|
|
|
async function uploadPfp() {
|
|
if (!S.pfpFile) return;
|
|
const btn = document.getElementById('pfp-upload-btn');
|
|
btn.disabled = true; btn.textContent = 'Uploading…';
|
|
const fd = new FormData();
|
|
fd.append('image', S.pfpFile);
|
|
const r = await api('POST', '/web/upload-pfp', fd, true);
|
|
btn.disabled = false; btn.textContent = 'Upload Picture';
|
|
const msg = document.getElementById('pfp-upload-msg');
|
|
if (r.ok) {
|
|
msg.innerHTML = '<div class="form-success">Profile picture updated!</div>';
|
|
S.pfpFile = null;
|
|
btn.style.display = 'none';
|
|
loadPfpHistory(S.player.Id || S.player.id);
|
|
const avLg = document.getElementById('profile-avatar-lg');
|
|
avLg.querySelector('img') && (avLg.querySelector('img').src = '/alt/' + (S.player.Id||S.player.id) + '?t=' + Date.now());
|
|
} else {
|
|
msg.innerHTML = `<div class="form-error">${esc(r.data?.error || 'Upload failed.')}</div>`;
|
|
}
|
|
}
|
|
|
|
async function loadLeaderboard() {
|
|
const r = await api('GET', '/web/players');
|
|
if (!r.ok) {
|
|
document.getElementById('lb-tbody').innerHTML = `<tr><td colspan="6"><div class="empty-state">Failed to load players</div></td></tr>`;
|
|
return;
|
|
}
|
|
S.lbData = r.data || [];
|
|
renderLeaderboard();
|
|
clearInterval(S.lbTimer);
|
|
S.lbTimer = setInterval(async () => {
|
|
const r2 = await api('GET', '/web/players');
|
|
if (r2.ok) { S.lbData = r2.data || []; renderLeaderboard(); }
|
|
}, 12000);
|
|
}
|
|
|
|
function renderLeaderboard() {
|
|
const filter = document.getElementById('lb-filter')?.value?.toLowerCase() || '';
|
|
let data = S.lbData;
|
|
if (filter) data = data.filter(p => (p.display_name||'').toLowerCase().includes(filter) || (p.username||'').toLowerCase().includes(filter));
|
|
|
|
const { key, dir } = S.lbSort;
|
|
data = [...data].sort((a, b) => {
|
|
let av = a[key] ?? 0, bv = b[key] ?? 0;
|
|
if (typeof av === 'string') av = av.toLowerCase();
|
|
if (typeof bv === 'string') bv = bv.toLowerCase();
|
|
if (av < bv) return -dir;
|
|
if (av > bv) return dir;
|
|
return 0;
|
|
});
|
|
|
|
const me = S.player ? (S.player.Id || S.player.id) : null;
|
|
|
|
const tbody = document.getElementById('lb-tbody');
|
|
if (!data.length) { tbody.innerHTML = '<tr><td colspan="6"><div class="empty-state">No players found</div></td></tr>'; return; }
|
|
|
|
tbody.innerHTML = data.map((p, i) => {
|
|
const relNum = p.relationship || 0;
|
|
let actionHtml = '';
|
|
if (p.id != me) {
|
|
if (relNum === 0) actionHtml = `<button class="btn btn-secondary btn-sm" onclick="sendFriendReq(${esc(p.id)}, this)">+ Friend</button>`;
|
|
else if (relNum === 1) actionHtml = `<span class="badge badge-teal">Sent</span>`;
|
|
else if (relNum === 2) actionHtml = `<button class="btn btn-primary btn-sm" onclick="acceptFriendReq(${esc(p.id)}, this)">Accept</button>`;
|
|
else if (relNum === 3) actionHtml = `<span class="badge badge-green">Friends</span>`;
|
|
} else {
|
|
actionHtml = `<span class="badge badge-purple">You</span>`;
|
|
}
|
|
return `
|
|
<tr>
|
|
<td class="rank">${i+1}</td>
|
|
<td>
|
|
<div class="player-cell" style="cursor:pointer" onclick="openPlayerPopup(${esc(p.id)})">
|
|
${avatarEl(p.id, p.display_name||p.username, 32)}
|
|
<div>
|
|
<div class="player-name">${esc(p.display_name||p.username)}</div>
|
|
<div class="player-username">@${esc(p.username)}</div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td><span class="badge badge-purple">Lv.${esc(p.level||0)}</span></td>
|
|
<td style="color:var(--yellow);font-weight:600">${fmtXP(p.xp||0)}</td>
|
|
<td>${p.online ? '<span class="badge badge-green">Online</span>' : '<span style="color:var(--text3);font-size:11px">Offline</span>'}</td>
|
|
<td>${actionHtml}</td>
|
|
</tr>
|
|
`;
|
|
}).join('');
|
|
|
|
document.querySelectorAll('#lb-table th').forEach(th => th.classList.remove('sorted'));
|
|
}
|
|
|
|
function sortLB(key) {
|
|
if (S.lbSort.key === key) S.lbSort.dir *= -1;
|
|
else { S.lbSort.key = key; S.lbSort.dir = key === 'display_name' ? 1 : -1; }
|
|
renderLeaderboard();
|
|
}
|
|
|
|
function filterLeaderboard(val) {
|
|
renderLeaderboard();
|
|
}
|
|
|
|
async function loadFriends() {
|
|
const r = await api('GET', '/web/friends');
|
|
if (!r.ok) {
|
|
document.getElementById('friends-list-content').innerHTML = '<div class="empty-state">Failed to load friends</div>';
|
|
return;
|
|
}
|
|
S.friendsData = r.data || [];
|
|
renderFriends();
|
|
renderFriendRequests();
|
|
}
|
|
|
|
function switchFriendsTab(tab) {
|
|
S.friendsTab = tab;
|
|
document.getElementById('friends-tab-friends').classList.toggle('active', tab === 'friends');
|
|
document.getElementById('friends-tab-requests').classList.toggle('active', tab === 'requests');
|
|
document.getElementById('friends-pane-friends').style.display = tab === 'friends' ? '' : 'none';
|
|
document.getElementById('friends-pane-requests').style.display = tab === 'requests' ? '' : 'none';
|
|
}
|
|
|
|
function renderFriends() {
|
|
const friends = S.friendsData.filter(f => !f.pending_request);
|
|
const el = document.getElementById('friends-list-content');
|
|
if (!friends.length) { el.innerHTML = '<div class="empty-state"><span class="empty-icon"><svg viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="9" r="4"/><path d="M2 23c0-4 4-7 9-7s9 3 9 7"/><path d="M20 5a3.5 3.5 0 010 7M26 23c0-3-2.5-5.5-6-6"/></svg></span>No friends yet. Find people in the Leaderboard!</div>'; return; }
|
|
|
|
const sorted = [...friends].sort((a,b) => (b.online?1:0)-(a.online?1:0));
|
|
el.innerHTML = sorted.map(f => `
|
|
<div class="friend-row" style="cursor:pointer" onclick="openPlayerPopup(${f.id})">
|
|
<div class="avatar" style="width:38px;height:38px;font-size:15px;flex-shrink:0">
|
|
<img src="/alt/${esc(f.id)}" alt="" onerror="this.style.display='none'" onload="this.nextSibling&&(this.nextSibling.style.display='none')"><span>${esc(initials(f.display_name))}</span>
|
|
</div>
|
|
<div class="online-dot ${f.online ? 'on' : ''}"></div>
|
|
<div style="flex:1;min-width:0">
|
|
<div class="friend-name">${esc(f.display_name||f.username)}</div>
|
|
<div style="font-size:11px;color:var(--text3)">@${esc(f.username)} · Lv.${esc(f.level||'?')}</div>
|
|
</div>
|
|
<div style="display:flex;gap:6px;flex-shrink:0">
|
|
<button class="btn btn-teal btn-sm" onclick="startChat(${esc(f.id)})">Msg</button>
|
|
<button class="btn btn-danger btn-sm" onclick="removeFriend(${esc(f.id)}, this)">Remove</button>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
function renderFriendRequests() {
|
|
const reqs = S.friendsData.filter(f => f.pending_request);
|
|
const badge = document.getElementById('friends-req-count');
|
|
const navBadge = document.getElementById('friend-req-badge');
|
|
|
|
if (reqs.length) {
|
|
badge.textContent = reqs.length; badge.style.display = 'inline';
|
|
navBadge.textContent = reqs.length; navBadge.style.display = 'inline';
|
|
} else {
|
|
badge.style.display = 'none'; navBadge.style.display = 'none';
|
|
}
|
|
|
|
const el = document.getElementById('friends-req-content');
|
|
if (!reqs.length) { el.innerHTML = '<div class="empty-state">No pending requests</div>'; return; }
|
|
|
|
el.innerHTML = reqs.map(f => `
|
|
<div class="friend-row">
|
|
<div class="avatar" style="width:38px;height:38px;font-size:15px;flex-shrink:0">
|
|
<img src="/alt/${esc(f.id)}" alt="" onerror="this.style.display='none'" onload="this.nextSibling&&(this.nextSibling.style.display='none')"><span>${esc(initials(f.display_name))}</span>
|
|
</div>
|
|
<div style="flex:1;min-width:0">
|
|
<div class="friend-name">${esc(f.display_name||f.username)}</div>
|
|
<div style="font-size:11px;color:var(--text3)">@${esc(f.username)}</div>
|
|
</div>
|
|
<div style="display:flex;gap:6px;flex-shrink:0">
|
|
<button class="btn btn-primary btn-sm" onclick="acceptFriendReq(${esc(f.id)}, this)">Accept</button>
|
|
<button class="btn btn-danger btn-sm" onclick="removeFriend(${esc(f.id)}, this)">Decline</button>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
async function sendFriendReq(pid, btn) {
|
|
if (btn) { btn.disabled = true; btn.textContent = '…'; }
|
|
const r = await api('POST', '/api/relationships/v2/sendfriendrequest?id=' + pid);
|
|
if (r.ok) {
|
|
if (btn) btn.outerHTML = '<span class="badge badge-teal">Sent</span>';
|
|
} else {
|
|
if (btn) { btn.disabled = false; btn.textContent = '+ Friend'; }
|
|
showToast(r.data?.error || 'Failed to send request', 'red');
|
|
}
|
|
}
|
|
|
|
async function acceptFriendReq(pid, btn) {
|
|
if (btn) { btn.disabled = true; }
|
|
const r = await api('POST', '/api/relationships/v2/acceptfriendrequest?id=' + pid);
|
|
if (r.ok) {
|
|
showToast('Friend request accepted!', 'green');
|
|
loadFriends();
|
|
} else {
|
|
if (btn) btn.disabled = false;
|
|
showToast(r.data?.error || 'Failed to accept', 'red');
|
|
}
|
|
}
|
|
|
|
async function removeFriend(pid, btn) {
|
|
if (btn) btn.disabled = true;
|
|
const r = await api('POST', '/api/relationships/v2/removefriend?id=' + pid);
|
|
if (r.ok) {
|
|
showToast('Friend removed.', 'yellow');
|
|
loadFriends();
|
|
} else {
|
|
if (btn) btn.disabled = false;
|
|
showToast(r.data?.error || 'Failed', 'red');
|
|
}
|
|
}
|
|
|
|
async function loadMessages() {
|
|
const r = await api('GET', '/web/chats');
|
|
const el = document.getElementById('thread-list-content');
|
|
if (!r.ok) { el.innerHTML = '<div class="empty-state">Could not load chats</div>'; return; }
|
|
S.threads = r.data || [];
|
|
renderThreadList();
|
|
updateMsgBadge();
|
|
}
|
|
|
|
function renderThreadList() {
|
|
const el = document.getElementById('thread-list-content');
|
|
if (!S.threads.length) { el.innerHTML = '<div class="empty-state" style="padding:20px;font-size:12px">No conversations yet</div>'; return; }
|
|
|
|
el.innerHTML = S.threads.map(t => {
|
|
const other = (t.players||[]).find(p => p.id != (S.player?.Id||S.player?.id)) || t.players?.[0] || {};
|
|
const name = other.display_name || other.username || 'Unknown';
|
|
const pid = other.id;
|
|
const unread = t.unread || 0;
|
|
return `
|
|
<div class="thread-item ${S.activeThread === t.thread_id ? 'active' : ''}" onclick="openThread(${esc(t.thread_id)})">
|
|
<div class="avatar" style="width:36px;height:36px;font-size:14px;flex-shrink:0">
|
|
<img src="/alt/${esc(pid)}" alt="" onerror="this.style.display='none'" onload="this.nextSibling&&(this.nextSibling.style.display='none')"><span>${esc(initials(name))}</span>
|
|
</div>
|
|
<div class="thread-info">
|
|
<div class="thread-name">${esc(name)}</div>
|
|
<div class="thread-preview">${esc((t.latest_message && t.latest_message.Contents) || 'No messages yet')}</div>
|
|
</div>
|
|
${unread ? `<div class="thread-unread">${unread}</div>` : ''}
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
async function openThread(threadId) {
|
|
S.activeThread = threadId;
|
|
clearInterval(S.chatPollTimer);
|
|
|
|
const thread = S.threads.find(t => t.thread_id === threadId);
|
|
const me = S.player?.Id || S.player?.id;
|
|
const other = thread ? (thread.players||[]).find(p => p.id != me) || thread.players?.[0] : null;
|
|
const otherName = other ? (other.display_name || other.username) : 'Chat';
|
|
|
|
const header = document.getElementById('chat-partner-name');
|
|
const headerAvatar = document.getElementById('chat-partner-avatar');
|
|
header.textContent = otherName;
|
|
headerAvatar.innerHTML = (other ? `<img src="/alt/${esc(other.id)}" alt="" onerror="this.style.display='none'" onload="this.nextSibling&&(this.nextSibling.style.display='none')">` : '') + `<span>${esc(initials(otherName))}</span>`;
|
|
|
|
if (other) {
|
|
document.getElementById('chat-partner-online').innerHTML =
|
|
`<span class="badge ${other.online ? 'badge-green' : ''}" style="${other.online?'':'color:var(--text3);background:none;border-color:var(--border)'}">` +
|
|
(other.online ? 'Online' : 'Offline') + '</span>';
|
|
}
|
|
|
|
const input = document.getElementById('chat-input');
|
|
const sendBtn = document.getElementById('chat-send-btn');
|
|
input.disabled = false; sendBtn.disabled = false;
|
|
|
|
renderThreadList();
|
|
|
|
const r = await api('GET', '/web/chats/' + threadId);
|
|
if (r.ok) {
|
|
const msgs = r.data.messages || [];
|
|
S.lastMsgId = msgs.length ? Math.max(...msgs.map(m => m.ChatMessageId || 0)) : 0;
|
|
renderMessages(msgs, thread);
|
|
}
|
|
|
|
S.chatPollTimer = setInterval(() => pollChat(threadId, thread), 3000);
|
|
}
|
|
|
|
function renderMessages(msgs, thread) {
|
|
const el = document.getElementById('chat-messages');
|
|
const me = S.player?.Id || S.player?.id;
|
|
|
|
if (!msgs.length) { el.innerHTML = '<div class="empty-state">No messages yet. Say hello!</div>'; return; }
|
|
|
|
const players = {};
|
|
if (thread) (thread.players||[]).forEach(p => { players[p.id] = p; });
|
|
|
|
el.innerHTML = msgs.map(m => {
|
|
const sender = players[m.SenderId] || { display_name: 'Unknown', id: m.SenderId };
|
|
const name = sender.display_name || sender.username || 'Unknown';
|
|
const isMe = m.SenderId == me;
|
|
return `
|
|
<div class="chat-msg" style="${isMe ? 'flex-direction:row-reverse' : ''}">
|
|
<div class="avatar chat-msg-avatar" style="width:28px;height:28px;font-size:11px;margin-top:2px">
|
|
<img src="/alt/${esc(m.SenderId)}" alt="" onerror="this.style.display='none'" onload="this.nextSibling&&(this.nextSibling.style.display='none')"><span>${esc(initials(name))}</span>
|
|
</div>
|
|
<div class="chat-msg-body" style="${isMe ? 'align-items:flex-end;display:flex;flex-direction:column' : ''}">
|
|
<div class="chat-msg-meta">
|
|
${isMe ? '' : `<span class="chat-msg-name">${esc(name)}</span>`}
|
|
<span class="chat-msg-time">${esc(fmtTime(m.SentTime))}</span>
|
|
</div>
|
|
<div class="chat-msg-text" style="${isMe ? 'background:rgba(139,92,246,0.18);border-radius:10px 10px 2px 10px;padding:6px 10px;max-width:280px;text-align:right' : 'max-width:280px'}">${esc(m.Contents || m.Text || "")}</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
el.scrollTop = el.scrollHeight;
|
|
}
|
|
|
|
async function pollChat(threadId, thread) {
|
|
if (S.activeThread !== threadId) return;
|
|
const r = await api('GET', `/web/chats/${threadId}/poll?after_id=${S.lastMsgId}`);
|
|
if (!r.ok || !r.data?.length) return;
|
|
const newMsgs = r.data;
|
|
S.lastMsgId = Math.max(...newMsgs.map(m => m.ChatMessageId || 0), S.lastMsgId);
|
|
|
|
const el = document.getElementById('chat-messages');
|
|
const me = S.player?.Id || S.player?.id;
|
|
const players = {};
|
|
if (thread) (thread.players||[]).forEach(p => { players[p.id] = p; });
|
|
|
|
newMsgs.forEach(m => {
|
|
const sender = players[m.SenderId] || { display_name: 'Unknown', id: m.SenderId };
|
|
const name = sender.display_name || sender.username || 'Unknown';
|
|
const isMe = m.SenderId == me;
|
|
const div = document.createElement('div');
|
|
div.className = 'chat-msg';
|
|
div.style.cssText = isMe ? 'flex-direction:row-reverse' : '';
|
|
div.innerHTML = `
|
|
<div class="avatar chat-msg-avatar" style="width:28px;height:28px;font-size:11px;margin-top:2px">
|
|
<img src="/alt/${esc(m.SenderId)}" alt="" onerror="this.style.display='none'" onload="this.nextSibling&&(this.nextSibling.style.display='none')"><span>${esc(initials(name))}</span>
|
|
</div>
|
|
<div class="chat-msg-body" style="${isMe ? 'align-items:flex-end;display:flex;flex-direction:column' : ''}">
|
|
<div class="chat-msg-meta">
|
|
${isMe ? '' : `<span class="chat-msg-name">${esc(name)}</span>`}
|
|
<span class="chat-msg-time">${esc(fmtTime(m.SentTime))}</span>
|
|
</div>
|
|
<div class="chat-msg-text" style="${isMe ? 'background:rgba(139,92,246,0.18);border-radius:10px 10px 2px 10px;padding:6px 10px;max-width:280px;text-align:right' : 'max-width:280px'}">${esc(m.Contents || m.Text || "")}</div>
|
|
</div>
|
|
`;
|
|
el.appendChild(div);
|
|
});
|
|
el.scrollTop = el.scrollHeight;
|
|
}
|
|
|
|
function onChatKey(e) {
|
|
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); sendChatMsg(); }
|
|
}
|
|
|
|
async function sendChatMsg() {
|
|
const input = document.getElementById('chat-input');
|
|
const text = input.value.trim();
|
|
if (!text || !S.activeThread) return;
|
|
input.value = '';
|
|
const r = await api('POST', '/web/chats/' + S.activeThread + '/send', { text });
|
|
if (!r.ok) { input.value = text; showToast('Failed to send message', 'red'); }
|
|
}
|
|
|
|
async function startChat(pid) {
|
|
const r = await api('POST', '/web/chats/start', { player_id: pid });
|
|
if (!r.ok) { showToast('Could not start chat', 'red'); return; }
|
|
navigate('messages');
|
|
setTimeout(async () => {
|
|
await loadMessages();
|
|
if (r.data?.thread_id) openThread(r.data.thread_id);
|
|
}, 100);
|
|
}
|
|
|
|
function updateMsgBadge() {
|
|
const total = S.threads.reduce((sum, t) => sum + (t.unread||0), 0);
|
|
const badge = document.getElementById('msg-badge');
|
|
if (total > 0) { badge.textContent = total; badge.style.display = 'inline'; }
|
|
else { badge.style.display = 'none'; }
|
|
}
|
|
|
|
function loadSettings() {
|
|
if (!S.player) return;
|
|
const p = S.player;
|
|
const dn = p.DisplayName || p.display_name || '—';
|
|
const un = p.Username || p.username || '—';
|
|
const pid = p.Id || p.id || '—';
|
|
document.getElementById('settings-display-name').textContent = dn;
|
|
document.getElementById('settings-username').textContent = '@' + un;
|
|
document.getElementById('settings-id').textContent = pid;
|
|
document.getElementById('settings-signed-as').textContent = dn;
|
|
}
|
|
|
|
async function loadPhotos(reset) {
|
|
if (reset !== false) {
|
|
S.photosOffset = 0;
|
|
S.photosLoaded = false;
|
|
document.getElementById('photos-grid').innerHTML = '<div class="loading-center"><div class="spinner"></div></div>';
|
|
document.getElementById('photos-load-more').style.display = 'none';
|
|
document.getElementById('photos-count').textContent = '';
|
|
}
|
|
const r = await api('GET', '/web/my-photos?offset=' + S.photosOffset + '&limit=24');
|
|
const grid = document.getElementById('photos-grid');
|
|
if (!r.ok) {
|
|
grid.innerHTML = '<div class="empty-state">Could not load photos</div>';
|
|
return;
|
|
}
|
|
const { photos, total, offset, limit } = r.data;
|
|
S.photosTotal = total;
|
|
if (offset === 0) grid.innerHTML = '';
|
|
if (!photos.length && offset === 0) {
|
|
grid.innerHTML = '<div class="empty-state"><span class="empty-icon"><svg viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="5" width="24" height="18" rx="2"/><circle cx="10" cy="13" r="3"/><path d="M2 19l7-7 5 5 3-3 9 9"/></svg></span>No photos yet. Snap some in-game!</div>';
|
|
document.getElementById('photos-count').textContent = '';
|
|
return;
|
|
}
|
|
document.getElementById('photos-count').textContent = total + ' photo' + (total !== 1 ? 's' : '');
|
|
photos.forEach(ph => {
|
|
const wrap = document.createElement('div');
|
|
wrap.style.cssText = 'position:relative;border-radius:8px;overflow:hidden;background:var(--bg2);aspect-ratio:1;cursor:pointer';
|
|
const img = document.createElement('img');
|
|
img.src = '/alt/' + esc(ph.name);
|
|
img.alt = '';
|
|
img.style.cssText = 'width:100%;height:100%;object-fit:cover;display:block';
|
|
const overlay = document.createElement('div');
|
|
overlay.style.cssText = 'position:absolute;bottom:0;left:0;right:0;background:linear-gradient(transparent,rgba(0,0,0,.7));padding:6px 8px;opacity:0;transition:opacity .15s';
|
|
const roomLabel = ph.room_name ? esc(ph.room_name) : 'Unknown room';
|
|
const dateLabel = fmtTime(ph.created_at);
|
|
overlay.innerHTML = `<div style="font-size:10px;color:#fff;line-height:1.3">${roomLabel}<br><span style="opacity:.7">${dateLabel}</span></div>` +
|
|
`<a href="/alt/${esc(ph.name)}" download="${esc(ph.name)}" onclick="event.stopPropagation()" style="position:absolute;top:6px;right:6px;color:#fff;background:rgba(0,0,0,.5);border-radius:4px;padding:2px 5px;font-size:11px;text-decoration:none">↓</a>`;
|
|
wrap.appendChild(img);
|
|
wrap.appendChild(overlay);
|
|
wrap.addEventListener('mouseenter', () => overlay.style.opacity = '1');
|
|
wrap.addEventListener('mouseleave', () => overlay.style.opacity = '0');
|
|
grid.appendChild(wrap);
|
|
});
|
|
S.photosOffset = offset + photos.length;
|
|
const loadMore = document.getElementById('photos-load-more');
|
|
loadMore.style.display = S.photosOffset < total ? 'block' : 'none';
|
|
}
|
|
|
|
function loadMorePhotos() {
|
|
loadPhotos(false);
|
|
}
|
|
|
|
async function changePassword() {
|
|
const cur = document.getElementById('pw-current').value;
|
|
const nw = document.getElementById('pw-new').value;
|
|
const cf = document.getElementById('pw-confirm').value;
|
|
const el = document.getElementById('pw-msg');
|
|
|
|
if (!cur || !nw || !cf) { showMsg(el, 'Fill in all fields.', 'error'); return; }
|
|
if (nw !== cf) { showMsg(el, 'New passwords do not match.', 'error'); return; }
|
|
if (nw.length < 8) { showMsg(el, 'Password must be at least 8 characters.', 'error'); return; }
|
|
|
|
const r = await api('POST', '/web/change-password', { current_password: cur, new_password: nw });
|
|
if (r.ok) {
|
|
showMsg(el, 'Password updated successfully.', 'success');
|
|
document.getElementById('pw-current').value = '';
|
|
document.getElementById('pw-new').value = '';
|
|
document.getElementById('pw-confirm').value = '';
|
|
} else {
|
|
showMsg(el, r.data?.error || 'Failed to update password.', 'error');
|
|
}
|
|
}
|
|
|
|
function toggleNotifPanel() {
|
|
S.notifOpen = !S.notifOpen;
|
|
document.getElementById('notif-panel').classList.toggle('open', S.notifOpen);
|
|
if (S.notifOpen) fetchNotifications();
|
|
}
|
|
|
|
async function fetchNotifications() {
|
|
const r = await api('GET', '/web/notifications');
|
|
if (!r.ok) return;
|
|
S.notifications = r.data || [];
|
|
renderNotifications();
|
|
updateNotifBadge();
|
|
}
|
|
|
|
function renderNotifications() {
|
|
const el = document.getElementById('notif-list');
|
|
if (!S.notifications.length) { el.innerHTML = '<div class="notif-empty">All caught up</div>'; return; }
|
|
|
|
el.innerHTML = S.notifications.map(n => {
|
|
const name = esc(n.from_name || 'Someone');
|
|
let text = '';
|
|
if (n.kind === 'friend_request') text = `<strong>${name}</strong> sent you a friend request`;
|
|
else text = `<strong>${name}</strong> ${esc(n.label || 'sent you a notification')}`;
|
|
|
|
const actions = n.kind === 'friend_request' ? `
|
|
<div class="notif-actions">
|
|
<button class="btn-xs primary" onclick="acceptFriendReqFromNotif(${esc(n.from_id)}, ${esc(n.id)})">Accept</button>
|
|
<button class="btn-xs ghost" onclick="dismissNotif(${esc(n.id)})">Ignore</button>
|
|
</div>
|
|
` : '';
|
|
|
|
return `
|
|
<div class="notif-item" id="notif-${esc(n.id)}">
|
|
<div class="notif-avatar">
|
|
<img src="/alt/${esc(n.from_id)}" alt="" onerror="this.style.display='none'" onload="this.nextSibling&&(this.nextSibling.style.display='none')"><span>${esc(initials(n.from_name||'?'))}</span>
|
|
</div>
|
|
<div class="notif-body">
|
|
<div class="notif-text">${text}</div>
|
|
<div class="notif-time">${esc(fmtTime(n.sent_at))}</div>
|
|
${actions}
|
|
</div>
|
|
<button class="notif-dismiss" onclick="dismissNotif(${esc(n.id)})">✕</button>
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
function updateNotifBadge() {
|
|
const count = S.notifications.length;
|
|
const badge = document.getElementById('notif-badge');
|
|
if (count > 0) { badge.textContent = count; badge.style.display = 'block'; }
|
|
else { badge.style.display = 'none'; }
|
|
}
|
|
|
|
async function dismissNotif(id) {
|
|
const r = await api('POST', '/web/notifications/dismiss/' + id);
|
|
if (r.ok) {
|
|
S.notifications = S.notifications.filter(n => n.id !== id);
|
|
renderNotifications();
|
|
updateNotifBadge();
|
|
}
|
|
}
|
|
|
|
async function dismissAllNotifs() {
|
|
await Promise.all(S.notifications.map(n => api('POST', '/web/notifications/dismiss/' + n.id)));
|
|
S.notifications = [];
|
|
renderNotifications();
|
|
updateNotifBadge();
|
|
}
|
|
|
|
async function acceptFriendReqFromNotif(pid, notifId) {
|
|
const r = await api('POST', '/api/relationships/v2/acceptfriendrequest?id=' + pid);
|
|
if (r.ok) {
|
|
showToast('Friend request accepted!', 'green');
|
|
await dismissNotif(notifId);
|
|
if (S.currentSection === 'friends') loadFriends();
|
|
const p = S.lbData.find(x => x.id == pid);
|
|
if (p) { p.relationship = 3; renderLeaderboard(); }
|
|
} else {
|
|
showToast(r.data?.error || 'Failed', 'red');
|
|
}
|
|
}
|
|
|
|
function startNotifPoll() {
|
|
fetchNotifications();
|
|
S.notifTimer = setInterval(fetchNotifications, 30000);
|
|
}
|
|
|
|
function startHeartbeat() {
|
|
api('POST', '/web/heartbeat');
|
|
S.heartbeatTimer = setInterval(() => api('POST', '/web/heartbeat'), 60000);
|
|
}
|
|
|
|
async function openPlayerPopup(pid) {
|
|
const popup = document.getElementById('player-popup');
|
|
const inner = document.getElementById('player-popup-content');
|
|
inner.innerHTML = '<div class="loading-center"><div class="spinner"></div></div>';
|
|
popup.classList.add('open');
|
|
|
|
const r = await api('GET', '/api/public/v1/profile/' + pid);
|
|
if (!r.ok) { inner.innerHTML = '<div class="empty-state">Could not load profile</div>'; return; }
|
|
const p = r.data;
|
|
const xpPct = Math.min(100, ((p.xp % 1000) / 1000) * 100);
|
|
const me = S.player?.Id || S.player?.id;
|
|
|
|
const lbEntry = S.lbData.find(x => x.id == pid);
|
|
const rel = lbEntry?.relationship || 0;
|
|
|
|
let friendBtn = '';
|
|
if (pid != me) {
|
|
if (rel === 0) friendBtn = `<button class="btn btn-primary btn-sm" onclick="sendFriendReq(${esc(pid)}, this)">+ Add Friend</button>`;
|
|
else if (rel === 1) friendBtn = `<span class="badge badge-teal">Request Sent</span>`;
|
|
else if (rel === 2) friendBtn = `<button class="btn btn-primary btn-sm" onclick="acceptFriendReq(${esc(pid)}, this)">Accept Request</button>`;
|
|
else if (rel === 3) friendBtn = `<button class="btn btn-teal btn-sm" onclick="startChat(${esc(pid)})">Message</button>`;
|
|
}
|
|
|
|
inner.innerHTML = `
|
|
<div style="text-align:center;margin-bottom:16px">
|
|
${avatarEl(pid, p.display_name||p.username, 72, 'margin:0 auto 12px;border:3px solid var(--border)')}
|
|
<div style="font-size:18px;font-weight:700;color:var(--text)">${esc(p.display_name||p.username)}</div>
|
|
<div style="font-size:12px;color:var(--text3);margin-top:2px">@${esc(p.username)}</div>
|
|
${p.developer ? '<span class="badge badge-purple" style="margin-top:6px">Developer</span>' : ''}
|
|
</div>
|
|
${p.bio ? `<div style="font-size:13px;color:var(--text2);text-align:center;margin-bottom:12px;font-style:italic">${esc(p.bio)}</div>` : ''}
|
|
<div style="display:flex;justify-content:space-around;margin-bottom:14px">
|
|
<div style="text-align:center">
|
|
<div style="font-size:18px;font-weight:700;color:var(--text)">${esc(p.level||0)}</div>
|
|
<div style="font-size:11px;color:var(--text3)">Level</div>
|
|
</div>
|
|
<div style="text-align:center">
|
|
<div style="font-size:18px;font-weight:700;color:var(--yellow)">${fmtXP(p.xp||0)}</div>
|
|
<div style="font-size:11px;color:var(--text3)">XP</div>
|
|
</div>
|
|
</div>
|
|
<div class="xp-bar-wrap mb-3"><div class="xp-bar-fill" style="width:${xpPct}%"></div></div>
|
|
<div style="display:flex;justify-content:center;gap:8px">${friendBtn}</div>
|
|
`;
|
|
}
|
|
|
|
function closePlayerPopup(e) {
|
|
if (e.target === document.getElementById('player-popup')) closePlayerPopupDirect();
|
|
}
|
|
|
|
function closePlayerPopupDirect() {
|
|
document.getElementById('player-popup').classList.remove('open');
|
|
}
|
|
|
|
function onSearchInput(val) {
|
|
if (!val) return;
|
|
if (S.currentSection !== 'leaderboard') {
|
|
navigate('leaderboard');
|
|
setTimeout(() => {
|
|
const filter = document.getElementById('lb-filter');
|
|
if (filter) { filter.value = val; filterLeaderboard(val); }
|
|
}, 150);
|
|
} else {
|
|
const filter = document.getElementById('lb-filter');
|
|
if (filter) { filter.value = val; filterLeaderboard(val); }
|
|
}
|
|
}
|
|
|
|
function showToast(msg, color) {
|
|
const t = document.createElement('div');
|
|
const c = { green: 'var(--green)', red: 'var(--red)', yellow: 'var(--yellow)', purple: 'var(--purple-l)' }[color] || 'var(--text2)';
|
|
t.style.cssText = `position:fixed;bottom:24px;right:24px;z-index:9999;background:var(--bg3);border:1px solid var(--border);border-left:3px solid ${c};border-radius:10px;padding:12px 16px;font-size:13px;color:var(--text);box-shadow:0 8px 24px rgba(0,0,0,0.4);max-width:300px;animation:fadeIn 0.2s ease`;
|
|
t.textContent = msg;
|
|
document.body.appendChild(t);
|
|
setTimeout(() => t.style.opacity = '0', 2500);
|
|
setTimeout(() => t.remove(), 2800);
|
|
}
|
|
|
|
document.addEventListener('click', (e) => {
|
|
if (S.notifOpen && !document.getElementById('notif-panel').contains(e.target) && !document.getElementById('notif-btn').contains(e.target)) {
|
|
S.notifOpen = false;
|
|
document.getElementById('notif-panel').classList.remove('open');
|
|
}
|
|
const ns = document.getElementById('new-chat-search');
|
|
if (ns && ns.style.display !== 'none') {
|
|
const btn = ns.previousElementSibling.querySelector('button');
|
|
if (!ns.contains(e.target) && (!btn || !btn.contains(e.target))) {
|
|
ns.style.display = 'none';
|
|
}
|
|
}
|
|
});
|
|
|
|
let _allPlayersCache = null;
|
|
|
|
async function toggleNewChat() {
|
|
const el = document.getElementById('new-chat-search');
|
|
const isOpen = el.style.display !== 'none';
|
|
el.style.display = isOpen ? 'none' : '';
|
|
if (!isOpen) {
|
|
const input = document.getElementById('new-chat-input');
|
|
input.value = '';
|
|
input.focus();
|
|
if (!_allPlayersCache) {
|
|
const r = await api('GET', '/web/players');
|
|
if (r.ok) _allPlayersCache = r.data || [];
|
|
}
|
|
searchNewChat('');
|
|
}
|
|
}
|
|
|
|
function searchNewChat(val) {
|
|
const el = document.getElementById('new-chat-results');
|
|
if (!_allPlayersCache) { el.innerHTML = ''; return; }
|
|
const me = S.player?.Id || S.player?.id;
|
|
const q = val.toLowerCase();
|
|
const filtered = _allPlayersCache.filter(p =>
|
|
p.id != me && (
|
|
(p.display_name||'').toLowerCase().includes(q) ||
|
|
(p.username||'').toLowerCase().includes(q)
|
|
)
|
|
).slice(0, 8);
|
|
if (!filtered.length) {
|
|
el.innerHTML = '<div style="font-size:12px;color:var(--text3);padding:4px 0">No players found</div>';
|
|
return;
|
|
}
|
|
el.innerHTML = filtered.map(p => `
|
|
<div style="display:flex;align-items:center;gap:8px;padding:6px 4px;cursor:pointer;border-radius:6px;transition:background .15s"
|
|
onmouseover="this.style.background='var(--bg3)'" onmouseout="this.style.background=''"
|
|
onclick="startChatFromSearch(${esc(p.id)})">
|
|
${avatarEl(p.id, p.display_name||p.username, 28)}
|
|
<div style="flex:1;min-width:0">
|
|
<div style="font-size:12px;font-weight:600;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis">${esc(p.display_name||p.username)}</div>
|
|
<div style="font-size:11px;color:var(--text3)">@${esc(p.username)}</div>
|
|
</div>
|
|
${p.online ? '<span class="badge badge-green" style="font-size:10px;flex-shrink:0">Online</span>' : ''}
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
async function startChatFromSearch(pid) {
|
|
document.getElementById('new-chat-search').style.display = 'none';
|
|
startChat(pid);
|
|
}
|
|
|
|
document.getElementById('login-pass').addEventListener('keydown', e => { if (e.key === 'Enter') doLogin(); });
|
|
document.getElementById('login-user').addEventListener('keydown', e => { if (e.key === 'Enter') doLogin(); });
|
|
document.getElementById('reg-pass').addEventListener('keydown', e => { if (e.key === 'Enter') doRegister(); });
|
|
|
|
async function init() {
|
|
initPfpDrop();
|
|
fetchStatus();
|
|
|
|
const resumed = await tryResumeSession();
|
|
if (resumed) {
|
|
loadSection('home');
|
|
}
|
|
}
|
|
|
|
init();
|
|
</script>
|
|
</body>
|
|
</html>
|