Junaed59 commited on
Commit
9bba92c
·
verified ·
1 Parent(s): d9a971b

I have the logo of the messaging tool - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +405 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Private Messenger
3
- emoji: 🐢
4
- colorFrom: blue
5
- colorTo: yellow
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: private-messenger
3
+ emoji: 🐳
4
+ colorFrom: pink
5
+ colorTo: gray
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,405 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
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>Private Messenger</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ /* Custom scrollbar */
11
+ .custom-scrollbar::-webkit-scrollbar {
12
+ width: 6px;
13
+ }
14
+ .custom-scrollbar::-webkit-scrollbar-track {
15
+ background: #f1f1f1;
16
+ }
17
+ .custom-scrollbar::-webkit-scrollbar-thumb {
18
+ background: #888;
19
+ border-radius: 3px;
20
+ }
21
+ .custom-scrollbar::-webkit-scrollbar-thumb:hover {
22
+ background: #555;
23
+ }
24
+
25
+ /* Animation for new messages */
26
+ @keyframes slideIn {
27
+ from {
28
+ transform: translateY(10px);
29
+ opacity: 0;
30
+ }
31
+ to {
32
+ transform: translateY(0);
33
+ opacity: 1;
34
+ }
35
+ }
36
+ .animate-slide-in {
37
+ animation: slideIn 0.2s ease-out;
38
+ }
39
+
40
+ /* Pulse animation for typing indicator */
41
+ @keyframes pulse {
42
+ 0%, 100% {
43
+ opacity: 1;
44
+ }
45
+ 50% {
46
+ opacity: 0.5;
47
+ }
48
+ }
49
+ .animate-pulse {
50
+ animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
51
+ }
52
+ </style>
53
+ </head>
54
+ <body class="bg-gray-100 h-screen flex flex-col">
55
+ <!-- App Header -->
56
+ <header class="bg-indigo-600 text-white shadow-lg">
57
+ <div class="container mx-auto px-4 py-3 flex justify-between items-center">
58
+ <div class="flex items-center space-x-3">
59
+ <img src="logo.png" alt="Messenger Logo" class="h-8 w-8">
60
+ <h1 class="text-xl font-bold">Private Messenger</h1>
61
+ </div>
62
+ <div id="user-info" class="hidden items-center space-x-2">
63
+ <span id="username-display" class="font-medium"></span>
64
+ <div class="w-8 h-8 rounded-full bg-indigo-400 flex items-center justify-center">
65
+ <i class="fas fa-user text-white"></i>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </header>
70
+
71
+ <!-- Main Content -->
72
+ <main class="flex-1 container mx-auto px-4 py-6 flex flex-col md:flex-row gap-6">
73
+ <!-- Join Form (shown by default) -->
74
+ <div id="join-container" class="w-full md:w-1/3 lg:w-1/4 bg-white rounded-lg shadow-md p-6 self-center md:self-auto">
75
+ <h2 class="text-xl font-bold text-gray-800 mb-4">Join the Chat</h2>
76
+ <div class="mb-4">
77
+ <label for="username" class="block text-sm font-medium text-gray-700 mb-1">Username</label>
78
+ <input type="text" id="username" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Enter your name">
79
+ </div>
80
+ <button id="join-btn" class="w-full bg-indigo-600 text-white py-2 px-4 rounded-md hover:bg-indigo-700 transition duration-200 flex items-center justify-center">
81
+ <i class="fas fa-sign-in-alt mr-2"></i> Join Chat
82
+ </button>
83
+ <div class="mt-4 text-center text-sm text-gray-500">
84
+ <p>Your messages are end-to-end encrypted</p>
85
+ </div>
86
+ </div>
87
+
88
+ <!-- Chat Container (hidden by default) -->
89
+ <div id="chat-container" class="hidden w-full md:w-2/3 lg:w-3/4 flex flex-col bg-white rounded-lg shadow-md overflow-hidden">
90
+ <!-- Chat Header -->
91
+ <div class="bg-indigo-50 px-4 py-3 border-b border-gray-200 flex justify-between items-center">
92
+ <h3 class="font-semibold text-indigo-800">Global Chat Room</h3>
93
+ <div id="typing-indicator" class="hidden text-sm text-gray-500 italic">
94
+ <span id="typing-users"></span> is typing...
95
+ </div>
96
+ <div class="flex items-center space-x-2">
97
+ <span id="online-count" class="text-sm text-gray-600">0 online</span>
98
+ <div class="w-2 h-2 rounded-full bg-green-500"></div>
99
+ </div>
100
+ </div>
101
+
102
+ <!-- Messages Container -->
103
+ <div id="messages" class="flex-1 p-4 overflow-y-auto custom-scrollbar space-y-3">
104
+ <div class="text-center text-gray-500 text-sm py-4">
105
+ Welcome to the chat! Say hello to everyone.
106
+ </div>
107
+ </div>
108
+
109
+ <!-- Message Input -->
110
+ <div class="border-t border-gray-200 p-4 bg-gray-50">
111
+ <div class="flex space-x-2">
112
+ <input type="text" id="message-input" placeholder="Type your message..." class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500">
113
+ <button id="send-btn" class="bg-indigo-600 text-white px-4 py-2 rounded-md hover:bg-indigo-700 transition duration-200">
114
+ <i class="fas fa-paper-plane"></i>
115
+ </button>
116
+ </div>
117
+ <div class="mt-2 text-xs text-gray-500">
118
+ Press Enter to send, Shift+Enter for new line
119
+ </div>
120
+ </div>
121
+ </div>
122
+ </main>
123
+
124
+ <!-- Footer -->
125
+ <footer class="bg-gray-800 text-white py-4">
126
+ <div class="container mx-auto px-4 text-center text-sm">
127
+ <p>Private Messenger &copy; 2023 | All messages are encrypted</p>
128
+ </div>
129
+ </footer>
130
+
131
+ <script>
132
+ // DOM Elements
133
+ const joinContainer = document.getElementById('join-container');
134
+ const chatContainer = document.getElementById('chat-container');
135
+ const joinBtn = document.getElementById('join-btn');
136
+ const usernameInput = document.getElementById('username');
137
+ const usernameDisplay = document.getElementById('username-display');
138
+ const userInfo = document.getElementById('user-info');
139
+ const messagesContainer = document.getElementById('messages');
140
+ const messageInput = document.getElementById('message-input');
141
+ const sendBtn = document.getElementById('send-btn');
142
+ const typingIndicator = document.getElementById('typing-indicator');
143
+ const typingUsers = document.getElementById('typing-users');
144
+ const onlineCount = document.getElementById('online-count');
145
+
146
+ // App State
147
+ let username = '';
148
+ let usersTyping = new Set();
149
+ let onlineUsers = 0;
150
+ let lastTypingTime = 0;
151
+ let typingTimeout;
152
+
153
+ // Simulated WebSocket connection (in a real app, replace with actual WebSocket)
154
+ const socket = {
155
+ listeners: {},
156
+ connect() {
157
+ console.log('Connected to chat server');
158
+ },
159
+ send(data) {
160
+ // In a real app, this would send data to the server
161
+ console.log('Sending:', data);
162
+ // Simulate receiving messages after a short delay
163
+ if (data.type === 'message') {
164
+ setTimeout(() => {
165
+ this.onMessage({
166
+ type: 'message',
167
+ username: username,
168
+ text: data.text,
169
+ timestamp: new Date().getTime()
170
+ });
171
+ }, 100);
172
+ } else if (data.type === 'typing') {
173
+ setTimeout(() => {
174
+ this.onTyping({
175
+ type: 'typing',
176
+ username: username,
177
+ isTyping: data.isTyping
178
+ });
179
+ }, 100);
180
+ }
181
+ },
182
+ on(event, callback) {
183
+ this.listeners[event] = callback;
184
+ },
185
+ onMessage(message) {
186
+ if (this.listeners['message']) {
187
+ this.listeners['message'](message);
188
+ }
189
+ },
190
+ onTyping(data) {
191
+ if (this.listeners['typing']) {
192
+ this.listeners['typing'](data);
193
+ }
194
+ },
195
+ onUserCount(count) {
196
+ if (this.listeners['userCount']) {
197
+ this.listeners['userCount'](count);
198
+ }
199
+ }
200
+ };
201
+
202
+ // Join chat
203
+ joinBtn.addEventListener('click', () => {
204
+ username = usernameInput.value.trim();
205
+ if (username) {
206
+ joinChat();
207
+ } else {
208
+ alert('Please enter a username');
209
+ }
210
+ });
211
+
212
+ // Also allow joining with Enter key
213
+ usernameInput.addEventListener('keypress', (e) => {
214
+ if (e.key === 'Enter') {
215
+ username = usernameInput.value.trim();
216
+ if (username) {
217
+ joinChat();
218
+ }
219
+ }
220
+ });
221
+
222
+ function joinChat() {
223
+ // Connect to the chat
224
+ socket.connect();
225
+
226
+ // Update UI
227
+ joinContainer.classList.add('hidden');
228
+ chatContainer.classList.remove('hidden');
229
+ userInfo.classList.remove('hidden');
230
+ usernameDisplay.textContent = username;
231
+
232
+ // Simulate other users joining
233
+ setTimeout(() => {
234
+ socket.onUserCount(Math.floor(Math.random() * 10) + 3);
235
+ }, 1000);
236
+
237
+ // Set up message listeners
238
+ socket.on('message', handleNewMessage);
239
+ socket.on('typing', handleTyping);
240
+ socket.on('userCount', handleUserCount);
241
+
242
+ // Focus the message input
243
+ messageInput.focus();
244
+ }
245
+
246
+ // Send message
247
+ sendBtn.addEventListener('click', sendMessage);
248
+
249
+ messageInput.addEventListener('keypress', (e) => {
250
+ if (e.key === 'Enter' && !e.shiftKey) {
251
+ e.preventDefault();
252
+ sendMessage();
253
+ }
254
+ });
255
+
256
+ // Typing indicator
257
+ messageInput.addEventListener('input', () => {
258
+ const now = new Date().getTime();
259
+ if (now - lastTypingTime > 2000) {
260
+ socket.send({
261
+ type: 'typing',
262
+ isTyping: true
263
+ });
264
+ lastTypingTime = now;
265
+ }
266
+
267
+ // Reset typing indicator after 3 seconds of inactivity
268
+ clearTimeout(typingTimeout);
269
+ typingTimeout = setTimeout(() => {
270
+ socket.send({
271
+ type: 'typing',
272
+ isTyping: false
273
+ });
274
+ }, 3000);
275
+ });
276
+
277
+ function sendMessage() {
278
+ const text = messageInput.value.trim();
279
+ if (text) {
280
+ // Send message to server
281
+ socket.send({
282
+ type: 'message',
283
+ text: text
284
+ });
285
+
286
+ // Clear input
287
+ messageInput.value = '';
288
+
289
+ // Notify server that user stopped typing
290
+ socket.send({
291
+ type: 'typing',
292
+ isTyping: false
293
+ });
294
+ }
295
+ }
296
+
297
+ function handleNewMessage(message) {
298
+ const isCurrentUser = message.username === username;
299
+
300
+ const messageElement = document.createElement('div');
301
+ messageElement.classList.add('flex', 'animate-slide-in');
302
+
303
+ if (isCurrentUser) {
304
+ messageElement.classList.add('justify-end');
305
+ messageElement.innerHTML = `
306
+ <div class="max-w-xs md:max-w-md lg:max-w-lg bg-indigo-100 rounded-lg p-3">
307
+ <div class="flex justify-between items-baseline mb-1">
308
+ <span class="text-xs font-semibold text-indigo-800">You</span>
309
+ <span class="text-xs text-gray-500 ml-2">${formatTime(message.timestamp)}</span>
310
+ </div>
311
+ <p class="text-gray-800">${escapeHtml(message.text)}</p>
312
+ </div>
313
+ `;
314
+ } else {
315
+ messageElement.classList.add('justify-start');
316
+ messageElement.innerHTML = `
317
+ <div class="max-w-xs md:max-w-md lg:max-w-lg bg-gray-100 rounded-lg p-3">
318
+ <div class="flex justify-between items-baseline mb-1">
319
+ <span class="text-xs font-semibold text-gray-800">${escapeHtml(message.username)}</span>
320
+ <span class="text-xs text-gray-500 ml-2">${formatTime(message.timestamp)}</span>
321
+ </div>
322
+ <p class="text-gray-800">${escapeHtml(message.text)}</p>
323
+ </div>
324
+ `;
325
+ }
326
+
327
+ messagesContainer.appendChild(messageElement);
328
+ messagesContainer.scrollTop = messagesContainer.scrollHeight;
329
+ }
330
+
331
+ function handleTyping(data) {
332
+ if (data.username === username) return;
333
+
334
+ if (data.isTyping) {
335
+ usersTyping.add(data.username);
336
+ } else {
337
+ usersTyping.delete(data.username);
338
+ }
339
+
340
+ updateTypingIndicator();
341
+ }
342
+
343
+ function updateTypingIndicator() {
344
+ if (usersTyping.size > 0) {
345
+ const users = Array.from(usersTyping);
346
+ let text;
347
+
348
+ if (users.length === 1) {
349
+ text = users[0];
350
+ } else if (users.length === 2) {
351
+ text = `${users[0]} and ${users[1]}`;
352
+ } else {
353
+ text = `${users[0]}, ${users[1]}, and ${users.length - 2} others`;
354
+ }
355
+
356
+ typingUsers.textContent = text;
357
+ typingIndicator.classList.remove('hidden');
358
+ } else {
359
+ typingIndicator.classList.add('hidden');
360
+ }
361
+ }
362
+
363
+ function handleUserCount(count) {
364
+ onlineUsers = count;
365
+ onlineCount.textContent = `${count} online`;
366
+ }
367
+
368
+ // Helper functions
369
+ function formatTime(timestamp) {
370
+ const date = new Date(timestamp);
371
+ return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
372
+ }
373
+
374
+ function escapeHtml(text) {
375
+ const div = document.createElement('div');
376
+ div.textContent = text;
377
+ return div.innerHTML;
378
+ }
379
+
380
+ // Simulate receiving messages from other users
381
+ setInterval(() => {
382
+ if (username && Math.random() > 0.9) {
383
+ const sampleMessages = [
384
+ "Hello there!",
385
+ "How are you doing?",
386
+ "Anyone here?",
387
+ "This chat is awesome!",
388
+ "What's new?",
389
+ "Just testing the chat",
390
+ "Have a great day!",
391
+ "Typing... just kidding :)"
392
+ ];
393
+ const randomUser = ["Alice", "Bob", "Charlie", "Dana", "Eve"][Math.floor(Math.random() * 5)];
394
+
395
+ socket.onMessage({
396
+ type: 'message',
397
+ username: randomUser,
398
+ text: sampleMessages[Math.floor(Math.random() * sampleMessages.length)],
399
+ timestamp: new Date().getTime()
400
+ });
401
+ }
402
+ }, 10000);
403
+ </script>
404
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Junaed59/private-messenger" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
405
+ </html>