File size: 18,357 Bytes
99b9605
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Osnet Forum</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .chat-message {
            animation: fadeIn 0.3s ease-in-out;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .tab-content {
            display: none;
        }
        .tab-content.active {
            display: block;
        }
        .auth-form {
            max-width: 400px;
            margin: 0 auto;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-radius: 15px;
            padding: 2rem;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
        }
        .chat-container {
            height: calc(100vh - 180px);
        }
        .message-input:focus {
            outline: none;
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
        }
    </style>
</head>
<body class="bg-gray-900 text-gray-100 min-h-screen">
    <!-- Auth Screens -->
    <div id="auth-container" class="flex flex-col items-center justify-center min-h-screen p-4">
        <!-- Login Form -->
        <div id="login-form" class="auth-form">
            <div class="text-center mb-6">
                <h1 class="text-3xl font-bold text-blue-400">Osnet</h1>
                <p class="text-gray-400 mt-2">Войдите в свой аккаунт</p>
            </div>
            <form id="loginForm" class="space-y-4">
                <div>
                    <label for="login-username" class="block text-sm font-medium text-gray-300 mb-1">Имя пользователя</label>
                    <input type="text" id="login-username" required 
                           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">
                </div>
                <div>
                    <label for="login-password" class="block text-sm font-medium text-gray-300 mb-1">Пароль</label>
                    <input type="password" id="login-password" required 
                           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">
                </div>
                <button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition duration-200">
                    Войти
                </button>
                <div class="text-center text-sm text-gray-400">
                    Нет аккаунта? <button type="button" onclick="showRegister()" class="text-blue-400 hover:text-blue-300">Зарегистрироваться</button>
                </div>
            </form>
        </div>

        <!-- Register Form -->
        <div id="register-form" class="auth-form hidden">
            <div class="text-center mb-6">
                <h1 class="text-3xl font-bold text-blue-400">Osnet</h1>
                <p class="text-gray-400 mt-2">Создайте новый аккаунт</p>
            </div>
            <form id="registerForm" class="space-y-4">
                <div>
                    <label for="register-username" class="block text-sm font-medium text-gray-300 mb-1">Имя пользователя</label>
                    <input type="text" id="register-username" required 
                           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">
                </div>
                <div>
                    <label for="register-email" class="block text-sm font-medium text-gray-300 mb-1">Email</label>
                    <input type="email" id="register-email" required 
                           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">
                </div>
                <div>
                    <label for="register-password" class="block text-sm font-medium text-gray-300 mb-1">Пароль</label>
                    <input type="password" id="register-password" required 
                           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">
                </div>
                <div>
                    <label for="register-confirm-password" class="block text-sm font-medium text-gray-300 mb-1">Подтвердите пароль</label>
                    <input type="password" id="register-confirm-password" required 
                           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">
                </div>
                <button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition duration-200">
                    Зарегистрироваться
                </button>
                <div class="text-center text-sm text-gray-400">
                    Уже есть аккаунт? <button type="button" onclick="showLogin()" class="text-blue-400 hover:text-blue-300">Войти</button>
                </div>
            </form>
        </div>
    </div>

    <!-- Main App (hidden until auth) -->
    <div id="app-container" class="hidden">
        <!-- Header -->
        <header class="bg-gray-800 border-b border-gray-700 py-4 px-6 flex items-center justify-between sticky top-0 z-10">
            <div class="flex items-center space-x-4">
                <div class="text-2xl font-bold text-blue-400">Osnet</div>
            </div>
            <div class="flex items-center space-x-4">
                <button id="logout-btn" class="text-gray-400 hover:text-white transition">
                    <i class="fas fa-sign-out-alt"></i>
                </button>
            </div>
        </header>

        <!-- Tabs -->
        <div class="bg-gray-800 border-b border-gray-700">
            <div class="flex">
                <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">
                    <i class="fas fa-users mr-2"></i> Группы
                </button>
                <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">
                    <i class="fas fa-comments mr-2"></i> Чат
                </button>
            </div>
        </div>

        <!-- Tab Contents -->
        <div class="p-4">
            <!-- Groups Tab -->
            <div id="groups-tab" class="tab-content">
                <h2 class="text-xl font-semibold mb-4">Группы Osnet</h2>
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
                    <div class="bg-gray-800 rounded-lg border border-gray-700 p-4 hover:bg-gray-700 transition cursor-pointer">
                        <h3 class="font-medium text-lg mb-2">Разработчики</h3>
                        <p class="text-gray-400 text-sm">Обсуждение разработки и программирования</p>
                        <div class="mt-3 text-xs text-gray-500">Участников: 124</div>
                    </div>
                    <div class="bg-gray-800 rounded-lg border border-gray-700 p-4 hover:bg-gray-700 transition cursor-pointer">
                        <h3 class="font-medium text-lg mb-2">Дизайн</h3>
                        <p class="text-gray-400 text-sm">Графика, UI/UX и веб-дизайн</p>
                        <div class="mt-3 text-xs text-gray-500">Участников: 89</div>
                    </div>
                    <div class="bg-gray-800 rounded-lg border border-gray-700 p-4 hover:bg-gray-700 transition cursor-pointer">
                        <h3 class="font-medium text-lg mb-2">Флейм</h3>
                        <p class="text-gray-400 text-sm">Обсуждение любых тем</p>
                        <div class="mt-3 text-xs text-gray-500">Участников: 256</div>
                    </div>
                </div>
            </div>

            <!-- Chat Tab -->
            <div id="chat-tab" class="tab-content active">
                <div class="chat-container overflow-y-auto mb-4 space-y-3" id="chat-messages">
                    <!-- Messages will be loaded here -->
                    <div class="text-center py-10 text-gray-500">
                        <i class="fas fa-comments text-4xl mb-2"></i>
                        <p>Начните общение в общем чате Osnet</p>
                    </div>
                </div>
                
                <div class="flex items-center space-x-2">
                    <input type="text" id="message-input" placeholder="Напишите сообщение..." 
                           class="message-input flex-1 px-4 py-3 bg-gray-800 border border-gray-700 rounded-full focus:border-blue-500">
                    <button id="send-btn" class="bg-blue-600 hover:bg-blue-700 text-white p-3 rounded-full transition">
                        <i class="fas fa-paper-plane"></i>
                    </button>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Auth state
        let currentUser = null;
        
        // DOM elements
        const authContainer = document.getElementById('auth-container');
        const appContainer = document.getElementById('app-container');
        const loginForm = document.getElementById('login-form');
        const registerForm = document.getElementById('register-form');
        const chatMessages = document.getElementById('chat-messages');
        const messageInput = document.getElementById('message-input');
        const sendBtn = document.getElementById('send-btn');
        const logoutBtn = document.getElementById('logout-btn');
        const tabBtns = document.querySelectorAll('.tab-btn');
        const tabContents = document.querySelectorAll('.tab-content');
        
        // Mock database
        const users = [];
        const messages = [];
        
        // Initialize
        document.addEventListener('DOMContentLoaded', () => {
            // Check if user is already logged in (from localStorage)
            const savedUser = localStorage.getItem('osnet_user');
            if (savedUser) {
                currentUser = JSON.parse(savedUser);
                showApp();
                loadMessages();
            }
            
            // Form submissions
            document.getElementById('loginForm').addEventListener('submit', handleLogin);
            document.getElementById('registerForm').addEventListener('submit', handleRegister);
            
            // Chat functionality
            sendBtn.addEventListener('click', sendMessage);
            messageInput.addEventListener('keypress', (e) => {
                if (e.key === 'Enter') sendMessage();
            });
            
            // Logout
            logoutBtn.addEventListener('click', handleLogout);
            
            // Tab switching
            tabBtns.forEach(btn => {
                btn.addEventListener('click', () => switchTab(btn.dataset.tab));
            });
        });
        
        // Auth functions
        function showLogin() {
            loginForm.classList.remove('hidden');
            registerForm.classList.add('hidden');
        }
        
        function showRegister() {
            loginForm.classList.add('hidden');
            registerForm.classList.remove('hidden');
        }
        
        function handleLogin(e) {
            e.preventDefault();
            const username = document.getElementById('login-username').value;
            const password = document.getElementById('login-password').value;
            
            // Mock authentication
            const user = users.find(u => u.username === username && u.password === password);
            if (user) {
                currentUser = user;
                localStorage.setItem('osnet_user', JSON.stringify(user));
                showApp();
                loadMessages();
            } else {
                alert('Неверное имя пользователя или пароль');
            }
        }
        
        function handleRegister(e) {
            e.preventDefault();
            const username = document.getElementById('register-username').value;
            const email = document.getElementById('register-email').value;
            const password = document.getElementById('register-password').value;
            const confirmPassword = document.getElementById('register-confirm-password').value;
            
            if (password !== confirmPassword) {
                alert('Пароли не совпадают');
                return;
            }
            
            if (users.some(u => u.username === username)) {
                alert('Имя пользователя уже занято');
                return;
            }
            
            const newUser = {
                id: Date.now().toString(),
                username,
                email,
                password,
                joined: new Date().toISOString()
            };
            
            users.push(newUser);
            currentUser = newUser;
            localStorage.setItem('osnet_user', JSON.stringify(newUser));
            showApp();
            loadMessages();
            showLogin();
        }
        
        function handleLogout() {
            currentUser = null;
            localStorage.removeItem('osnet_user');
            showAuth();
            chatMessages.innerHTML = `
                <div class="text-center py-10 text-gray-500">
                    <i class="fas fa-comments text-4xl mb-2"></i>
                    <p>Начните общение в общем чате Osnet</p>
                </div>
            `;
        }
        
        function showAuth() {
            authContainer.classList.remove('hidden');
            appContainer.classList.add('hidden');
        }
        
        function showApp() {
            authContainer.classList.add('hidden');
            appContainer.classList.remove('hidden');
        }
        
        // Chat functions
        function loadMessages() {
            // In a real app, this would fetch messages from the server
            if (messages.length === 0) return;
            
            chatMessages.innerHTML = '';
            messages.forEach(msg => {
                addMessageToChat(msg);
            });
        }
        
        function sendMessage() {
            const text = messageInput.value.trim();
            if (!text || !currentUser) return;
            
            const newMessage = {
                id: Date.now().toString(),
                text,
                username: currentUser.username,
                timestamp: new Date().toISOString()
            };
            
            // In a real app, this would send to the Flask backend
            messages.push(newMessage);
            addMessageToChat(newMessage);
            messageInput.value = '';
            
            // Scroll to bottom
            chatMessages.scrollTop = chatMessages.scrollHeight;
        }
        
        function addMessageToChat(message) {
            const isCurrentUser = message.username === currentUser.username;
            
            const messageElement = document.createElement('div');
            messageElement.className = `chat-message flex ${isCurrentUser ? 'justify-end' : 'justify-start'}`;
            
            messageElement.innerHTML = `
                <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'}">
                    ${!isCurrentUser ? `<div class="font-medium text-xs text-gray-300 mb-1">${message.username}</div>` : ''}
                    <div class="text-sm">${message.text}</div>
                    <div class="text-right mt-1 text-xs opacity-70">${formatTime(message.timestamp)}</div>
                </div>
            `;
            
            chatMessages.appendChild(messageElement);
        }
        
        function formatTime(timestamp) {
            const date = new Date(timestamp);
            return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
        }
        
        // Tab functions
        function switchTab(tabName) {
            // Update active tab button
            tabBtns.forEach(btn => {
                if (btn.dataset.tab === tabName) {
                    btn.classList.add('border-blue-500', 'text-white');
                } else {
                    btn.classList.remove('border-blue-500', 'text-white');
                }
            });
            
            // Show active tab content
            tabContents.forEach(content => {
                if (content.id === `${tabName}-tab`) {
                    content.classList.add('active');
                } else {
                    content.classList.remove('active');
                }
            });
        }
    </script>
<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>
</html>