یک پیام رسان واقعی مانند discord بساز، به طور کاملا واقعی کار کنه، کاملا واقعی باشه، ثبت نام بدون نیاز به ایمیل، نیازی نیست GUI همانند discord باشه، فقط عملکرد همانند discord باشه
Browse files- README.md +7 -4
- index.html +367 -18
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
colorFrom: pink
|
| 5 |
colorTo: purple
|
|
|
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: ChatVerse 🌌
|
| 3 |
+
colorFrom: red
|
|
|
|
| 4 |
colorTo: purple
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://deepsite.hf.co).
|
index.html
CHANGED
|
@@ -1,19 +1,368 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>ChatVerse - Connect & Chat</title>
|
| 7 |
+
<link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🌌</text></svg>">
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
+
<style>
|
| 12 |
+
@keyframes float {
|
| 13 |
+
0%, 100% { transform: translateY(0px); }
|
| 14 |
+
50% { transform: translateY(-20px); }
|
| 15 |
+
}
|
| 16 |
+
.float-animation {
|
| 17 |
+
animation: float 6s ease-in-out infinite;
|
| 18 |
+
}
|
| 19 |
+
.message-bubble {
|
| 20 |
+
animation: slideIn 0.3s ease-out;
|
| 21 |
+
}
|
| 22 |
+
@keyframes slideIn {
|
| 23 |
+
from {
|
| 24 |
+
opacity: 0;
|
| 25 |
+
transform: translateY(10px);
|
| 26 |
+
}
|
| 27 |
+
to {
|
| 28 |
+
opacity: 1;
|
| 29 |
+
transform: translateY(0);
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
.typing-indicator span {
|
| 33 |
+
animation: typing 1.4s infinite ease-in-out;
|
| 34 |
+
}
|
| 35 |
+
.typing-indicator span:nth-child(2) {
|
| 36 |
+
animation-delay: 0.2s;
|
| 37 |
+
}
|
| 38 |
+
.typing-indicator span:nth-child(3) {
|
| 39 |
+
animation-delay: 0.4s;
|
| 40 |
+
}
|
| 41 |
+
@keyframes typing {
|
| 42 |
+
0%, 60%, 100% {
|
| 43 |
+
transform: translateY(0);
|
| 44 |
+
}
|
| 45 |
+
30% {
|
| 46 |
+
transform: translateY(-10px);
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
</style>
|
| 50 |
+
</head>
|
| 51 |
+
<body class="bg-gradient-to-br from-purple-900 via-blue-900 to-indigo-900 min-h-screen">
|
| 52 |
+
<!-- Login Screen -->
|
| 53 |
+
<div id="loginScreen" class="min-h-screen flex items-center justify-center p-4">
|
| 54 |
+
<div class="bg-white/10 backdrop-blur-lg rounded-3xl p-8 max-w-md w-full shadow-2xl border border-white/20">
|
| 55 |
+
<div class="text-center mb-8">
|
| 56 |
+
<div class="float-animation">
|
| 57 |
+
<h1 class="text-5xl font-bold text-white mb-2">ChatVerse</h1>
|
| 58 |
+
<p class="text-purple-200">Connect with the universe 🌌</p>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
<form id="loginForm" class="space-y-6">
|
| 62 |
+
<div>
|
| 63 |
+
<label class="block text-purple-200 mb-2">Choose your username</label>
|
| 64 |
+
<input type="text" id="username" required
|
| 65 |
+
class="w-full px-4 py-3 rounded-xl bg-white/20 backdrop-blur text-white placeholder-purple-200 border border-purple-300/30 focus:outline-none focus:border-purple-400 transition"
|
| 66 |
+
placeholder="Enter username">
|
| 67 |
+
</div>
|
| 68 |
+
<button type="submit"
|
| 69 |
+
class="w-full bg-gradient-to-r from-purple-500 to-pink-500 text-white py-3 rounded-xl font-semibold hover:from-purple-600 hover:to-pink-600 transform hover:scale-105 transition duration-300 shadow-lg">
|
| 70 |
+
Join ChatVerse
|
| 71 |
+
</button>
|
| 72 |
+
</form>
|
| 73 |
+
</div>
|
| 74 |
+
</div>
|
| 75 |
+
|
| 76 |
+
<!-- Chat Interface -->
|
| 77 |
+
<div id="chatInterface" class="hidden h-screen flex flex-col">
|
| 78 |
+
<!-- Header -->
|
| 79 |
+
<header class="bg-white/10 backdrop-blur-lg border-b border-white/20 p-4">
|
| 80 |
+
<div class="flex items-center justify-between max-w-7xl mx-auto">
|
| 81 |
+
<div class="flex items-center space-x-3">
|
| 82 |
+
<h1 class="text-2xl font-bold text-white">ChatVerse</h1>
|
| 83 |
+
<span class="bg-green-400 w-3 h-3 rounded-full animate-pulse"></span>
|
| 84 |
+
</div>
|
| 85 |
+
<div class="flex items-center space-x-4">
|
| 86 |
+
<span id="currentUser" class="text-purple-200"></span>
|
| 87 |
+
<button onclick="logout()" class="text-purple-200 hover:text-white transition">
|
| 88 |
+
<i data-feather="log-out"></i>
|
| 89 |
+
</button>
|
| 90 |
+
</div>
|
| 91 |
+
</div>
|
| 92 |
+
</header>
|
| 93 |
+
|
| 94 |
+
<div class="flex-1 flex overflow-hidden">
|
| 95 |
+
<!-- Sidebar - Online Users -->
|
| 96 |
+
<aside class="w-64 bg-white/5 backdrop-blur-lg border-r border-white/10 p-4 overflow-y-auto">
|
| 97 |
+
<h2 class="text-purple-200 font-semibold mb-4 flex items-center">
|
| 98 |
+
<i data-feather="users" class="w-4 h-4 mr-2"></i>
|
| 99 |
+
Online Users (<span id="onlineCount">0</span>)
|
| 100 |
+
</h2>
|
| 101 |
+
<div id="usersList" class="space-y-2">
|
| 102 |
+
<!-- Users will be populated here -->
|
| 103 |
+
</div>
|
| 104 |
+
</aside>
|
| 105 |
+
|
| 106 |
+
<!-- Main Chat Area -->
|
| 107 |
+
<main class="flex-1 flex flex-col">
|
| 108 |
+
<!-- Messages Container -->
|
| 109 |
+
<div id="messagesContainer" class="flex-1 overflow-y-auto p-6 space-y-4">
|
| 110 |
+
<!-- Messages will appear here -->
|
| 111 |
+
</div>
|
| 112 |
+
|
| 113 |
+
<!-- Typing Indicator -->
|
| 114 |
+
<div id="typingIndicator" class="px-6 py-2 hidden">
|
| 115 |
+
<div class="typing-indicator flex items-center space-x-1 text-purple-300">
|
| 116 |
+
<span class="w-2 h-2 bg-purple-300 rounded-full"></span>
|
| 117 |
+
<span class="w-2 h-2 bg-purple-300 rounded-full"></span>
|
| 118 |
+
<span class="w-2 h-2 bg-purple-300 rounded-full"></span>
|
| 119 |
+
<span class="text-sm ml-2" id="typingText"></span>
|
| 120 |
+
</div>
|
| 121 |
+
</div>
|
| 122 |
+
|
| 123 |
+
<!-- Message Input -->
|
| 124 |
+
<div class="bg-white/10 backdrop-blur-lg border-t border-white/20 p-4">
|
| 125 |
+
<form id="messageForm" class="flex space-x-3">
|
| 126 |
+
<input type="text" id="messageInput"
|
| 127 |
+
placeholder="Type your message..."
|
| 128 |
+
class="flex-1 px-4 py-3 rounded-xl bg-white/20 backdrop-blur text-white placeholder-purple-200 border border-purple-300/30 focus:outline-none focus:border-purple-400 transition"
|
| 129 |
+
autocomplete="off">
|
| 130 |
+
<button type="submit"
|
| 131 |
+
class="bg-gradient-to-r from-purple-500 to-pink-500 text-white px-6 py-3 rounded-xl hover:from-purple-600 hover:to-pink-600 transform hover:scale-105 transition duration-300 shadow-lg">
|
| 132 |
+
<i data-feather="send" class="w-5 h-5"></i>
|
| 133 |
+
</button>
|
| 134 |
+
</form>
|
| 135 |
+
</div>
|
| 136 |
+
</main>
|
| 137 |
+
</div>
|
| 138 |
+
</div>
|
| 139 |
+
|
| 140 |
+
<script>
|
| 141 |
+
// Simple WebSocket-like simulation using localStorage and BroadcastChannel
|
| 142 |
+
class ChatSystem {
|
| 143 |
+
constructor() {
|
| 144 |
+
this.currentUser = null;
|
| 145 |
+
this.users = new Set();
|
| 146 |
+
this.messages = [];
|
| 147 |
+
this.broadcastChannel = new BroadcastChannel('chatverse');
|
| 148 |
+
this.typingTimeout = null;
|
| 149 |
+
this.isTyping = false;
|
| 150 |
+
|
| 151 |
+
this.broadcastChannel.onmessage = (event) => {
|
| 152 |
+
const { type, data } = event.data;
|
| 153 |
+
this.handleMessage(type, data);
|
| 154 |
+
};
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
handleMessage(type, data) {
|
| 158 |
+
switch(type) {
|
| 159 |
+
case 'userJoined':
|
| 160 |
+
this.addUser(data.username);
|
| 161 |
+
break;
|
| 162 |
+
case 'userLeft':
|
| 163 |
+
this.removeUser(data.username);
|
| 164 |
+
break;
|
| 165 |
+
case 'message':
|
| 166 |
+
this.addMessage(data);
|
| 167 |
+
break;
|
| 168 |
+
case 'typing':
|
| 169 |
+
this.showTyping(data.username);
|
| 170 |
+
break;
|
| 171 |
+
case 'stopTyping':
|
| 172 |
+
this.hideTyping();
|
| 173 |
+
break;
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
broadcast(type, data) {
|
| 178 |
+
this.broadcastChannel.postMessage({ type, data });
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
login(username) {
|
| 182 |
+
this.currentUser = username;
|
| 183 |
+
localStorage.setItem('currentUser', username);
|
| 184 |
+
this.broadcast('userJoined', { username });
|
| 185 |
+
this.addUser(username);
|
| 186 |
+
this.loadMessages();
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
logout() {
|
| 190 |
+
if (this.currentUser) {
|
| 191 |
+
this.broadcast('userLeft', { username: this.currentUser });
|
| 192 |
+
localStorage.removeItem('currentUser');
|
| 193 |
+
this.removeUser(this.currentUser);
|
| 194 |
+
this.currentUser = null;
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
addUser(username) {
|
| 199 |
+
this.users.add(username);
|
| 200 |
+
this.updateUsersList();
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
removeUser(username) {
|
| 204 |
+
this.users.delete(username);
|
| 205 |
+
this.updateUsersList();
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
updateUsersList() {
|
| 209 |
+
const usersList = document.getElementById('usersList');
|
| 210 |
+
const onlineCount = document.getElementById('onlineCount');
|
| 211 |
+
|
| 212 |
+
usersList.innerHTML = '';
|
| 213 |
+
onlineCount.textContent = this.users.size;
|
| 214 |
+
|
| 215 |
+
this.users.forEach(username => {
|
| 216 |
+
const userDiv = document.createElement('div');
|
| 217 |
+
userDiv.className = 'flex items-center space-x-2 p-2 rounded-lg hover:bg-white/10 transition cursor-pointer';
|
| 218 |
+
userDiv.innerHTML = `
|
| 219 |
+
<div class="w-2 h-2 bg-green-400 rounded-full"></div>
|
| 220 |
+
<span class="text-purple-200">${username}</span>
|
| 221 |
+
${username === this.currentUser ? '<span class="text-xs text-purple-400">(You)</span>' : ''}
|
| 222 |
+
`;
|
| 223 |
+
usersList.appendChild(userDiv);
|
| 224 |
+
});
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
sendMessage(content) {
|
| 228 |
+
const message = {
|
| 229 |
+
id: Date.now(),
|
| 230 |
+
username: this.currentUser,
|
| 231 |
+
content: content,
|
| 232 |
+
timestamp: new Date().toISOString()
|
| 233 |
+
};
|
| 234 |
+
|
| 235 |
+
this.messages.push(message);
|
| 236 |
+
this.broadcast('message', message);
|
| 237 |
+
this.addMessage(message);
|
| 238 |
+
this.saveMessages();
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
addMessage(message) {
|
| 242 |
+
const messagesContainer = document.getElementById('messagesContainer');
|
| 243 |
+
const messageDiv = document.createElement('div');
|
| 244 |
+
messageDiv.className = `message-bubble flex ${message.username === this.currentUser ? 'justify-end' : 'justify-start'}`;
|
| 245 |
+
|
| 246 |
+
const time = new Date(message.timestamp).toLocaleTimeString('en-US', {
|
| 247 |
+
hour: '2-digit',
|
| 248 |
+
minute: '2-digit'
|
| 249 |
+
});
|
| 250 |
+
|
| 251 |
+
messageDiv.innerHTML = `
|
| 252 |
+
<div class="max-w-xs lg:max-w-md px-4 py-2 rounded-2xl ${
|
| 253 |
+
message.username === this.currentUser
|
| 254 |
+
? 'bg-gradient-to-r from-purple-500 to-pink-500 text-white'
|
| 255 |
+
: 'bg-white/20 backdrop-blur text-purple-100'
|
| 256 |
+
}">
|
| 257 |
+
<div class="flex items-baseline space-x-2">
|
| 258 |
+
<span class="font-semibold text-sm">${message.username}</span>
|
| 259 |
+
<span class="text-xs opacity-70">${time}</span>
|
| 260 |
+
</div>
|
| 261 |
+
<p class="mt-1">${message.content}</p>
|
| 262 |
+
</div>
|
| 263 |
+
`;
|
| 264 |
+
|
| 265 |
+
messagesContainer.appendChild(messageDiv);
|
| 266 |
+
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
showTyping(username) {
|
| 270 |
+
if (username === this.currentUser) return;
|
| 271 |
+
|
| 272 |
+
const typingIndicator = document.getElementById('typingIndicator');
|
| 273 |
+
const typingText = document.getElementById('typingText');
|
| 274 |
+
|
| 275 |
+
typingText.textContent = `${username} is typing...`;
|
| 276 |
+
typingIndicator.classList.remove('hidden');
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
hideTyping() {
|
| 280 |
+
document.getElementById('typingIndicator').classList.add('hidden');
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
handleTyping() {
|
| 284 |
+
if (!this.isTyping) {
|
| 285 |
+
this.isTyping = true;
|
| 286 |
+
this.broadcast('typing', { username: this.currentUser });
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
clearTimeout(this.typingTimeout);
|
| 290 |
+
this.typingTimeout = setTimeout(() => {
|
| 291 |
+
this.isTyping = false;
|
| 292 |
+
this.broadcast('stopTyping', {});
|
| 293 |
+
}, 1000);
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
saveMessages() {
|
| 297 |
+
localStorage.setItem('chatMessages', JSON.stringify(this.messages));
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
loadMessages() {
|
| 301 |
+
const saved = localStorage.getItem('chatMessages');
|
| 302 |
+
if (saved) {
|
| 303 |
+
this.messages = JSON.parse(saved);
|
| 304 |
+
this.messages.forEach(msg => this.addMessage(msg));
|
| 305 |
+
}
|
| 306 |
+
}
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
// Initialize chat system
|
| 310 |
+
const chatSystem = new ChatSystem();
|
| 311 |
+
|
| 312 |
+
// Check if user is already logged in
|
| 313 |
+
window.addEventListener('DOMContentLoaded', () => {
|
| 314 |
+
const savedUser = localStorage.getItem('currentUser');
|
| 315 |
+
if (savedUser) {
|
| 316 |
+
showChatInterface(savedUser);
|
| 317 |
+
}
|
| 318 |
+
});
|
| 319 |
+
|
| 320 |
+
// Login form handler
|
| 321 |
+
document.getElementById('loginForm').addEventListener('submit', (e) => {
|
| 322 |
+
e.preventDefault();
|
| 323 |
+
const username = document.getElementById('username').value.trim();
|
| 324 |
+
if (username) {
|
| 325 |
+
chatSystem.login(username);
|
| 326 |
+
showChatInterface(username);
|
| 327 |
+
}
|
| 328 |
+
});
|
| 329 |
+
|
| 330 |
+
// Message form handler
|
| 331 |
+
document.getElementById('messageForm').addEventListener('submit', (e) => {
|
| 332 |
+
e.preventDefault();
|
| 333 |
+
const input = document.getElementById('messageInput');
|
| 334 |
+
const message = input.value.trim();
|
| 335 |
+
if (message) {
|
| 336 |
+
chatSystem.sendMessage(message);
|
| 337 |
+
input.value = '';
|
| 338 |
+
chatSystem.hideTyping();
|
| 339 |
+
}
|
| 340 |
+
});
|
| 341 |
+
|
| 342 |
+
// Typing indicator
|
| 343 |
+
document.getElementById('messageInput').addEventListener('input', () => {
|
| 344 |
+
chatSystem.handleTyping();
|
| 345 |
+
});
|
| 346 |
+
|
| 347 |
+
// Show chat interface
|
| 348 |
+
function showChatInterface(username) {
|
| 349 |
+
document.getElementById('loginScreen').classList.add('hidden');
|
| 350 |
+
document.getElementById('chatInterface').classList.remove('hidden');
|
| 351 |
+
document.getElementById('currentUser').textContent = username;
|
| 352 |
+
feather.replace();
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
// Logout
|
| 356 |
+
function logout() {
|
| 357 |
+
chatSystem.logout();
|
| 358 |
+
document.getElementById('chatInterface').classList.add('hidden');
|
| 359 |
+
document.getElementById('loginScreen').classList.remove('hidden');
|
| 360 |
+
document.getElementById('messagesContainer').innerHTML = '';
|
| 361 |
+
document.getElementById('username').value = '';
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
// Replace feather icons
|
| 365 |
+
feather.replace();
|
| 366 |
+
</script>
|
| 367 |
+
</body>
|
| 368 |
</html>
|