diff --git a/public/index.html b/public/index.html index a177c27..0602752 100644 --- a/public/index.html +++ b/public/index.html @@ -4,7 +4,7 @@ Web OSCAR Chat - +
@@ -86,6 +86,6 @@
- + diff --git a/public/js/ui.js b/public/js/ui.js index 72f068f..b8295a8 100644 --- a/public/js/ui.js +++ b/public/js/ui.js @@ -146,6 +146,16 @@ export function renderUserResults(users, onOpen) { } } +function buddyStatus(b) { + const raw = String(b?.state || b?.status || '').toLowerCase(); + if (['online', 'present', 'active'].includes(raw)) return 'online'; + if (['away', 'idle', 'dnd', 'busy', 'na'].includes(raw) || b?.idleMins > 0) return 'away'; + if (['offline', 'disconnected'].includes(raw)) return 'offline'; + // If we have an object but no explicit state, default to offline/unknown. + if (b && typeof b === 'object' && !raw) return 'offline'; + return raw ? 'away' : 'offline'; +} + export function renderBuddies(buddies, onOpen) { const list = el('buddies'); clear(list); @@ -154,8 +164,24 @@ export function renderBuddies(buddies, onOpen) { const name = typeof b === 'string' ? b : (b.aimId || b.displayId || b.screenName || b.name || JSON.stringify(b)); - const state = b && typeof b === 'object' && b.state ? ` (${b.state})` : ''; - li.appendChild(button(`${name}${state}`, () => onOpen(name))); + const status = typeof b === 'string' ? 'offline' : buddyStatus(b); + const statusMsg = b?.statusMsg || b?.awayMsg || b?.statusMessage || ''; + const title = statusMsg ? `${status}: ${statusMsg}` : status; + + const btn = document.createElement('button'); + btn.type = 'button'; + btn.className = 'buddy-item'; + btn.title = title; + btn.addEventListener('click', () => onOpen(name)); + + const dot = document.createElement('span'); + dot.className = `status-dot status-${status}`; + const label = document.createElement('span'); + label.className = 'buddy-name'; + label.textContent = name; + + btn.append(dot, label); + li.appendChild(btn); list.appendChild(li); } } diff --git a/public/style.css b/public/style.css index e71add9..2f48f0d 100644 --- a/public/style.css +++ b/public/style.css @@ -273,3 +273,26 @@ main { padding: 1rem; max-width: 1600px; margin: 0 auto; } 0%, 100% { box-shadow: 0 0 0 rgba(255, 209, 102, 0); border-color: rgba(255, 209, 102, 0.35); } 50% { box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.12), 0 0 18px rgba(255, 209, 102, 0.18); border-color: rgba(255, 209, 102, 0.9); } } + +.buddy-item { + display: flex; + align-items: center; + gap: 0.5rem; + width: 100%; + text-align: left; + background: rgba(255,255,255,0.02); + color: var(--text); + border: 1px solid var(--border); + padding: 0.45rem 0.55rem; +} +.buddy-item:hover { background: var(--accent-soft); border-color: rgba(77,163,255,0.3); } +.status-dot { + width: 10px; + height: 10px; + border-radius: 50%; + flex: 0 0 10px; +} +.status-online { background: #2ecc71; box-shadow: 0 0 0 2px rgba(46,204,113,0.15); } +.status-away { background: #f1c40f; box-shadow: 0 0 0 2px rgba(241,196,15,0.15); } +.status-offline { background: #e74c3c; box-shadow: 0 0 0 2px rgba(231,76,60,0.15); } +.buddy-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }