Neogram129 commited on
Commit
99b9605
·
verified ·
1 Parent(s): 8392b32

Делаем скрипт Osnet форума вход и регистр потом после захода вверху текст Osnet и вкладка группы Osnet вкладка чата как в телеграмме, это общий чат без сокетов ажах сообщение на фласке - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +385 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Osnet
3
- emoji: 😻
4
- colorFrom: pink
5
- colorTo: purple
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: osnet
3
+ emoji: 🐳
4
+ colorFrom: yellow
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,385 @@
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="ru">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Osnet Forum</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
+ .chat-message {
11
+ animation: fadeIn 0.3s ease-in-out;
12
+ }
13
+ @keyframes fadeIn {
14
+ from { opacity: 0; transform: translateY(10px); }
15
+ to { opacity: 1; transform: translateY(0); }
16
+ }
17
+ .tab-content {
18
+ display: none;
19
+ }
20
+ .tab-content.active {
21
+ display: block;
22
+ }
23
+ .auth-form {
24
+ max-width: 400px;
25
+ margin: 0 auto;
26
+ background: rgba(255, 255, 255, 0.1);
27
+ backdrop-filter: blur(10px);
28
+ border-radius: 15px;
29
+ padding: 2rem;
30
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
31
+ }
32
+ .chat-container {
33
+ height: calc(100vh - 180px);
34
+ }
35
+ .message-input:focus {
36
+ outline: none;
37
+ box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
38
+ }
39
+ </style>
40
+ </head>
41
+ <body class="bg-gray-900 text-gray-100 min-h-screen">
42
+ <!-- Auth Screens -->
43
+ <div id="auth-container" class="flex flex-col items-center justify-center min-h-screen p-4">
44
+ <!-- Login Form -->
45
+ <div id="login-form" class="auth-form">
46
+ <div class="text-center mb-6">
47
+ <h1 class="text-3xl font-bold text-blue-400">Osnet</h1>
48
+ <p class="text-gray-400 mt-2">Войдите в свой аккаунт</p>
49
+ </div>
50
+ <form id="loginForm" class="space-y-4">
51
+ <div>
52
+ <label for="login-username" class="block text-sm font-medium text-gray-300 mb-1">Имя пользователя</label>
53
+ <input type="text" id="login-username" required
54
+ class="w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg focus:border-blue-500 focus:ring-1 focus:ring-blue-500">
55
+ </div>
56
+ <div>
57
+ <label for="login-password" class="block text-sm font-medium text-gray-300 mb-1">Пароль</label>
58
+ <input type="password" id="login-password" required
59
+ class="w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg focus:border-blue-500 focus:ring-1 focus:ring-blue-500">
60
+ </div>
61
+ <button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition duration-200">
62
+ Войти
63
+ </button>
64
+ <div class="text-center text-sm text-gray-400">
65
+ Нет аккаунта? <button type="button" onclick="showRegister()" class="text-blue-400 hover:text-blue-300">Зарегистрироваться</button>
66
+ </div>
67
+ </form>
68
+ </div>
69
+
70
+ <!-- Register Form -->
71
+ <div id="register-form" class="auth-form hidden">
72
+ <div class="text-center mb-6">
73
+ <h1 class="text-3xl font-bold text-blue-400">Osnet</h1>
74
+ <p class="text-gray-400 mt-2">Создайте новый аккаунт</p>
75
+ </div>
76
+ <form id="registerForm" class="space-y-4">
77
+ <div>
78
+ <label for="register-username" class="block text-sm font-medium text-gray-300 mb-1">Имя пользователя</label>
79
+ <input type="text" id="register-username" required
80
+ class="w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg focus:border-blue-500 focus:ring-1 focus:ring-blue-500">
81
+ </div>
82
+ <div>
83
+ <label for="register-email" class="block text-sm font-medium text-gray-300 mb-1">Email</label>
84
+ <input type="email" id="register-email" required
85
+ class="w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg focus:border-blue-500 focus:ring-1 focus:ring-blue-500">
86
+ </div>
87
+ <div>
88
+ <label for="register-password" class="block text-sm font-medium text-gray-300 mb-1">Пароль</label>
89
+ <input type="password" id="register-password" required
90
+ class="w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg focus:border-blue-500 focus:ring-1 focus:ring-blue-500">
91
+ </div>
92
+ <div>
93
+ <label for="register-confirm-password" class="block text-sm font-medium text-gray-300 mb-1">Подтвердите пароль</label>
94
+ <input type="password" id="register-confirm-password" required
95
+ class="w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg focus:border-blue-500 focus:ring-1 focus:ring-blue-500">
96
+ </div>
97
+ <button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition duration-200">
98
+ Зарегистрироваться
99
+ </button>
100
+ <div class="text-center text-sm text-gray-400">
101
+ Уже есть аккаунт? <button type="button" onclick="showLogin()" class="text-blue-400 hover:text-blue-300">Войти</button>
102
+ </div>
103
+ </form>
104
+ </div>
105
+ </div>
106
+
107
+ <!-- Main App (hidden until auth) -->
108
+ <div id="app-container" class="hidden">
109
+ <!-- Header -->
110
+ <header class="bg-gray-800 border-b border-gray-700 py-4 px-6 flex items-center justify-between sticky top-0 z-10">
111
+ <div class="flex items-center space-x-4">
112
+ <div class="text-2xl font-bold text-blue-400">Osnet</div>
113
+ </div>
114
+ <div class="flex items-center space-x-4">
115
+ <button id="logout-btn" class="text-gray-400 hover:text-white transition">
116
+ <i class="fas fa-sign-out-alt"></i>
117
+ </button>
118
+ </div>
119
+ </header>
120
+
121
+ <!-- Tabs -->
122
+ <div class="bg-gray-800 border-b border-gray-700">
123
+ <div class="flex">
124
+ <button data-tab="groups" class="tab-btn py-4 px-6 text-center border-b-2 border-transparent hover:bg-gray-700 text-gray-400 hover:text-white font-medium transition flex-1">
125
+ <i class="fas fa-users mr-2"></i> Группы
126
+ </button>
127
+ <button data-tab="chat" class="tab-btn py-4 px-6 text-center border-b-2 border-blue-500 text-white font-medium transition flex-1">
128
+ <i class="fas fa-comments mr-2"></i> Чат
129
+ </button>
130
+ </div>
131
+ </div>
132
+
133
+ <!-- Tab Contents -->
134
+ <div class="p-4">
135
+ <!-- Groups Tab -->
136
+ <div id="groups-tab" class="tab-content">
137
+ <h2 class="text-xl font-semibold mb-4">Группы Osnet</h2>
138
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
139
+ <div class="bg-gray-800 rounded-lg border border-gray-700 p-4 hover:bg-gray-700 transition cursor-pointer">
140
+ <h3 class="font-medium text-lg mb-2">Разработчики</h3>
141
+ <p class="text-gray-400 text-sm">Обсуждение разработки и программирования</p>
142
+ <div class="mt-3 text-xs text-gray-500">Участников: 124</div>
143
+ </div>
144
+ <div class="bg-gray-800 rounded-lg border border-gray-700 p-4 hover:bg-gray-700 transition cursor-pointer">
145
+ <h3 class="font-medium text-lg mb-2">Дизайн</h3>
146
+ <p class="text-gray-400 text-sm">Графика, UI/UX и веб-дизайн</p>
147
+ <div class="mt-3 text-xs text-gray-500">Участников: 89</div>
148
+ </div>
149
+ <div class="bg-gray-800 rounded-lg border border-gray-700 p-4 hover:bg-gray-700 transition cursor-pointer">
150
+ <h3 class="font-medium text-lg mb-2">Флейм</h3>
151
+ <p class="text-gray-400 text-sm">Обсуждение любых тем</p>
152
+ <div class="mt-3 text-xs text-gray-500">Участников: 256</div>
153
+ </div>
154
+ </div>
155
+ </div>
156
+
157
+ <!-- Chat Tab -->
158
+ <div id="chat-tab" class="tab-content active">
159
+ <div class="chat-container overflow-y-auto mb-4 space-y-3" id="chat-messages">
160
+ <!-- Messages will be loaded here -->
161
+ <div class="text-center py-10 text-gray-500">
162
+ <i class="fas fa-comments text-4xl mb-2"></i>
163
+ <p>Начните общение в общем чате Osnet</p>
164
+ </div>
165
+ </div>
166
+
167
+ <div class="flex items-center space-x-2">
168
+ <input type="text" id="message-input" placeholder="Напишите сообщение..."
169
+ class="message-input flex-1 px-4 py-3 bg-gray-800 border border-gray-700 rounded-full focus:border-blue-500">
170
+ <button id="send-btn" class="bg-blue-600 hover:bg-blue-700 text-white p-3 rounded-full transition">
171
+ <i class="fas fa-paper-plane"></i>
172
+ </button>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ </div>
177
+
178
+ <script>
179
+ // Auth state
180
+ let currentUser = null;
181
+
182
+ // DOM elements
183
+ const authContainer = document.getElementById('auth-container');
184
+ const appContainer = document.getElementById('app-container');
185
+ const loginForm = document.getElementById('login-form');
186
+ const registerForm = document.getElementById('register-form');
187
+ const chatMessages = document.getElementById('chat-messages');
188
+ const messageInput = document.getElementById('message-input');
189
+ const sendBtn = document.getElementById('send-btn');
190
+ const logoutBtn = document.getElementById('logout-btn');
191
+ const tabBtns = document.querySelectorAll('.tab-btn');
192
+ const tabContents = document.querySelectorAll('.tab-content');
193
+
194
+ // Mock database
195
+ const users = [];
196
+ const messages = [];
197
+
198
+ // Initialize
199
+ document.addEventListener('DOMContentLoaded', () => {
200
+ // Check if user is already logged in (from localStorage)
201
+ const savedUser = localStorage.getItem('osnet_user');
202
+ if (savedUser) {
203
+ currentUser = JSON.parse(savedUser);
204
+ showApp();
205
+ loadMessages();
206
+ }
207
+
208
+ // Form submissions
209
+ document.getElementById('loginForm').addEventListener('submit', handleLogin);
210
+ document.getElementById('registerForm').addEventListener('submit', handleRegister);
211
+
212
+ // Chat functionality
213
+ sendBtn.addEventListener('click', sendMessage);
214
+ messageInput.addEventListener('keypress', (e) => {
215
+ if (e.key === 'Enter') sendMessage();
216
+ });
217
+
218
+ // Logout
219
+ logoutBtn.addEventListener('click', handleLogout);
220
+
221
+ // Tab switching
222
+ tabBtns.forEach(btn => {
223
+ btn.addEventListener('click', () => switchTab(btn.dataset.tab));
224
+ });
225
+ });
226
+
227
+ // Auth functions
228
+ function showLogin() {
229
+ loginForm.classList.remove('hidden');
230
+ registerForm.classList.add('hidden');
231
+ }
232
+
233
+ function showRegister() {
234
+ loginForm.classList.add('hidden');
235
+ registerForm.classList.remove('hidden');
236
+ }
237
+
238
+ function handleLogin(e) {
239
+ e.preventDefault();
240
+ const username = document.getElementById('login-username').value;
241
+ const password = document.getElementById('login-password').value;
242
+
243
+ // Mock authentication
244
+ const user = users.find(u => u.username === username && u.password === password);
245
+ if (user) {
246
+ currentUser = user;
247
+ localStorage.setItem('osnet_user', JSON.stringify(user));
248
+ showApp();
249
+ loadMessages();
250
+ } else {
251
+ alert('Неверное имя пользователя или пароль');
252
+ }
253
+ }
254
+
255
+ function handleRegister(e) {
256
+ e.preventDefault();
257
+ const username = document.getElementById('register-username').value;
258
+ const email = document.getElementById('register-email').value;
259
+ const password = document.getElementById('register-password').value;
260
+ const confirmPassword = document.getElementById('register-confirm-password').value;
261
+
262
+ if (password !== confirmPassword) {
263
+ alert('Пароли не совпадают');
264
+ return;
265
+ }
266
+
267
+ if (users.some(u => u.username === username)) {
268
+ alert('Имя пользователя уже занято');
269
+ return;
270
+ }
271
+
272
+ const newUser = {
273
+ id: Date.now().toString(),
274
+ username,
275
+ email,
276
+ password,
277
+ joined: new Date().toISOString()
278
+ };
279
+
280
+ users.push(newUser);
281
+ currentUser = newUser;
282
+ localStorage.setItem('osnet_user', JSON.stringify(newUser));
283
+ showApp();
284
+ loadMessages();
285
+ showLogin();
286
+ }
287
+
288
+ function handleLogout() {
289
+ currentUser = null;
290
+ localStorage.removeItem('osnet_user');
291
+ showAuth();
292
+ chatMessages.innerHTML = `
293
+ <div class="text-center py-10 text-gray-500">
294
+ <i class="fas fa-comments text-4xl mb-2"></i>
295
+ <p>Начните общение в общем чате Osnet</p>
296
+ </div>
297
+ `;
298
+ }
299
+
300
+ function showAuth() {
301
+ authContainer.classList.remove('hidden');
302
+ appContainer.classList.add('hidden');
303
+ }
304
+
305
+ function showApp() {
306
+ authContainer.classList.add('hidden');
307
+ appContainer.classList.remove('hidden');
308
+ }
309
+
310
+ // Chat functions
311
+ function loadMessages() {
312
+ // In a real app, this would fetch messages from the server
313
+ if (messages.length === 0) return;
314
+
315
+ chatMessages.innerHTML = '';
316
+ messages.forEach(msg => {
317
+ addMessageToChat(msg);
318
+ });
319
+ }
320
+
321
+ function sendMessage() {
322
+ const text = messageInput.value.trim();
323
+ if (!text || !currentUser) return;
324
+
325
+ const newMessage = {
326
+ id: Date.now().toString(),
327
+ text,
328
+ username: currentUser.username,
329
+ timestamp: new Date().toISOString()
330
+ };
331
+
332
+ // In a real app, this would send to the Flask backend
333
+ messages.push(newMessage);
334
+ addMessageToChat(newMessage);
335
+ messageInput.value = '';
336
+
337
+ // Scroll to bottom
338
+ chatMessages.scrollTop = chatMessages.scrollHeight;
339
+ }
340
+
341
+ function addMessageToChat(message) {
342
+ const isCurrentUser = message.username === currentUser.username;
343
+
344
+ const messageElement = document.createElement('div');
345
+ messageElement.className = `chat-message flex ${isCurrentUser ? 'justify-end' : 'justify-start'}`;
346
+
347
+ messageElement.innerHTML = `
348
+ <div class="max-w-xs md:max-w-md lg:max-w-lg rounded-lg px-4 py-2 ${isCurrentUser ? 'bg-blue-600 text-white' : 'bg-gray-700'}">
349
+ ${!isCurrentUser ? `<div class="font-medium text-xs text-gray-300 mb-1">${message.username}</div>` : ''}
350
+ <div class="text-sm">${message.text}</div>
351
+ <div class="text-right mt-1 text-xs opacity-70">${formatTime(message.timestamp)}</div>
352
+ </div>
353
+ `;
354
+
355
+ chatMessages.appendChild(messageElement);
356
+ }
357
+
358
+ function formatTime(timestamp) {
359
+ const date = new Date(timestamp);
360
+ return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
361
+ }
362
+
363
+ // Tab functions
364
+ function switchTab(tabName) {
365
+ // Update active tab button
366
+ tabBtns.forEach(btn => {
367
+ if (btn.dataset.tab === tabName) {
368
+ btn.classList.add('border-blue-500', 'text-white');
369
+ } else {
370
+ btn.classList.remove('border-blue-500', 'text-white');
371
+ }
372
+ });
373
+
374
+ // Show active tab content
375
+ tabContents.forEach(content => {
376
+ if (content.id === `${tabName}-tab`) {
377
+ content.classList.add('active');
378
+ } else {
379
+ content.classList.remove('active');
380
+ }
381
+ });
382
+ }
383
+ </script>
384
+ <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=Neogram129/osnet" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
385
+ </html>