Redesign user interface across all pages (#42)

* Redesign UI: unified design system across all pages

- Replace scattered inline CSS with comprehensive single style.css
- Implement modern design system:
  - System font stack (-apple-system, Segoe UI, etc.)
  - Consistent spacing scale (4px base)
  - Unified color tokens for light/dark themes
  - Reusable component classes (buttons, cards, badges, forms)

- Update all templates to use new CSS classes:
  - browse.html: Less chunky, better space usage with room-grid
  - index.html: Cleaner centered card layout
  - auth.html: Streamlined 4-step flow with gradient background
  - profile.html: Modern settings interface
  - search.html: Browse-style card layout

- Chat page improvements:
  - Tighter layouts (240px/280px sidebars instead of 15%/25%)
  - Better message spacing
  - Improved code blocks with proper padding
  - Cleaner utility belt

- Better responsive design and dark mode support

* modified:   app.py
	modified:   templates/base.html
	modified:   templates/profile.html

* Revert standalone pages to original design

- Browse, index, auth, profile restored to original inline CSS
- Chat page improvements preserved in style.css
- Search page still uses improved card layout

* Add dark mode support to index and browse pages

- index.html now supports dark mode with CSS variables
- browse.html now supports dark mode with CSS variables
- Theme persists from localStorage across pages

* Remove theme toggle from chat page

- Theme toggle button removed from desktop chat sidebar
- Theme toggle button removed from mobile chat modal
- Theme management now done via profile page only

* Make usernames clickable links to profile pages in chat

* Update search page to match browse page layout and CSS

* Fix chat layout positioning

* Fix room list auto-update when title changes

* Fix new room creation appearing in sidebar

- Add socketio.emit in create_room_api() to broadcast new rooms
- Update socket handler to add new rooms to sidebar dynamically
- Rooms now appear without hard refresh

* Fix /title and /cancel commands being sent to LLM

- Add missing return statements after command handlers
- Commands now properly terminate message processing
- Prevents commands from being interpreted as chat messages

* Make usernames in user lists clickable links to profiles

- Update updateUserLists() to create links for all usernames
- Add hover effect CSS for user list links
- Works for both active and inactive users
- Works for both desktop and mobile views

* Revert user list profile links and update profile page layout

- Remove profile links from user lists (no backend route for other users)
- Update profile page to full-screen layout like browse page
- Add header with navigation buttons
- Remove centered container, use full-width layout
- Add box shadows to sections for visual separation

* Convert all flexbox layouts to CSS grid

- Replace all display: flex with CSS grid equivalents
- Update templates: profile, browse, search, index, auth
- Update static CSS for consistent grid usage
- Use grid-template-columns, grid-auto-flow, and place-items
- Improve layout consistency across all pages

* Fix chatroom horizontal scrolling

- Add overflow-x: hidden to #chat-container and #chat to prevent horizontal scroll
- Add word-break and overflow-wrap to message content for text wrapping
- Change pre tags from overflow: hidden to overflow-x: auto for individual scrolling
- Add min-width: 0 to grid containers to prevent overflow
- Code blocks can now scroll individually while chatroom wraps content

* Remove duplicate CSS variables and fix XSS vulnerability

- search.html: Remove inline styles, link to style.css
- index.html: Remove duplicate CSS variable blocks, link to style.css
- browse.html: Remove duplicate CSS variable blocks, link to style.css
- chat.html: Fix XSS vulnerability in room list updates
  - Use textContent/createTextNode instead of innerHTML for user data
  - Use DOM methods instead of string concatenation
  - Encode URL components with encodeURIComponent
  - Extract user count from textContent instead of innerHTML regex

* Merge duplicate CSS rules and replace inline styles with design system

style.css:
- Merge duplicate html, body rules (lines 137-143 and 159-167)
- Consolidate typography and layout properties in single rule
- Remove duplicate BASE LAYOUT section

profile.html:
- Replace style.display mutations with classList API
- Add .availability-indicator.show CSS rule for visibility
- Use classList.add('show') and classList.remove('show')
- Consistent with existing .message.show pattern

browse.html:
- Replace hard-coded gradient colors with CSS variables
- Use var(--gradient-start) and var(--gradient-end) for buttons
- Replace #667eea with var(--button-primary) for tabs and room names
- Remove inline .room-badge styles, use .badge .badge-public/.badge-private
- Apply existing badge classes from style.css for dark mode support

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Russell Ballestrini <russell@unturf.com>
This commit is contained in:
Russell 2025-11-12 09:24:49 -05:00 committed by GitHub
parent e4cabf4be6
commit d46818b5dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 1507 additions and 615 deletions

20
app.py
View file

@ -642,6 +642,16 @@ def create_room_api():
db.session.add(new_room)
db.session.commit()
# Broadcast new room to all users so it appears in sidebar
new_room_data = {
'id': new_room.id,
'name': new_room.name,
'title': new_room.title,
'is_private': new_room.is_private,
'is_new': True # Flag to indicate this is a new room, not an update
}
socketio.emit("update_room_list", new_room_data, room=None)
return jsonify({
'success': True,
'room': {
@ -1055,6 +1065,14 @@ def on_join(data):
username = data["username"]
room = get_room(room_name)
# Set owner for newly created rooms (if room has no owner and user is authenticated)
if room.owner_id is None:
user = auth.get_current_user()
if user:
room.owner_id = user.id
db.session.add(room)
db.session.commit()
# Add the user to the active users list
room.add_user(username)
@ -1240,8 +1258,10 @@ def handle_message(data):
gevent.spawn(save_code_block_to_s3, room_name, s3_key_path, username)
if command.startswith("/title new"):
gevent.spawn(generate_new_title, room_name, username)
return
if command.startswith("/cancel"):
gevent.spawn(cancel_generation, room_name)
return
activity_state = ActivityState.query.filter_by(room_id=room.id).first()
if activity_state:

File diff suppressed because it is too large Load diff

View file

@ -9,10 +9,8 @@
body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
display: grid;
place-items: center;
min-height: 100vh;
margin: 0;
padding: 20px;

View file

@ -39,13 +39,6 @@
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<!-- Search form -->
<div id="search-form" style="width: 90%;">
<form action="/search" method="get">
<input type="text" id="search-keywords" name="keywords" placeholder="Search for keywords..." value="{{ keywords }}">
</form>
</div>
<!-- Hamburger button for mobile -->
<button id="hamburger-button"></button>
@ -71,11 +64,6 @@
<option value="shimmer">Shimmer</option>
</select>
</div>
<div id="theme-toggle-mobile">
<button id="theme-toggle-btn-mobile" onclick="toggleTheme()">
🌙 Dark Mode
</button>
</div>
<div id="auto-play-tts-mobile">
<button id="auto-play-tts-btn-mobile" onclick="toggleAutoPlayTTS()" style="width: 100%; margin-top: 10px; background-color: #f44336; color: white; border: none; padding: 8px; border-radius: 4px; cursor: pointer;">
Auto-Play TTS: OFF
@ -336,16 +324,7 @@
}
function updateThemeButtonText(theme) {
const themeBtn = document.getElementById('theme-toggle-btn');
const themeBtnMobile = document.getElementById('theme-toggle-btn-mobile');
if (theme === 'dark') {
if (themeBtn) themeBtn.textContent = '☀️ Light Mode';
if (themeBtnMobile) themeBtnMobile.textContent = '☀️ Light Mode';
} else {
if (themeBtn) themeBtn.textContent = '🌙 Dark Mode';
if (themeBtnMobile) themeBtnMobile.textContent = '🌙 Dark Mode';
}
// Theme toggle moved to profile page
}
// Apply saved theme on page load
@ -600,6 +579,10 @@
return;
}
// Determine if current room is private by checking if we're in private section
const currentRoomElement = document.querySelector(`[data-room-id="${roomId}"]`);
const isPrivate = currentRoomElement ? currentRoomElement.classList.contains('private-room') : false;
try {
const response = await fetch(`/api/rooms/${roomId}/delete`, {
method: 'DELETE',
@ -609,7 +592,32 @@
const data = await response.json();
if (response.ok) {
window.location.href = '/';
// Navigate to the top room of the appropriate list (public or private)
const roomList = isPrivate
? document.querySelectorAll('#private-rooms-section .rooms-list li')
: document.querySelectorAll('#public-rooms-section .rooms-list li');
// Find first room that isn't the deleted one
let targetRoom = null;
for (let room of roomList) {
if (room.getAttribute('data-room-id') != roomId) {
targetRoom = room;
break;
}
}
if (targetRoom) {
// Navigate to the first available room in the list
const link = targetRoom.closest('a');
if (link) {
window.location.href = link.href;
} else {
window.location.href = '/';
}
} else {
// No other rooms available, go to home
window.location.href = '/';
}
} else {
alert(data.error || 'Failed to delete room');
}

View file

@ -1,37 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Browse Rooms - OpenCompletion</title>
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f7f7f7;
background-color: var(--bg-page);
color: var(--text-primary);
margin: 0;
padding: 20px;
transition: background-color 0.3s ease, color 0.3s ease;
}
.header {
max-width: 1400px;
margin: 0 auto 30px;
display: flex;
justify-content: space-between;
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
flex-wrap: wrap;
gap: 15px;
}
.header h1 {
color: #333;
color: var(--text-primary);
margin: 0;
transition: color 0.3s ease;
}
.header-actions {
display: flex;
display: grid;
grid-auto-flow: column;
gap: 10px;
flex-wrap: wrap;
}
.btn {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
color: white;
border: none;
border-radius: 5px;
@ -51,7 +54,9 @@
.room-tabs {
max-width: 1400px;
margin: 0 auto 20px;
display: flex;
display: grid;
grid-auto-flow: column;
grid-auto-columns: max-content;
gap: 10px;
border-bottom: 2px solid #e1e1e1;
}
@ -61,16 +66,16 @@
padding: 12px 24px;
font-size: 16px;
cursor: pointer;
color: #666;
color: var(--text-secondary);
border-bottom: 3px solid transparent;
transition: all 0.3s;
}
.room-tab:hover {
color: #667eea;
color: var(--button-primary);
}
.room-tab.active {
color: #667eea;
border-bottom-color: #667eea;
color: var(--button-primary);
border-bottom-color: var(--button-primary);
font-weight: bold;
}
.rooms-container {
@ -90,11 +95,11 @@
margin-bottom: 40px;
}
.room-card {
background: white;
background: var(--bg-card);
border-radius: 8px;
padding: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
transition: transform 0.2s, box-shadow 0.2s;
transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s ease;
cursor: pointer;
text-decoration: none;
color: inherit;
@ -105,55 +110,50 @@
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.room-card-header {
display: flex;
justify-content: space-between;
display: grid;
grid-template-columns: 1fr auto;
align-items: start;
margin-bottom: 10px;
}
.room-name {
font-size: 20px;
font-weight: bold;
color: #667eea;
color: var(--button-primary);
margin: 0 0 5px 0;
}
.room-badge {
font-size: 12px;
padding: 4px 8px;
border-radius: 4px;
background: #e7f3ff;
color: #0066cc;
white-space: nowrap;
}
.room-badge.private {
background: #fff3cd;
color: #856404;
}
.room-title {
color: #666;
color: var(--text-secondary);
font-size: 14px;
margin: 8px 0;
line-height: 1.4;
transition: color 0.3s ease;
}
.room-meta {
display: flex;
display: grid;
grid-auto-flow: column;
grid-auto-columns: max-content;
gap: 15px;
margin-top: 12px;
font-size: 14px;
color: #999;
color: var(--text-muted);
transition: color 0.3s ease;
}
.room-meta-item {
display: flex;
display: grid;
grid-auto-flow: column;
align-items: center;
gap: 5px;
}
.empty-state {
text-align: center;
padding: 60px 20px;
color: #999;
color: var(--text-muted);
transition: color 0.3s ease;
}
.empty-state h3 {
color: #666;
color: var(--text-secondary);
margin-bottom: 10px;
transition: color 0.3s ease;
}
.auth-prompt {
background: #fff3cd;
@ -171,11 +171,10 @@
grid-template-columns: 1fr;
}
.header {
flex-direction: column;
align-items: stretch;
grid-template-columns: 1fr;
}
.header-actions {
flex-direction: column;
grid-auto-flow: row;
}
}
</style>
@ -211,7 +210,7 @@
<a href="{{ url_for('chat', room_name=room.name) }}" class="room-card">
<div class="room-card-header">
<h3 class="room-name">{{ room.name }}</h3>
<span class="room-badge">Public</span>
<span class="badge badge-public">Public</span>
</div>
{% if room.title %}
<p class="room-title">{{ room.title }}</p>
@ -242,7 +241,7 @@
<a href="{{ url_for('chat', room_name=room.name) }}" class="room-card">
<div class="room-card-header">
<h3 class="room-name">{{ room.name }}</h3>
<span class="room-badge private">Private</span>
<span class="badge badge-private">Private</span>
</div>
{% if room.title %}
<p class="room-title">{{ room.title }}</p>
@ -273,6 +272,10 @@
</div>
<script>
// Theme persistence
const savedTheme = localStorage.getItem('theme') || 'light';
document.documentElement.setAttribute('data-theme', savedTheme);
function switchTab(tab) {
// Update tab buttons
document.querySelectorAll('.room-tab').forEach(btn => {

View file

@ -5,8 +5,16 @@
{% block content %}
<div id="chat-container">
<!-- Search form -->
<div id="search-form">
<form action="/search" method="get">
<input type="text" id="search-keywords" name="keywords" placeholder="Search for keywords..." value="{{ keywords }}">
</form>
</div>
<!-- Chat area where messages will be displayed -->
<div id="chat"></div>
<!-- Form for sending messages -->
<form id="message-form">
<textarea id="message" placeholder="Type your message..."></textarea>
@ -45,11 +53,6 @@
<!-- Voices will be populated from API -->
</select>
</div>
<div>
<button id="theme-toggle-btn" onclick="toggleTheme()">
🌙 Dark Mode
</button>
</div>
<div>
<button id="auto-play-tts-btn" onclick="toggleAutoPlayTTS()" style="width: 100%; margin-top: 10px; background-color: #f44336; color: white; border: none; padding: 8px; border-radius: 4px; cursor: pointer;">
Auto-Play TTS: OFF
@ -463,14 +466,81 @@ socket.on("update_room_title", (data) => {
document.title = data.title; // Update the window's title
});
// Socket event to update the room title in the sidebar.
// Socket event to update the room title in the sidebar or add new rooms.
socket.on('update_room_list', function(updatedRoom) {
// Find the room list item by its data-room-id attribute
const roomListItem = document.querySelector(`#rooms-list li[data-room-id="${updatedRoom.id}"]`);
if (roomListItem) {
// Update the room list item's content with the new title
roomListItem.innerHTML = `<b>${updatedRoom.name}</b> ${updatedRoom.title ? '<br />' + updatedRoom.title : ''}`;
// Room exists - update it
// Extract user count from existing content (safer than regex on innerHTML)
const userCountText = roomListItem.textContent.match(/(\d+)\s*users/);
const userCount = userCountText ? userCountText[1] : null;
const ownerBadge = roomListItem.querySelector('.owner-badge');
// Clear and rebuild content safely using DOM methods
roomListItem.innerHTML = '';
// Add room name
const nameElement = document.createElement('b');
nameElement.textContent = updatedRoom.name;
roomListItem.appendChild(nameElement);
// Add room title if present
if (updatedRoom.title) {
roomListItem.appendChild(document.createElement('br'));
const titleText = document.createTextNode(updatedRoom.title);
roomListItem.appendChild(titleText);
}
// Add user count if it existed
if (userCount) {
roomListItem.appendChild(document.createElement('br'));
const userText = document.createTextNode(` ${userCount} users`);
roomListItem.appendChild(userText);
}
// Re-add owner badge if it existed
if (ownerBadge) {
roomListItem.appendChild(ownerBadge);
}
} else if (updatedRoom.is_new) {
// New room - add it to the appropriate list
const targetList = updatedRoom.is_private
? document.querySelector('#private-rooms-section .rooms-list')
: document.querySelector('#public-rooms-section .rooms-list');
if (targetList) {
// Create new room list item using safe DOM methods
const newLink = document.createElement('a');
newLink.href = `/chat/${encodeURIComponent(updatedRoom.name)}`;
const newLi = document.createElement('li');
newLi.setAttribute('data-room-id', updatedRoom.id);
if (updatedRoom.is_private) {
newLi.classList.add('private-room');
}
// Add room name safely
const nameElement = document.createElement('b');
nameElement.textContent = updatedRoom.name;
newLi.appendChild(nameElement);
// Add room title if present
if (updatedRoom.title) {
newLi.appendChild(document.createElement('br'));
const titleText = document.createTextNode(updatedRoom.title);
newLi.appendChild(titleText);
}
// Add user count
newLi.appendChild(document.createElement('br'));
const userText = document.createTextNode(' 0 users');
newLi.appendChild(userText);
newLink.appendChild(newLi);
targetList.appendChild(newLink);
}
}
});
@ -744,7 +814,7 @@ socket.on("chat_message", (data) => {
newMessage.className = "message-content";
// Check if the username is present and prepend it to the message content
const messageContent = data.username ? `**${data.username}:**\n\n${data.content}` : data.content;
const messageContent = data.username ? `**[${data.username}](/profile/${data.username}):**\n\n${data.content}` : data.content;
// Check if the message starts with a base64 image tag
if (data.content.startsWith('<img src="data:image/jpeg;base64')) {

View file

@ -1,41 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenCompletion - AI-Powered Chat Rooms</title>
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js"></script>
<script src="{{ url_for('static', filename='js/utils.js') }}"></script>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f7f7f7;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: var(--bg-page);
color: var(--text-primary);
display: grid;
place-items: center;
min-height: 100vh;
margin: 0;
padding: 20px;
transition: background-color 0.3s ease, color 0.3s ease;
}
#main-container {
background-color: #ffffff;
background-color: var(--bg-card);
border-radius: 10px;
padding: 30px;
width: 100%;
max-width: 800px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
transition: background-color 0.3s ease;
}
h1 {
color: #333;
color: var(--text-primary);
margin-bottom: 10px;
text-align: center;
transition: color 0.3s ease;
}
.tagline {
text-align: center;
color: #666;
color: var(--text-secondary);
margin-bottom: 30px;
transition: color 0.3s ease;
}
.stats-grid {
display: grid;
@ -60,40 +64,47 @@
opacity: 0.9;
}
#join-section {
background-color: #f9f9f9;
background-color: var(--bg-section);
border-radius: 8px;
padding: 25px;
margin-bottom: 20px;
transition: background-color 0.3s ease;
}
#join-section h2 {
margin-top: 0;
color: #333;
color: var(--text-primary);
transition: color 0.3s ease;
}
#join-room-form {
display: flex;
flex-direction: column;
display: grid;
gap: 10px;
}
input[type="text"] {
width: 100%;
border: 2px solid #e1e1e1;
border: 2px solid var(--border-color);
border-radius: 5px;
padding: 12px;
font-size: 16px;
box-sizing: border-box;
background-color: var(--bg-card);
color: var(--text-primary);
transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
input[type="text"]:focus {
outline: none;
border-color: #667eea;
}
.room-type-selector {
display: flex;
display: grid;
grid-auto-flow: column;
grid-auto-columns: max-content;
gap: 20px;
align-items: center;
padding: 10px 0;
}
.room-type-selector label {
display: flex;
display: grid;
grid-auto-flow: column;
align-items: center;
gap: 5px;
cursor: pointer;
@ -119,12 +130,13 @@
.auth-status {
text-align: center;
padding: 15px;
background: #e7f3ff;
background: var(--bg-status);
border-radius: 8px;
margin-bottom: 20px;
transition: background-color 0.3s ease;
}
.auth-status.logged-in {
background: #d4edda;
background: var(--bg-status-logged);
}
.browse-link {
text-align: center;
@ -206,6 +218,10 @@
</div>
<script>
// Theme persistence
const savedTheme = localStorage.getItem('theme') || 'light';
document.documentElement.setAttribute('data-theme', savedTheme);
document.getElementById('join-room-form').addEventListener('submit', async function(e) {
e.preventDefault();
const roomInput = document.getElementById('room').value.trim();

View file

@ -40,42 +40,71 @@
font-family: Arial, sans-serif;
background-color: var(--bg-secondary);
color: var(--text-primary);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 20px;
transition: background-color 0.3s, color 0.3s;
}
#main-container {
background-color: var(--bg-primary);
border-radius: 10px;
padding: 30px;
width: 100%;
max-width: 600px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
.header {
max-width: 1400px;
margin: 0 auto 30px;
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
gap: 15px;
}
h1 {
.header h1 {
color: var(--text-primary);
margin-bottom: 10px;
text-align: center;
margin: 0;
transition: color 0.3s;
}
.header-actions {
display: grid;
grid-auto-flow: column;
gap: 10px;
}
.btn {
background: linear-gradient(135deg, var(--button-primary) 0%, var(--button-hover) 100%);
color: white;
border: none;
border-radius: 5px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
text-decoration: none;
display: inline-block;
transition: transform 0.2s;
}
.btn:hover {
transform: translateY(-2px);
}
.btn-secondary {
background: #6c757d;
}
.content-container {
max-width: 800px;
margin: 0 auto;
}
.subtitle {
text-align: center;
color: var(--text-secondary);
margin-bottom: 30px;
transition: color 0.3s;
}
.section {
background-color: var(--bg-secondary);
background-color: var(--bg-primary);
border-radius: 8px;
padding: 25px;
margin-bottom: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.section h2 {
@ -117,6 +146,11 @@
font-size: 14px;
margin-top: 5px;
min-height: 20px;
display: none;
}
.availability-indicator.show {
display: block;
}
.available {
@ -191,19 +225,13 @@
margin-bottom: 5px;
}
.back-link {
text-align: center;
margin-top: 20px;
}
.back-link a {
color: var(--button-primary);
text-decoration: none;
font-weight: bold;
}
.back-link a:hover {
text-decoration: underline;
@media (max-width: 768px) {
.header {
grid-template-columns: 1fr;
}
.header-actions {
grid-auto-flow: row;
}
}
.message {
@ -229,8 +257,15 @@
</style>
</head>
<body>
<div id="main-container">
<h1>Profile Settings</h1>
<div class="header">
<h1>⚙️ Profile Settings</h1>
<div class="header-actions">
<a href="/" class="btn">🏠 Home</a>
<a href="/browse" class="btn btn-secondary">📋 Browse Rooms</a>
</div>
</div>
<div class="content-container">
<p class="subtitle">Manage your account preferences</p>
<!-- Username Section -->
@ -271,10 +306,6 @@
</div>
</div>
</div>
<div class="back-link">
<a href="/">← Back to Home</a>
</div>
</div>
<script>
@ -306,9 +337,21 @@
// Clear previous timeout
clearTimeout(checkTimeout);
// Reset if empty or same as current
if (!username || username === currentUsername) {
// Hide indicator and disable button if same as current username
if (username === currentUsername) {
indicator.textContent = '';
indicator.classList.remove('show');
submitBtn.disabled = true;
return;
}
// Show indicator when username changes
indicator.classList.add('show');
// Reset if empty
if (!username) {
indicator.textContent = '';
indicator.classList.remove('show');
submitBtn.disabled = true;
return;
}
@ -317,14 +360,14 @@
const isValid = /^[a-zA-Z0-9_-]{3,50}$/.test(username);
if (!isValid) {
indicator.textContent = 'Invalid format (3-50 chars: letters, numbers, _, -)';
indicator.className = 'availability-indicator unavailable';
indicator.className = 'availability-indicator unavailable show';
submitBtn.disabled = true;
return;
}
// Check availability after 500ms delay
indicator.textContent = 'Checking availability...';
indicator.className = 'availability-indicator';
indicator.className = 'availability-indicator show';
checkTimeout = setTimeout(async () => {
try {
@ -333,16 +376,16 @@
if (data.available) {
indicator.textContent = '✓ Username is available';
indicator.className = 'availability-indicator available';
indicator.className = 'availability-indicator available show';
submitBtn.disabled = false;
} else {
indicator.textContent = '✗ Username is already taken';
indicator.className = 'availability-indicator unavailable';
indicator.className = 'availability-indicator unavailable show';
submitBtn.disabled = true;
}
} catch (error) {
indicator.textContent = 'Error checking availability';
indicator.className = 'availability-indicator unavailable';
indicator.className = 'availability-indicator unavailable show';
submitBtn.disabled = true;
}
}, 500);

View file

@ -1,40 +1,67 @@
{% extends "base.html" %}
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search Results - OpenCompletion</title>
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<div class="header">
<h1>🔍 Search Results</h1>
<div class="header-actions">
<a href="/" class="btn">🏠 Home</a>
<a href="/browse" class="btn btn-secondary">📋 Browse Rooms</a>
{% if user %}
<a href="/profile" class="btn btn-secondary">👤 {{ user.display_name }}</a>
{% else %}
<a href="/auth" class="btn btn-secondary">🔐 Sign In</a>
{% endif %}
</div>
</div>
{% block title %}Search Results{% endblock %}
{% block content %}
<style>
/* Add styles for the search results */
#search-results {
margin: 20px;
width: 100%;
}
.search-result {
border: 1px solid #e1e1e1;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
width: 100%;
}
</style>
<div id="search-results">
{% if error %}
<div class="search-result">{{ error }}</div>
{% elif results %}
{% for result in results %}
<div class="search-result">
<a href="/chat/{{ result.room_name }}?username={{ username }}">
<b>{{ result.room_name }}</b><br/>
{{ result.room_title or "No title" }}</br>
<b>Score:</b> {{ result.score }}
</a>
</div>
<br/>
{% endfor %}
{% else %}
<div class="search-result">No results found.</div>
<div class="alert alert-error">{{ error }}</div>
{% endif %}
</div>
{% endblock %}
{% if results %}
<div class="search-info">
Found <strong>{{ results|length }}</strong> result{{ 's' if results|length != 1 else '' }}
</div>
<div class="results-container">
<div class="rooms-grid">
{% for result in results %}
<a href="{{ url_for('chat', room_name=result.room_name) }}" class="room-card">
<div class="room-card-header">
<h3 class="room-name">{{ result.room_name }}</h3>
<span class="room-badge">Score: {{ "%.2f"|format(result.score) }}</span>
</div>
{% if result.room_title %}
<p class="room-title">{{ result.room_title }}</p>
{% else %}
<p class="room-title">Untitled Room</p>
{% endif %}
</a>
{% endfor %}
</div>
</div>
{% elif not error %}
<div class="results-container">
<div class="empty-state">
<div class="empty-state-icon">🔍</div>
<h3>No results found</h3>
<p>Try searching for different keywords</p>
<a href="/browse" class="btn" style="margin-top: 20px;">Browse All Rooms</a>
</div>
</div>
{% endif %}
<script>
// Theme persistence
const savedTheme = localStorage.getItem('theme') || 'light';
document.documentElement.setAttribute('data-theme', savedTheme);
</script>
</body>
</html>