sldshr commited on
Commit
f908100
·
verified ·
1 Parent(s): 5578e88

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +916 -528
index.html CHANGED
@@ -1,90 +1,184 @@
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>ClientLess - Легковесный мессенджер</title>
7
- <script src="https://cdn.tailwindcss.com"></script>
8
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
 
9
  <style>
10
- @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  body {
13
  font-family: 'Roboto', sans-serif;
14
- background-color: #f5f7fa;
15
- color: #333;
16
- margin: 0;
17
- padding: 0;
18
  display: flex;
19
  flex-direction: column;
20
- min-height: 100vh;
21
- /* Запрет выделения текста по умолчанию */
22
  user-select: none;
23
  -webkit-user-select: none;
24
- -moz-user-select: none;
25
- -ms-user-select: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
 
28
- /* Разрешаем выделение только для текста сообщений и полей ввода */
29
  .selectable-text, input, textarea, code, pre {
30
  user-select: text !important;
31
  -webkit-user-select: text !important;
32
- -moz-user-select: text !important;
33
- -ms-user-select: text !important;
34
  }
35
 
36
- /* Классические тени 2015 года */
37
- .card-shadow {
38
- box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16), 0 2px 10px 0 rgba(0,0,0,0.12);
 
 
 
 
 
 
 
 
39
  }
40
 
41
- .header-shadow {
42
- box-shadow: 0 2px 5px rgba(0,0,0,0.26);
 
 
 
 
 
43
  }
44
 
45
- /* Специфичные цвета */
46
- .bg-brand-blue {
47
- background-color: #5682a3; /* Классический цвет Telegram Web того времени */
48
- }
49
- .text-brand-blue {
50
- color: #5682a3;
51
- }
52
- .bg-brand-hover {
53
- background-color: #4a7290;
54
  }
55
 
56
- /* Элементы форм в стиле 2015 */
57
- .legacy-input {
58
- border: 1px solid #ccc;
59
- border-radius: 3px;
60
- padding: 10px 12px;
61
- width: 100%;
62
- transition: border-color 0.2s;
63
- box-sizing: border-box;
64
  }
65
- .legacy-input:focus {
66
- border-color: #5682a3;
67
- outline: none;
68
- box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(86, 130, 163, 0.6);
69
  }
70
 
71
- .legacy-btn {
72
- background-color: #5682a3;
73
- color: white;
 
74
  border: none;
75
  border-radius: 3px;
76
  padding: 10px 20px;
77
- text-transform: uppercase;
78
  font-weight: 500;
 
 
79
  cursor: pointer;
 
80
  transition: background-color 0.2s, box-shadow 0.2s;
81
  }
82
- .legacy-btn:hover {
83
- background-color: #4a7290;
84
- box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16), 0 2px 10px 0 rgba(0,0,0,0.12);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
 
87
- /* Управление видимостью экранов */
88
  .screen {
89
  display: none;
90
  flex: 1;
@@ -94,189 +188,303 @@
94
  flex-direction: column;
95
  }
96
 
97
- /* Стили для огромной документации */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  .docs-sidebar {
99
- width: 250px;
100
- border-right: 1px solid #ddd;
101
- background: #fff;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
103
  .docs-content {
104
  flex: 1;
105
  padding: 40px;
106
- background: #fff;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
- .docs-content h1 { border-bottom: 2px solid #eee; padding-bottom: 10px; margin-bottom: 20px; font-size: 2.5rem; }
109
- .docs-content h2 { color: #5682a3; margin-top: 30px; font-size: 1.8rem;}
110
- code.inline { background: #f9f2f4; color: #c7254e; padding: 2px 4px; border-radius: 3px; font-family: monospace; }
111
- pre.code-block { background: #2b2b2b; color: #f8f8f2; padding: 15px; border-radius: 4px; font-family: monospace; overflow-x: auto; margin: 15px 0; }
112
 
113
- /* Клиент Web ClientLess (WCL) */
114
  #wcl-layout {
115
  height: 100vh;
116
  display: flex;
117
  flex-direction: column;
118
- position: relative;
119
  overflow: hidden;
120
  }
121
  .wcl-header {
122
- background-color: #5682a3;
123
- color: white;
124
  height: 54px;
125
  display: flex;
126
  align-items: center;
 
127
  padding: 0 16px;
128
- font-size: 18px;
129
- font-weight: 500;
130
  }
131
  .wcl-body {
132
  display: flex;
133
  flex: 1;
134
  overflow: hidden;
135
- background: #e7ebf0;
136
  position: relative;
137
  }
138
  .wcl-sidebar {
139
  width: 260px;
140
- background: #fff;
141
- border-right: 1px solid #dcdcdc;
142
  display: flex;
143
  flex-direction: column;
144
- transition: transform 0.25s ease-in-out;
145
- z-index: 30;
146
  }
147
  .wcl-right-sidebar {
148
  width: 250px;
149
- background: #fff;
150
- border-left: 1px solid #dcdcdc;
151
  display: flex;
152
  flex-direction: column;
153
- transition: transform 0.25s ease-in-out;
154
- z-index: 30;
155
- }
156
-
157
- /* Адаптивность мобильных выезжающих панелей */
158
- @media (max-width: 767px) {
159
- .wcl-sidebar {
160
- position: absolute;
161
- top: 0;
162
- bottom: 0;
163
- left: 0;
164
- transform: translateX(-100%);
165
- box-shadow: 2px 0 10px rgba(0,0,0,0.2);
166
- }
167
- .wcl-sidebar.open {
168
- transform: translateX(0);
169
- }
170
- }
171
-
172
- @media (max-width: 1023px) {
173
- .wcl-right-sidebar {
174
- position: absolute;
175
- top: 0;
176
- bottom: 0;
177
- right: 0;
178
- transform: translateX(100%);
179
- box-shadow: -2px 0 10px rgba(0,0,0,0.2);
180
- }
181
- .wcl-right-sidebar.open {
182
- transform: translateX(0);
183
- }
184
- }
185
-
186
- /* Оверлей для мобильного закрытия панелей */
187
- .wcl-overlay {
188
- display: none;
189
- position: absolute;
190
- inset: 0;
191
- background: rgba(0, 0, 0, 0.4);
192
- z-index: 25;
193
- }
194
- .wcl-overlay.active {
195
- display: block;
196
  }
197
-
198
  .wcl-main {
199
  flex: 1;
200
  display: flex;
201
  flex-direction: column;
202
- background: url('https://www.transparenttextures.com/patterns/cubes.png') #e7ebf0;
203
  position: relative;
204
  min-width: 0;
205
  }
 
206
  .list-header {
207
  padding: 14px 16px;
208
- font-weight: bold;
209
- color: #777;
 
210
  text-transform: uppercase;
211
- font-size: 12px;
212
- border-bottom: 1px solid #eee;
213
- background: #fafafa;
214
  }
215
  .list-item {
216
  padding: 12px 16px;
217
  display: flex;
218
  align-items: center;
219
  cursor: pointer;
220
- border-bottom: 1px solid #f5f5f5;
 
 
 
 
 
 
 
 
221
  }
222
- .list-item:hover { background-color: #f4f4f4; }
223
- .list-item.active { background-color: #5682a3; color: white; }
224
- .list-item.active i { color: white !important; }
 
225
  .status-dot {
226
- width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 10px; flex-shrink: 0;
 
 
 
227
  }
228
  .status-online { background-color: #4caf50; }
229
  .status-offline { background-color: #9e9e9e; }
230
-
231
- /* Чат зона */
232
- .chat-history {
233
- flex: 1;
234
- padding: 16px;
235
- overflow-y: auto;
236
- overflow-x: hidden;
237
- display: flex;
238
- flex-direction: column;
239
- }
240
- .chat-input-area { background: #fff; padding: 12px 16px; border-top: 1px solid #ddd; display: flex; flex-direction: column; }
241
-
242
- .message {
243
- background: #fff;
244
- padding: 10px 14px;
245
- border-radius: 4px;
246
- margin-bottom: 12px;
247
- max-width: 82%;
248
- box-shadow: 0 1px 2px rgba(0,0,0,0.1);
249
- position: relative;
250
- cursor: context-menu;
251
- word-wrap: break-word;
252
  word-break: break-word;
253
  overflow-wrap: anywhere;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  }
255
- .message.self { background: #effdde; align-self: flex-end; margin-left: auto; }
256
- .message-author { font-weight: bold; color: #5682a3; font-size: 13px; margin-bottom: 3px; }
257
  .message.self .message-author { display: none; }
258
- .message-time { font-size: 11px; color: #999; float: right; margin-top: 4px; margin-left: 10px; }
259
-
260
- /* Стили цитат/ответов в сообщениях */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  .message-quote {
262
- border-left: 3px solid #5682a3;
263
- background: rgba(86, 130, 163, 0.08);
264
  padding: 4px 8px;
265
  border-radius: 2px;
266
  font-size: 12px;
267
  margin-bottom: 6px;
268
- word-break: break-word;
269
- overflow-wrap: anywhere;
270
  }
271
- .message.self .message-quote {
272
- border-left-color: #4a7290;
273
- background: rgba(0, 0, 0, 0.05);
274
  }
275
 
276
- /* Упоминания @nickname */
277
  .mention-tag {
278
- background-color: #e8f0fe;
279
- color: #1a73e8;
280
  padding: 1px 4px;
281
  border-radius: 3px;
282
  font-weight: 500;
@@ -286,270 +494,343 @@
286
  text-decoration: underline;
287
  }
288
 
289
- /* Контекстное меню ПК */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  .custom-context-menu {
291
  position: fixed;
292
- background: #ffffff;
293
- border: 1px solid #ccc;
294
- box-shadow: 0 4px 12px rgba(0,0,0,0.15);
295
  border-radius: 4px;
296
  z-index: 100;
297
- min-width: 150px;
298
  padding: 4px 0;
299
  }
300
  .context-menu-item {
301
- padding: 8px 16px;
302
  font-size: 14px;
303
- color: #333;
304
  cursor: pointer;
305
  display: flex;
306
  align-items: center;
307
  gap: 10px;
308
  }
309
  .context-menu-item:hover {
310
- background-color: #f0f4f8;
311
  }
312
  .context-menu-item.danger {
313
- color: #d9534f;
314
- }
315
- .context-menu-item.danger:hover {
316
- background-color: #fdf2f2;
317
  }
318
 
319
- /* Модальное окно для мобильных устройств */
320
  .mobile-modal-overlay {
321
  position: fixed;
322
  inset: 0;
323
- background: rgba(0,0,0,0.4);
324
  z-index: 90;
325
  display: flex;
326
  align-items: flex-end;
327
  }
328
  .mobile-modal-sheet {
329
  width: 100%;
330
- background: #fff;
331
  border-top-left-radius: 12px;
332
  border-top-right-radius: 12px;
333
- padding: 12px 0 24px 0;
334
- box-shadow: 0 -4px 16px rgba(0,0,0,0.2);
335
- animation: slideUp 0.2s ease-out;
336
- }
337
- @keyframes slideUp {
338
- from { transform: translateY(100%); }
339
- to { transform: translateY(0); }
340
  }
 
 
341
  </style>
342
  </head>
343
  <body>
344
 
345
- <nav id="marketing-nav" class="bg-brand-blue text-white header-shadow relative z-10">
346
- <div class="max-w-7xl mx-auto px-4">
347
- <div class="flex justify-between items-center h-16">
348
- <!-- Бренд -->
349
- <div class="flex items-center cursor-pointer" onclick="navigate('landing')">
350
- <i class="fa-solid fa-paper-plane text-2xl mr-3"></i>
351
- <span class="font-bold text-xl tracking-wide">ClientLess</span>
352
- </div>
353
-
354
- <!-- Ссылки (слева направо по ТЗ) -->
355
- <div class="hidden md:flex space-x-6 items-center">
356
- <a href="#" onclick="navigate('docs')" class="hover:text-blue-200 transition font-medium text-lg">Docs</a>
357
- <a href="#" class="hover:text-blue-200 transition font-medium text-lg">Скачать приложение</a>
358
- <button onclick="navigate('server')" class="bg-white text-brand-blue px-4 py-2 rounded-sm font-bold shadow hover:bg-gray-100 transition uppercase text-sm">
359
- Веб Версия
360
- </button>
361
- </div>
362
- </div>
363
  </div>
364
  </nav>
365
 
366
- <div id="screen-landing" class="screen active justify-center items-center text-center p-6">
367
- <div class="max-w-3xl">
368
- <div class="mb-8">
369
- <i class="fa-solid fa-cloud-bolt text-brand-blue" style="font-size: 80px;"></i>
370
- </div>
371
- <h1 class="text-5xl font-bold mb-6 text-gray-800">Будущее коммуникаций уже здесь</h1>
372
- <p class="text-xl text-gray-600 mb-10 leading-relaxed">
373
- ClientLess — это высокопроизводительный протокол обмена сообщениями, созданный для независимых сообществ.
374
- Мы отказались от тяжелых монолитных архитектур в пользу легковесности и свободы.
375
- Разворачивайте свой сервер, подключайтесь через единый веб-интерфейс и общайтесь без границ.
376
- Никакой слежки, никаких лишних зависимостей. Только чистый, быстрый код.
377
- </p>
378
- <div class="flex justify-center gap-4">
379
- <button onclick="navigate('server')" class="legacy-btn text-lg py-3 px-8">Запустить WCL</button>
380
- <button onclick="navigate('docs')" class="bg-gray-200 text-gray-700 py-3 px-8 rounded-sm font-bold uppercase hover:bg-gray-300 transition shadow">Читать документацию</button>
381
  </div>
382
  </div>
383
  </div>
384
 
385
- <div id="screen-docs" class="screen bg-white">
386
- <div class="max-w-7xl mx-auto flex w-full h-full">
387
- <div class="docs-sidebar p-6 hidden md:block">
388
- <h3 class="font-bold text-lg mb-4 text-gray-700">Навигация</h3>
389
- <ul class="space-y-3 text-brand-blue font-medium">
390
- <li><a href="#" class="hover:underline">Введение</a></li>
391
- <li><a href="#" class="hover:underline">Архитектура</a></li>
392
- <li><a href="#" class="hover:underline">Подключение сервера</a></li>
393
- <li><a href="#" class="hover:underline">API Авторизации</a></li>
394
- <li><a href="#" class="hover:underline">Вебсокеты (WSS)</a></li>
395
- <li><a href="#" class="hover:underline">Структура пакетов</a></li>
396
- </ul>
397
  </div>
398
- <div class="docs-content overflow-y-auto">
399
- <h1>Документация ClientLess</h1>
400
- <p class="text-lg text-gray-600">Добро пожаловать в официальную документацию протокола ClientLess. Здесь вы найдете всё необходимое для настройки своего сервера и подключения к нему.</p>
401
-
402
- <h2>1. Основная концепция</h2>
403
- <p>ClientLess работает по принципу "Принеси свой сервер". Наш веб-клиент (WCL) является лишь интерфейсом, который рендерит данные, получаемые от вашего бэкенда через REST API и WebSockets.</p>
404
-
405
- <h2>2. Подключение к узлу (Node)</h2>
406
- <p>Для инициализации подключения вам потребуется <code class="inline">Project URL</code> и <code class="inline">Anon Key</code>. Эти данные используются для маршрутизации ваших пакетов.</p>
407
- <pre class="code-block">
408
- // Пример конфигурации подключения
409
- const clientConfig = {
410
- endpoint: "https://your-node.clientless.net",
411
- anonKey: "eyJhbGciOiJIUzI1NiIsInR5c...",
412
- timeout: 5000
413
- };
414
-
415
- WCL.init(clientConfig);</pre>
416
-
417
- <h2>3. Авторизация</h2>
418
- <p>Система поддерживает базовую авторизацию по логину и паролю. После успешной валидации сервер возвращает JWT токен.</p>
419
 
420
- <div class="bg-blue-50 p-4 border-l-4 border-blue-500 mt-6 text-sm text-gray-700">
421
- <strong>Примечание:</strong> Пароли передаются в захэшированном виде (SHA-256) даже чер��з HTTPS.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  </div>
 
423
  </div>
424
  </div>
425
  </div>
426
 
427
- <div id="screen-server" class="screen justify-center items-center">
428
- <div class="bg-white p-8 rounded-sm card-shadow w-full max-w-md mx-4">
429
- <div class="text-center mb-6">
430
- <i class="fa-solid fa-server text-brand-blue text-4xl mb-3"></i>
431
- <h2 class="text-2xl font-bold">Выбор сервера</h2>
432
- <p class="text-gray-500 text-sm mt-1">Введите данные для подключения к узлу</p>
433
- </div>
434
-
435
- <form id="server-form" onsubmit="handleServerSubmit(event)">
436
- <div class="mb-4">
437
- <label class="block text-gray-700 text-sm font-bold mb-2">Project URL</label>
438
- <input type="text" id="project-url" class="legacy-input" placeholder="https://..." required value="https://node1.clientless.net">
439
  </div>
440
- <div class="mb-6">
441
- <label class="block text-gray-700 text-sm font-bold mb-2">Anon Key</label>
442
- <input type="password" id="anon-key" class="legacy-input" placeholder="Введите ключ доступа" required value="dummy-key-2015">
443
  </div>
444
- <button type="submit" class="legacy-btn w-full">Подключиться к узлу</button>
445
  </form>
446
- <div class="text-center mt-4">
447
- <a href="#" onclick="navigate('docs')" class="text-brand-blue text-sm hover:underline">Где взять эти данные?</a>
448
- </div>
449
  </div>
450
  </div>
451
 
452
- <div id="screen-auth" class="screen justify-center items-center">
453
- <div class="bg-white p-8 rounded-sm card-shadow w-full max-w-md mx-4">
454
- <div class="text-center mb-6">
455
- <i class="fa-solid fa-user-lock text-brand-blue text-4xl mb-3"></i>
456
- <h2 class="text-2xl font-bold">Авторизация</h2>
457
- <p class="text-gray-500 text-sm mt-1">Узел: <span id="display-node" class="font-medium text-gray-800"></span></p>
458
- </div>
459
-
460
- <form id="auth-form" onsubmit="handleAuthSubmit(event)">
461
- <div class="mb-4">
462
- <label class="block text-gray-700 text-sm font-bold mb-2">Имя пользователя</label>
463
- <input type="text" id="username" class="legacy-input" placeholder="Например, User123" required>
464
  </div>
465
- <div class="mb-6">
466
- <label class="block text-gray-700 text-sm font-bold mb-2">Пароль</label>
467
- <input type="password" id="password" class="legacy-input" placeholder="Ваш пароль" required>
468
  </div>
469
- <button type="submit" class="legacy-btn w-full">Войти / Регистрация</button>
470
  </form>
471
- <div class="text-center mt-4">
472
- <button onclick="navigate('server')" class="text-gray-500 text-sm hover:underline">Вернуться к выбору сервера</button>
473
- </div>
474
  </div>
475
  </div>
476
 
 
477
  <div id="screen-client" class="screen">
478
  <div id="wcl-layout">
479
- <!-- WCL Header -->
480
- <div class="wcl-header justify-between header-shadow z-20">
481
- <div class="flex items-center">
482
- <button onclick="toggleSidebar('left')" class="md:hidden mr-3 text-white focus:outline-none" title="Каналы">
483
- <i class="fa-solid fa-bars text-xl"></i>
484
- </button>
485
- <span class="font-bold text-lg md:text-xl">ClientLess</span>
486
- <span class="mx-2 text-blue-200 hidden sm:inline">|</span>
487
- <span id="current-channel-title" class="text-sm md:text-base font-normal text-blue-100">#general</span>
488
  </div>
489
- <div class="flex items-center text-sm">
490
- <span class="mr-4 hidden md:inline" id="wcl-connected-node">Узел: node1.clientless.net</span>
491
- <span class="font-bold mr-2 text-white" id="wcl-username">Гость</span>
492
- <button onclick="logout()" class="ml-2 p-1 hover:text-gray-200" title="Выйти">
493
- <i class="fa-solid fa-sign-out-alt"></i>
494
  </button>
495
- <button onclick="toggleSidebar('right')" class="lg:hidden ml-3 text-white focus:outline-none" title="Участники">
496
- <i class="fa-solid fa-users text-lg"></i>
 
 
 
 
497
  </button>
498
  </div>
499
  </div>
500
 
501
- <!-- WCL Body -->
502
  <div class="wcl-body">
503
- <!-- Оверлей для мобилок при открытии боковых панелей -->
504
  <div id="wcl-overlay" class="wcl-overlay" onclick="closeSidebars()"></div>
505
 
506
- <!-- Левое меню: Каналы -->
507
  <div id="wcl-left-sidebar" class="wcl-sidebar">
508
- <div class="list-header flex justify-between items-center">
509
- <span>Каналы на сервере</span>
510
- <button onclick="closeSidebars()" class="md:hidden text-gray-500">&times;</button>
511
- </div>
512
- <div class="overflow-y-auto flex-1" id="channels-list">
513
- <!-- Динамические каналы -->
514
- </div>
515
  </div>
516
 
517
  <!-- Центральная часть: Чат -->
518
  <div class="wcl-main">
519
- <!-- История сообщений -->
520
- <div class="chat-history" id="chat-box">
521
- <!-- Динамические сообщения -->
522
- </div>
523
 
524
- <!-- Панель цитаты / редактирования -->
525
- <div id="reply-banner" class="hidden bg-gray-100 border-t border-l-4 border-brand-blue px-4 py-2 flex justify-between items-center text-xs">
526
- <div class="overflow-hidden">
527
- <span class="font-bold text-brand-blue" id="reply-title">Ответ</span>
528
- <div class="text-gray-600 truncate selectable-text" id="reply-text"></div>
529
  </div>
530
- <button onclick="cancelActionState()" class="text-gray-500 hover:text-red-500 font-bold px-2 text-lg">&times;</button>
531
  </div>
532
 
533
- <!-- Ввод сообщения -->
534
  <div class="chat-input-area">
535
- <div class="flex items-center">
536
- <input type="text" id="message-input" class="legacy-input selectable-text flex-1 m-0" placeholder="Написать сообщение..." onkeypress="handleKeyPress(event)">
537
- <button onclick="sendMessage()" class="ml-3 text-brand-blue text-2xl hover:text-brand-hover cursor-pointer bg-transparent border-none p-1">
538
  <i class="fa-solid fa-paper-plane"></i>
539
  </button>
540
  </div>
541
  </div>
542
  </div>
543
 
544
- <!-- Правое меню: Пользователи -->
545
  <div id="wcl-right-sidebar" class="wcl-right-sidebar">
546
- <div class="list-header flex justify-between items-center">
547
- <span>Пользователи (<span id="user-count">4</span>)</span>
548
- <button onclick="closeSidebars()" class="lg:hidden text-gray-500">&times;</button>
549
- </div>
550
- <div class="overflow-y-auto flex-1" id="users-list">
551
- <!-- Динамический список пользователей -->
552
- </div>
553
  </div>
554
  </div>
555
  </div>
@@ -558,10 +839,10 @@ WCL.init(clientConfig);</pre>
558
  <!-- ПК Контекстное меню -->
559
  <div id="context-menu" class="custom-context-menu hidden">
560
  <div class="context-menu-item" onclick="onReplyClick()">
561
- <i class="fa-solid fa-reply text-gray-500"></i> Ответить
562
  </div>
563
  <div id="context-edit-btn" class="context-menu-item" onclick="onEditClick()">
564
- <i class="fa-solid fa-pen text-gray-500"></i> Редактировать
565
  </div>
566
  <div id="context-delete-btn" class="context-menu-item danger" onclick="onDeleteClick()">
567
  <i class="fa-solid fa-trash"></i> Удалить
@@ -571,77 +852,103 @@ WCL.init(clientConfig);</pre>
571
  <!-- Мобильное действие модальное окно -->
572
  <div id="mobile-action-modal" class="mobile-modal-overlay hidden" onclick="closeMobileModal(event)">
573
  <div class="mobile-modal-sheet" onclick="event.stopPropagation()">
574
- <div class="text-center font-bold text-gray-500 text-xs mb-3 border-b pb-2">ВЫБЕРИТЕ ДЕЙСТВИЕ</div>
575
  <div class="context-menu-item" onclick="onReplyClick(); closeMobileModal();">
576
- <i class="fa-solid fa-reply text-brand-blue text-lg"></i> Ответить
577
  </div>
578
  <div id="mobile-edit-btn" class="context-menu-item" onclick="onEditClick(); closeMobileModal();">
579
- <i class="fa-solid fa-pen text-brand-blue text-lg"></i> Редактировать
580
  </div>
581
  <div id="mobile-delete-btn" class="context-menu-item danger" onclick="onDeleteClick(); closeMobileModal();">
582
- <i class="fa-solid fa-trash text-lg"></i> Удалить
583
  </div>
584
  </div>
585
  </div>
586
 
587
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
588
  // Состояние приложения
589
  let appState = {
590
  projectUrl: '',
591
  anonKey: '',
592
- username: 'Гость'
 
593
  };
594
 
595
- // База каналов и сообщений
596
- let currentChannel = 'general';
597
- const channelsData = {
598
- 'general': {
599
- name: 'general',
600
- isPrivate: false,
601
- messages: [
602
- { id: 1, author: 'Система', text: 'Добро пожаловать в ClientLess Web!', time: '10:00', isSelf: false, replyTo: null },
603
- { id: 2, author: 'Admin_Alex', text: 'Привет всем новеньким! Кликните на любого пользователя справа, чтобы оттегать его.', time: '10:05', isSelf: false, replyTo: null },
604
- { id: 3, author: 'Sarah_Dev', text: 'Всем привет! Нажмите ПКМ по сообщению (или тапом на телефоне), чтобы вызвать контекстное меню.', time: '10:07', isSelf: false, replyTo: null }
605
- ]
606
- },
607
- 'development': {
608
- name: 'development',
609
- isPrivate: false,
610
- messages: [
611
- { id: 4, author: 'Neo1999', text: 'Обновили WS коннектор до последней версии.', time: '11:15', isSelf: false, replyTo: null },
612
- { id: 5, author: 'Sarah_Dev', text: '@Neo1999 Отличная работа! Клиент стал работать еще быстрее.', time: '11:20', isSelf: false, replyTo: null }
613
- ]
614
- },
615
- 'design_2015': {
616
- name: 'design_2015',
617
- isPrivate: false,
618
- messages: [
619
- { id: 6, author: 'CyberPunk2015', text: 'Стиль 2015 года воссоздан с точностью! Тень card-shadow смотрится отлично.', time: '12:00', isSelf: false, replyTo: null }
620
- ]
621
- },
622
- 'admins_only': {
623
- name: 'admins_only',
624
- isPrivate: true,
625
- messages: [
626
- { id: 7, author: 'Admin_Alex', text: 'Секретный канал разработчиков и администраторов.', time: '09:30', isSelf: false, replyTo: null }
627
- ]
628
- }
629
- };
630
-
631
- // Список пользователей
632
- const usersList = [
633
- { name: 'Admin_Alex', status: 'online' },
634
- { name: 'Sarah_Dev', status: 'online' },
635
- { name: 'Neo1999', status: 'offline' },
636
- { name: 'CyberPunk2015', status: 'offline' }
637
- ];
638
-
639
- // Переменные контекста действия с сообщением
640
  let selectedMessageId = null;
641
  let replyTargetMsg = null;
642
  let editingMsgId = null;
643
 
644
- // Навигация по экранам
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
645
  function navigate(screenId) {
646
  document.querySelectorAll('.screen').forEach(el => el.classList.remove('active'));
647
  document.getElementById('screen-' + screenId).classList.add('active');
@@ -649,100 +956,178 @@ WCL.init(clientConfig);</pre>
649
  const marketingNav = document.getElementById('marketing-nav');
650
  if (screenId === 'client') {
651
  marketingNav.style.display = 'none';
652
- renderChannelsList();
653
- renderUsersList();
654
- switchChannel(currentChannel);
655
  } else {
656
- marketingNav.style.display = 'block';
657
  }
658
  }
659
 
660
- // Выбор сервера
661
- function handleServerSubmit(e) {
 
 
 
 
 
 
 
 
 
 
 
 
662
  e.preventDefault();
663
- const url = document.getElementById('project-url').value;
664
- const key = document.getElementById('anon-key').value;
 
 
665
 
666
- if (url && key) {
 
 
 
 
 
667
  appState.projectUrl = url;
668
  appState.anonKey = key;
669
- try {
670
- const urlObj = new URL(url);
671
- document.getElementById('display-node').innerText = urlObj.hostname;
672
- document.getElementById('wcl-connected-node').innerText = 'Узел: ' + urlObj.hostname;
673
- } catch(err) {
674
- document.getElementById('display-node').innerText = url;
675
- document.getElementById('wcl-connected-node').innerText = 'Узел: ' + url;
676
- }
677
  navigate('auth');
 
 
 
678
  }
679
  }
680
 
681
- // Авторизация
682
- function handleAuthSubmit(e) {
683
  e.preventDefault();
684
- const user = document.getElementById('username').value.trim();
685
- const pass = document.getElementById('password').value;
686
-
687
- if (user && pass) {
688
- appState.username = user;
689
- document.getElementById('wcl-username').innerText = user;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
690
  navigate('client');
 
 
 
691
  }
692
  }
693
 
694
- // Выход
695
  function logout() {
696
- appState.username = 'Гость';
697
- document.getElementById('username').value = '';
698
- document.getElementById('password').value = '';
699
- closeSidebars();
 
 
 
700
  navigate('landing');
701
  }
702
 
703
- // --- Управление Боковыми Панелями (Мобилки) ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
  function toggleSidebar(side) {
705
- const leftSidebar = document.getElementById('wcl-left-sidebar');
706
- const rightSidebar = document.getElementById('wcl-right-sidebar');
707
  const overlay = document.getElementById('wcl-overlay');
708
 
709
- if (side === 'left') {
710
- const isOpen = leftSidebar.classList.contains('open');
711
- closeSidebars();
712
- if (!isOpen) {
713
- leftSidebar.classList.add('open');
714
- overlay.classList.add('active');
715
- }
716
- } else if (side === 'right') {
717
- const isOpen = rightSidebar.classList.contains('open');
718
  closeSidebars();
719
- if (!isOpen) {
720
- rightSidebar.classList.add('open');
721
- overlay.classList.add('active');
722
- }
723
  }
724
  }
725
 
726
  function closeSidebars() {
727
- document.getElementById('wcl-left-sidebar').classList.remove('open');
728
  document.getElementById('wcl-right-sidebar').classList.remove('open');
729
  document.getElementById('wcl-overlay').classList.remove('active');
730
  }
731
 
732
- // --- Переключение каналов ---
733
- function switchChannel(channelId) {
734
- if (!channelsData[channelId]) return;
735
- currentChannel = channelId;
736
- document.getElementById('current-channel-title').innerText = '#' + channelId;
 
737
 
738
- // Сброс активного действия
739
  cancelActionState();
740
  closeSidebars();
741
-
742
- // Обновление стилей каналов
743
  renderChannelsList();
744
-
745
- // Рендер сообщений
 
 
 
 
 
 
 
746
  renderMessages();
747
  }
748
 
@@ -750,16 +1135,14 @@ WCL.init(clientConfig);</pre>
750
  const container = document.getElementById('channels-list');
751
  container.innerHTML = '';
752
 
753
- Object.keys(channelsData).forEach(id => {
754
- const ch = channelsData[id];
755
  const item = document.createElement('div');
756
- item.className = `list-item ${id === currentChannel ? 'active' : ''}`;
757
- item.onclick = () => switchChannel(id);
758
 
759
- const iconClass = ch.isPrivate ? 'fa-lock' : 'fa-hashtag';
760
  item.innerHTML = `
761
- <i class="fa-solid ${iconClass} mr-3 ${id === currentChannel ? 'text-white' : 'text-gray-400'}"></i>
762
- <span class="font-medium">${ch.name}</span>
763
  `;
764
  container.appendChild(item);
765
  });
@@ -768,69 +1151,79 @@ WCL.init(clientConfig);</pre>
768
  function renderUsersList() {
769
  const container = document.getElementById('users-list');
770
  container.innerHTML = '';
 
771
 
772
- // Добавляем текущего пользователя первым
773
- const currentUsers = [{ name: appState.username + ' (Вы)', status: 'online', rawName: appState.username }, ...usersList];
774
- document.getElementById('user-count').innerText = currentUsers.length;
775
-
776
- currentUsers.forEach(u => {
777
  const item = document.createElement('div');
778
  item.className = 'list-item';
779
- const userNameToMention = u.rawName || u.name;
780
- item.onclick = () => insertMention(userNameToMention);
 
 
781
 
782
  item.innerHTML = `
783
- <span class="status-dot status-${u.status}"></span>
784
- <span class="font-medium text-gray-800 ${u.rawName ? 'font-bold' : ''}">${escapeHTML(u.name)}</span>
785
  `;
786
  container.appendChild(item);
787
  });
788
  }
789
 
790
- // Вставка упоминания пользователя @nickname
791
  function insertMention(username) {
792
  const input = document.getElementById('message-input');
793
- const cleanName = username.replace(/\s*\(Вы\)/, '');
794
- input.value = input.value ? `${input.value} @${cleanName} ` : `@${cleanName} `;
795
  input.focus();
796
  }
797
 
798
- // --- Рендеринг и Сообщения ---
 
 
 
 
 
 
 
 
 
 
799
  function renderMessages() {
800
  const chatBox = document.getElementById('chat-box');
801
- chatBox.innerHTML = '<div class="text-center text-gray-400 text-xs my-3 border-b pb-2 mx-6">Начало истории канала</div>';
802
-
803
- const msgs = channelsData[currentChannel].messages;
804
 
805
- msgs.forEach(msg => {
806
  const msgDiv = document.createElement('div');
807
- const isSelf = msg.author === appState.username || msg.isSelf;
808
- msgDiv.className = `message ${isSelf ? 'self' : ''}`;
809
- msgDiv.setAttribute('data-id', msg.id);
 
 
 
 
810
 
811
- // Контекстное меню по ПКМ и тапу на мобильном
812
  msgDiv.oncontextmenu = (e) => handleMessageContextMenu(e, msg.id, isSelf);
813
  msgDiv.onclick = (e) => {
814
- if (window.innerWidth < 768) {
815
- handleMessageContextMenu(e, msg.id, isSelf);
816
- }
817
  };
818
 
819
  let quoteHtml = '';
820
- if (msg.replyTo) {
 
 
 
 
821
  quoteHtml = `
822
- <div class="message-quote">
823
- <div class="font-bold text-brand-blue">${escapeHTML(msg.replyTo.author)}</div>
824
- <div class="truncate text-gray-600">${escapeHTML(msg.replyTo.text)}</div>
825
  </div>
826
  `;
827
  }
828
 
829
  msgDiv.innerHTML = `
830
- <div class="message-author">${escapeHTML(msg.author)}</div>
831
  ${quoteHtml}
832
- <div class="selectable-text">${formatMessageText(msg.text)}</div>
833
- <div class="message-time">${msg.time}</div>
834
  `;
835
 
836
  chatBox.appendChild(msgDiv);
@@ -839,52 +1232,46 @@ WCL.init(clientConfig);</pre>
839
  chatBox.scrollTop = chatBox.scrollHeight;
840
  }
841
 
842
- // Отправка / Редактирование Сообщения
843
- function sendMessage() {
 
 
 
 
 
 
 
 
 
 
844
  const input = document.getElementById('message-input');
845
  const text = input.value.trim();
846
- if (!text) return;
847
-
848
- const now = new Date();
849
- const timeStr = now.getHours().toString().padStart(2, '0') + ':' + now.getMinutes().toString().padStart(2, '0');
850
 
851
  if (editingMsgId !== null) {
852
- // Редактирование действующего сообщения
853
- const msg = channelsData[currentChannel].messages.find(m => m.id === editingMsgId);
854
- if (msg) {
855
- msg.text = text;
856
- }
857
  } else {
858
- // Новое сообщение
859
- const newMsg = {
860
- id: Date.now(),
861
- author: appState.username,
862
- text: text,
863
- time: timeStr,
864
- isSelf: true,
865
- replyTo: replyTargetMsg ? { author: replyTargetMsg.author, text: replyTargetMsg.text } : null
866
- };
867
- channelsData[currentChannel].messages.push(newMsg);
868
  }
869
 
870
  input.value = '';
871
  cancelActionState();
872
- renderMessages();
873
  }
874
 
875
  function handleKeyPress(e) {
876
- if (e.key === 'Enter') {
877
- sendMessage();
878
- }
879
  }
880
 
881
- // Форматирование @упоминаний
882
  function formatMessageText(text) {
883
  const escaped = escapeHTML(text);
884
  return escaped.replace(/@([a-zA-Z0-9_\-А-Яа-я]+)/g, '<span class="mention-tag" onclick="insertMention(\'$1\'); event.stopPropagation();">@$1</span>');
885
  }
886
 
887
- // --- Контекстное меню и Действия ---
888
  function handleMessageContextMenu(e, msgId, isSelf) {
889
  e.preventDefault();
890
  e.stopPropagation();
@@ -909,42 +1296,42 @@ WCL.init(clientConfig);</pre>
909
 
910
  function onReplyClick() {
911
  hideContextMenus();
912
- const msg = channelsData[currentChannel].messages.find(m => m.id === selectedMessageId);
913
  if (!msg) return;
914
 
915
  replyTargetMsg = msg;
916
  editingMsgId = null;
917
 
918
- document.getElementById('reply-title').innerText = 'Ответ пользователю ' + msg.author;
919
- document.getElementById('reply-text').innerText = msg.text;
920
  document.getElementById('reply-banner').classList.remove('hidden');
921
  document.getElementById('message-input').focus();
922
  }
923
 
924
  function onEditClick() {
925
  hideContextMenus();
926
- const msg = channelsData[currentChannel].messages.find(m => m.id === selectedMessageId);
927
  if (!msg) return;
928
 
929
  editingMsgId = msg.id;
930
  replyTargetMsg = null;
931
 
932
  document.getElementById('reply-title').innerText = 'Редактирование сообщения';
933
- document.getElementById('reply-text').innerText = msg.text;
934
  document.getElementById('reply-banner').classList.remove('hidden');
935
 
936
  const input = document.getElementById('message-input');
937
- input.value = msg.text;
938
  input.focus();
939
  }
940
 
941
- function onDeleteClick() {
942
  hideContextMenus();
943
  if (selectedMessageId === null) return;
944
-
945
- channelsData[currentChannel].messages = channelsData[currentChannel].messages.filter(m => m.id !== selectedMessageId);
 
946
  cancelActionState();
947
- renderMessages();
948
  }
949
 
950
  function cancelActionState() {
@@ -960,16 +1347,14 @@ WCL.init(clientConfig);</pre>
960
  document.getElementById('mobile-action-modal').classList.add('hidden');
961
  }
962
 
963
- function closeMobileModal(e) {
964
  document.getElementById('mobile-action-modal').classList.add('hidden');
965
  }
966
 
967
- // Закрываем контекстное меню ПК при клике в любое место
968
  document.addEventListener('click', () => {
969
  document.getElementById('context-menu').classList.add('hidden');
970
  });
971
 
972
- // Экранирование HTML
973
  function escapeHTML(str) {
974
  return String(str).replace(/[&<>'"]/g,
975
  tag => ({
@@ -982,8 +1367,11 @@ WCL.init(clientConfig);</pre>
982
  );
983
  }
984
 
985
- window.onload = function() {
986
- navigate('landing');
 
 
 
987
  };
988
  </script>
989
  </body>
 
1
  <!DOCTYPE html>
2
+ <html lang="ru" data-theme="light">
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>ClientLess - Легковесный мессенджер</title>
7
+ <script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
8
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
9
+
10
  <style>
11
+ @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
12
+
13
+ /* CSS переменные для поддержки светлой и темной тем */
14
+ :root[data-theme="light"] {
15
+ --bg-body: #e7ebf0;
16
+ --bg-card: #ffffff;
17
+ --bg-header: #5682a3;
18
+ --bg-header-text: #ffffff;
19
+ --text-primary: #222222;
20
+ --text-secondary: #707579;
21
+ --brand-color: #5682a3;
22
+ --brand-hover: #4a7290;
23
+ --msg-self-bg: #effdde;
24
+ --msg-other-bg: #ffffff;
25
+ --msg-mention-bg: #e8f5e9;
26
+ --msg-mention-border: #4caf50;
27
+ --border-color: #dcdcdc;
28
+ --input-bg: #ffffff;
29
+ --quote-bg: rgba(86, 130, 163, 0.08);
30
+ --shadow-card: 0 2px 5px 0 rgba(0,0,0,0.16), 0 2px 10px 0 rgba(0,0,0,0.12);
31
+ --shadow-header: 0 2px 5px rgba(0,0,0,0.2);
32
+ --scrollbar-thumb: #b0bec5;
33
+ --scrollbar-track: #f1f1f1;
34
+ }
35
+
36
+ :root[data-theme="dark"] {
37
+ --bg-body: #0f172a;
38
+ --bg-card: #1e293b;
39
+ --bg-header: #1e293b;
40
+ --bg-header-text: #f1f5f9;
41
+ --text-primary: #f8fafc;
42
+ --text-secondary: #94a3b8;
43
+ --brand-color: #38bdf8;
44
+ --brand-hover: #0284c7;
45
+ --msg-self-bg: #1e3a8a;
46
+ --msg-other-bg: #334155;
47
+ --msg-mention-bg: #14532d;
48
+ --msg-mention-border: #22c55e;
49
+ --border-color: #334155;
50
+ --input-bg: #0f172a;
51
+ --quote-bg: rgba(56, 189, 248, 0.15);
52
+ --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.4);
53
+ --shadow-header: 0 2px 8px rgba(0,0,0,0.5);
54
+ --scrollbar-thumb: #475569;
55
+ --scrollbar-track: #0f172a;
56
+ }
57
+
58
+ /* Общие сбросы и стили */
59
+ * {
60
+ box-sizing: border-box;
61
+ margin: 0;
62
+ padding: 0;
63
+ }
64
 
65
  body {
66
  font-family: 'Roboto', sans-serif;
67
+ background-color: var(--bg-body);
68
+ color: var(--text-primary);
69
+ min-height: 100vh;
 
70
  display: flex;
71
  flex-direction: column;
 
 
72
  user-select: none;
73
  -webkit-user-select: none;
74
+ transition: background-color 0.3s, color 0.3s;
75
+ }
76
+
77
+ /* Кастомный скроллбар */
78
+ ::-webkit-scrollbar {
79
+ width: 7px;
80
+ height: 7px;
81
+ }
82
+ ::-webkit-scrollbar-track {
83
+ background: var(--scrollbar-track);
84
+ }
85
+ ::-webkit-scrollbar-thumb {
86
+ background: var(--scrollbar-thumb);
87
+ border-radius: 4px;
88
+ }
89
+ ::-webkit-scrollbar-thumb:hover {
90
+ background: var(--brand-color);
91
  }
92
 
93
+ /* Выделение текста только в сообщениях и инпутах */
94
  .selectable-text, input, textarea, code, pre {
95
  user-select: text !important;
96
  -webkit-user-select: text !important;
 
 
97
  }
98
 
99
+ /* Шапка навигации сайта */
100
+ .marketing-navbar {
101
+ background-color: var(--bg-header);
102
+ color: var(--bg-header-text);
103
+ box-shadow: var(--shadow-header);
104
+ height: 60px;
105
+ display: flex;
106
+ align-items: center;
107
+ justify-content: space-between;
108
+ padding: 0 24px;
109
+ z-index: 50;
110
  }
111
 
112
+ .brand-logo {
113
+ display: flex;
114
+ align-items: center;
115
+ font-size: 20px;
116
+ font-weight: 700;
117
+ cursor: pointer;
118
+ gap: 10px;
119
  }
120
 
121
+ .nav-links {
122
+ display: flex;
123
+ align-items: center;
124
+ gap: 20px;
 
 
 
 
 
125
  }
126
 
127
+ .nav-links a {
128
+ color: var(--bg-header-text);
129
+ text-decoration: none;
130
+ font-size: 15px;
131
+ font-weight: 500;
132
+ opacity: 0.9;
133
+ transition: opacity 0.2s;
 
134
  }
135
+
136
+ .nav-links a:hover {
137
+ opacity: 1;
 
138
  }
139
 
140
+ /* Кнопки в стиле 2015 Material / Bootstrap 3 */
141
+ .btn-md {
142
+ background-color: var(--brand-color);
143
+ color: #ffffff;
144
  border: none;
145
  border-radius: 3px;
146
  padding: 10px 20px;
 
147
  font-weight: 500;
148
+ text-transform: uppercase;
149
+ font-size: 13px;
150
  cursor: pointer;
151
+ box-shadow: 0 1px 3px rgba(0,0,0,0.2);
152
  transition: background-color 0.2s, box-shadow 0.2s;
153
  }
154
+ .btn-md:hover {
155
+ background-color: var(--brand-hover);
156
+ box-shadow: 0 2px 6px rgba(0,0,0,0.3);
157
+ }
158
+
159
+ .btn-secondary {
160
+ background-color: var(--bg-card);
161
+ color: var(--text-primary);
162
+ border: 1px solid var(--border-color);
163
+ }
164
+ .btn-secondary:hover {
165
+ background-color: var(--bg-body);
166
+ }
167
+
168
+ .theme-toggle-btn {
169
+ background: transparent;
170
+ border: none;
171
+ color: var(--bg-header-text);
172
+ font-size: 18px;
173
+ cursor: pointer;
174
+ padding: 6px;
175
+ border-radius: 50%;
176
+ display: flex;
177
+ align-items: center;
178
+ justify-content: center;
179
  }
180
 
181
+ /* Экранные секции */
182
  .screen {
183
  display: none;
184
  flex: 1;
 
188
  flex-direction: column;
189
  }
190
 
191
+ /* Главная страница Langing */
192
+ .landing-container {
193
+ display: flex;
194
+ flex-direction: column;
195
+ align-items: center;
196
+ justify-content: center;
197
+ text-align: center;
198
+ padding: 40px 20px;
199
+ flex: 1;
200
+ }
201
+ .landing-hero {
202
+ max-width: 800px;
203
+ background: var(--bg-card);
204
+ padding: 40px;
205
+ border-radius: 4px;
206
+ box-shadow: var(--shadow-card);
207
+ }
208
+ .landing-title {
209
+ font-size: 36px;
210
+ font-weight: 700;
211
+ margin: 20px 0;
212
+ color: var(--text-primary);
213
+ }
214
+ .landing-desc {
215
+ font-size: 17px;
216
+ color: var(--text-secondary);
217
+ line-height: 1.6;
218
+ margin-bottom: 30px;
219
+ }
220
+
221
+ /* Документация */
222
+ .docs-wrapper {
223
+ display: flex;
224
+ width: 100%;
225
+ max-width: 1200px;
226
+ margin: 20px auto;
227
+ background: var(--bg-card);
228
+ border-radius: 4px;
229
+ box-shadow: var(--shadow-card);
230
+ min-height: calc(100vh - 120px);
231
+ overflow: hidden;
232
+ }
233
  .docs-sidebar {
234
+ width: 280px;
235
+ border-right: 1px solid var(--border-color);
236
+ background: var(--bg-card);
237
+ padding: 20px 0;
238
+ }
239
+ .docs-menu-item {
240
+ padding: 12px 24px;
241
+ font-size: 14px;
242
+ font-weight: 500;
243
+ color: var(--text-primary);
244
+ cursor: pointer;
245
+ border-left: 3px solid transparent;
246
+ display: block;
247
+ }
248
+ .docs-menu-item:hover, .docs-menu-item.active {
249
+ background: var(--quote-bg);
250
+ color: var(--brand-color);
251
+ border-left-color: var(--brand-color);
252
  }
253
  .docs-content {
254
  flex: 1;
255
  padding: 40px;
256
+ overflow-y: auto;
257
+ max-height: calc(100vh - 120px);
258
+ }
259
+ .docs-content h1 { font-size: 28px; margin-bottom: 15px; border-bottom: 2px solid var(--border-color); padding-bottom: 10px; }
260
+ .docs-content h2 { font-size: 20px; color: var(--brand-color); margin: 25px 0 10px 0; }
261
+ .docs-content p { font-size: 15px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 15px; }
262
+
263
+ code.inline {
264
+ background: var(--quote-bg);
265
+ color: var(--brand-color);
266
+ padding: 2px 6px;
267
+ border-radius: 3px;
268
+ font-family: monospace;
269
+ font-size: 13px;
270
+ }
271
+ pre.code-block {
272
+ background: #1e1e1e;
273
+ color: #d4d4d4;
274
+ padding: 16px;
275
+ border-radius: 4px;
276
+ font-family: monospace;
277
+ font-size: 13px;
278
+ overflow-x: auto;
279
+ margin: 15px 0;
280
+ line-height: 1.5;
281
+ border: 1px solid var(--border-color);
282
+ }
283
+
284
+ /* Формы подключения и входа */
285
+ .form-card {
286
+ background: var(--bg-card);
287
+ padding: 32px;
288
+ border-radius: 4px;
289
+ box-shadow: var(--shadow-card);
290
+ width: 100%;
291
+ max-width: 420px;
292
+ margin: auto;
293
+ }
294
+ .form-group {
295
+ margin-bottom: 20px;
296
+ }
297
+ .form-group label {
298
+ display: block;
299
+ font-size: 13px;
300
+ font-weight: 500;
301
+ margin-bottom: 6px;
302
+ color: var(--text-secondary);
303
+ }
304
+ .form-input {
305
+ width: 100%;
306
+ padding: 10px 12px;
307
+ border: 1px solid var(--border-color);
308
+ border-radius: 3px;
309
+ background: var(--input-bg);
310
+ color: var(--text-primary);
311
+ font-size: 14px;
312
+ outline: none;
313
+ transition: border-color 0.2s;
314
+ }
315
+ .form-input:focus {
316
+ border-color: var(--brand-color);
317
  }
 
 
 
 
318
 
319
+ /* Клиент WCL */
320
  #wcl-layout {
321
  height: 100vh;
322
  display: flex;
323
  flex-direction: column;
 
324
  overflow: hidden;
325
  }
326
  .wcl-header {
327
+ background-color: var(--bg-header);
328
+ color: var(--bg-header-text);
329
  height: 54px;
330
  display: flex;
331
  align-items: center;
332
+ justify-content: space-between;
333
  padding: 0 16px;
334
+ box-shadow: var(--shadow-header);
335
+ z-index: 20;
336
  }
337
  .wcl-body {
338
  display: flex;
339
  flex: 1;
340
  overflow: hidden;
 
341
  position: relative;
342
  }
343
  .wcl-sidebar {
344
  width: 260px;
345
+ background: var(--bg-card);
346
+ border-right: 1px solid var(--border-color);
347
  display: flex;
348
  flex-direction: column;
349
+ z-index: 15;
350
+ transition: transform 0.25s ease;
351
  }
352
  .wcl-right-sidebar {
353
  width: 250px;
354
+ background: var(--bg-card);
355
+ border-left: 1px solid var(--border-color);
356
  display: flex;
357
  flex-direction: column;
358
+ z-index: 15;
359
+ transition: transform 0.25s ease;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  }
 
361
  .wcl-main {
362
  flex: 1;
363
  display: flex;
364
  flex-direction: column;
365
+ background: var(--bg-body);
366
  position: relative;
367
  min-width: 0;
368
  }
369
+
370
  .list-header {
371
  padding: 14px 16px;
372
+ font-weight: 700;
373
+ color: var(--text-secondary);
374
+ font-size: 11px;
375
  text-transform: uppercase;
376
+ letter-spacing: 0.5px;
377
+ border-bottom: 1px solid var(--border-color);
 
378
  }
379
  .list-item {
380
  padding: 12px 16px;
381
  display: flex;
382
  align-items: center;
383
  cursor: pointer;
384
+ border-bottom: 1px solid var(--border-color);
385
+ color: var(--text-primary);
386
+ }
387
+ .list-item:hover {
388
+ background-color: var(--quote-bg);
389
+ }
390
+ .list-item.active {
391
+ background-color: var(--brand-color);
392
+ color: #ffffff !important;
393
  }
394
+ .list-item.active i {
395
+ color: #ffffff !important;
396
+ }
397
+
398
  .status-dot {
399
+ width: 9px;
400
+ height: 9px;
401
+ border-radius: 50%;
402
+ margin-right: 10px;
403
  }
404
  .status-online { background-color: #4caf50; }
405
  .status-offline { background-color: #9e9e9e; }
406
+
407
+ /* История чата и сообщения */
408
+ .chat-history {
409
+ flex: 1;
410
+ padding: 16px;
411
+ overflow-y: auto;
412
+ overflow-x: hidden;
413
+ display: flex;
414
+ flex-direction: column;
415
+ }
416
+
417
+ .message {
418
+ background: var(--msg-other-bg);
419
+ color: var(--text-primary);
420
+ padding: 10px 14px;
421
+ border-radius: 4px;
422
+ margin-bottom: 12px;
423
+ max-width: 80%;
424
+ box-shadow: 0 1px 2px rgba(0,0,0,0.1);
425
+ position: relative;
 
 
426
  word-break: break-word;
427
  overflow-wrap: anywhere;
428
+ transition: background-color 0.3s, box-shadow 0.3s, border-color 0.3s;
429
+ }
430
+ .message.self {
431
+ background: var(--msg-self-bg);
432
+ align-self: flex-end;
433
+ margin-left: auto;
434
+ }
435
+
436
+ /* Особенность: сообщение с упоминанием текущего пользователя становиться зеленым */
437
+ .message.mentioned-me {
438
+ background-color: var(--msg-mention-bg) !important;
439
+ border-left: 4px solid var(--msg-mention-border) !important;
440
+ }
441
+
442
+ .message-author {
443
+ font-weight: 700;
444
+ color: var(--brand-color);
445
+ font-size: 13px;
446
+ margin-bottom: 4px;
447
  }
 
 
448
  .message.self .message-author { display: none; }
449
+ .message-time {
450
+ font-size: 11px;
451
+ color: var(--text-secondary);
452
+ float: right;
453
+ margin-top: 4px;
454
+ margin-left: 10px;
455
+ }
456
+
457
+ /* АНИМАЦИЯ МОРГАЮЩЕГО СИНЕГО ВЫДЕЛЕНИЯ НА 3 СЕКУНДЫ */
458
+ @keyframes flashBlueAnimation {
459
+ 0% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0); background-color: initial; }
460
+ 20% { box-shadow: 0 0 14px 4px rgba(33, 150, 243, 0.9); background-color: #bbdefb !important; color: #000 !important; border-left: 4px solid #1976d2; }
461
+ 40% { box-shadow: 0 0 4px 1px rgba(33, 150, 243, 0.4); background-color: initial; }
462
+ 60% { box-shadow: 0 0 14px 4px rgba(33, 150, 243, 0.9); background-color: #bbdefb !important; color: #000 !important; border-left: 4px solid #1976d2; }
463
+ 80% { box-shadow: 0 0 4px 1px rgba(33, 150, 243, 0.4); background-color: initial; }
464
+ 100% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0); background-color: initial; }
465
+ }
466
+
467
+ .flash-blue {
468
+ animation: flashBlueAnimation 3s ease-in-out forwards;
469
+ }
470
+
471
+ /* Блок ответов/цитат в сообщении */
472
  .message-quote {
473
+ border-left: 3px solid var(--brand-color);
474
+ background: var(--quote-bg);
475
  padding: 4px 8px;
476
  border-radius: 2px;
477
  font-size: 12px;
478
  margin-bottom: 6px;
479
+ cursor: pointer;
 
480
  }
481
+ .message-quote:hover {
482
+ opacity: 0.85;
 
483
  }
484
 
 
485
  .mention-tag {
486
+ background-color: var(--quote-bg);
487
+ color: var(--brand-color);
488
  padding: 1px 4px;
489
  border-radius: 3px;
490
  font-weight: 500;
 
494
  text-decoration: underline;
495
  }
496
 
497
+ /* Поле ввода сообщения */
498
+ .chat-input-area {
499
+ background: var(--bg-card);
500
+ padding: 12px 16px;
501
+ border-top: 1px solid var(--border-color);
502
+ }
503
+ .chat-input-wrapper {
504
+ display: flex;
505
+ align-items: center;
506
+ gap: 10px;
507
+ }
508
+
509
+ /* Мобильные панельки и оверлей */
510
+ .wcl-overlay {
511
+ display: none;
512
+ position: absolute;
513
+ inset: 0;
514
+ background: rgba(0, 0, 0, 0.5);
515
+ z-index: 10;
516
+ }
517
+ .wcl-overlay.active { display: block; }
518
+
519
+ @media (max-width: 767px) {
520
+ .wcl-sidebar {
521
+ position: absolute;
522
+ top: 0; bottom: 0; left: 0;
523
+ transform: translateX(-100%);
524
+ }
525
+ .wcl-sidebar.open { transform: translateX(0); }
526
+ .docs-wrapper { flex-direction: column; }
527
+ .docs-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); }
528
+ }
529
+ @media (max-width: 1023px) {
530
+ .wcl-right-sidebar {
531
+ position: absolute;
532
+ top: 0; bottom: 0; right: 0;
533
+ transform: translateX(100%);
534
+ }
535
+ .wcl-right-sidebar.open { transform: translateX(0); }
536
+ }
537
+
538
+ /* Контекстные меню */
539
  .custom-context-menu {
540
  position: fixed;
541
+ background: var(--bg-card);
542
+ border: 1px solid var(--border-color);
543
+ box-shadow: var(--shadow-card);
544
  border-radius: 4px;
545
  z-index: 100;
546
+ min-width: 160px;
547
  padding: 4px 0;
548
  }
549
  .context-menu-item {
550
+ padding: 10px 16px;
551
  font-size: 14px;
552
+ color: var(--text-primary);
553
  cursor: pointer;
554
  display: flex;
555
  align-items: center;
556
  gap: 10px;
557
  }
558
  .context-menu-item:hover {
559
+ background-color: var(--quote-bg);
560
  }
561
  .context-menu-item.danger {
562
+ color: #ef4444;
 
 
 
563
  }
564
 
565
+ /* Модальное окно для мобилок */
566
  .mobile-modal-overlay {
567
  position: fixed;
568
  inset: 0;
569
+ background: rgba(0,0,0,0.5);
570
  z-index: 90;
571
  display: flex;
572
  align-items: flex-end;
573
  }
574
  .mobile-modal-sheet {
575
  width: 100%;
576
+ background: var(--bg-card);
577
  border-top-left-radius: 12px;
578
  border-top-right-radius: 12px;
579
+ padding: 16px 0 24px 0;
580
+ box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
 
 
 
 
 
581
  }
582
+
583
+ .hidden { display: none !important; }
584
  </style>
585
  </head>
586
  <body>
587
 
588
+ <nav id="marketing-nav" class="marketing-navbar">
589
+ <div class="brand-logo" onclick="navigate('landing')">
590
+ <i class="fa-solid fa-paper-plane"></i>
591
+ <span>ClientLess</span>
592
+ </div>
593
+
594
+ <div class="nav-links">
595
+ <a href="#" onclick="navigate('docs')">Docs</a>
596
+ <a href="#" onclick="alert('Скачивание клиента доступно в вашей панели уза.')">Скачать приложение</a>
597
+ <button onclick="navigate('server')" class="btn-md">Веб Версия</button>
598
+
599
+ <button onclick="toggleTheme()" class="theme-toggle-btn" title="Сменить тему">
600
+ <i class="fa-solid fa-moon" id="theme-icon-nav"></i>
601
+ </button>
 
 
 
 
602
  </div>
603
  </nav>
604
 
605
+ <!-- Экран Langing -->
606
+ <div id="screen-landing" class="screen active">
607
+ <div class="landing-container">
608
+ <div class="landing-hero">
609
+ <i class="fa-solid fa-cloud-bolt text-brand" style="font-size: 70px; color: var(--brand-color);"></i>
610
+ <h1 class="landing-title">Будущее децентрализованных коммуникаций</h1>
611
+ <p class="landing-desc">
612
+ ClientLess — легковесный протокол для создания собственных независимых серверов общения.
613
+ Полная изоляция данных, поддержку WebSocket в реальном времени, встроенное шифрование и минимальная нагрузка на клиентские устройства.
614
+ </p>
615
+ <div style="display: flex; gap: 15px; justify-content: center;">
616
+ <button onclick="navigate('server')" class="btn-md" style="padding: 12px 28px; font-size: 15px;">Запустить WCL</button>
617
+ <button onclick="navigate('docs')" class="btn-md btn-secondary" style="padding: 12px 28px; font-size: 15px;">Документация сервера</button>
618
+ </div>
 
619
  </div>
620
  </div>
621
  </div>
622
 
623
+ <!-- Экран Документации -->
624
+ <div id="screen-docs" class="screen">
625
+ <div class="docs-wrapper">
626
+ <div class="docs-sidebar">
627
+ <span class="docs-menu-item active" onclick="switchDocSection('overview', this)">1. Обзор архитектуры</span>
628
+ <span class="docs-menu-item" onclick="switchDocSection('schema', this)">2. Схема БД Supabase (SQL)</span>
629
+ <span class="docs-menu-item" onclick="switchDocSection('rls', this)">3. Защита и RLS Политики</span>
630
+ <span class="docs-menu-item" onclick="switchDocSection('wss', this)">4. WebSocket API</span>
 
 
 
 
631
  </div>
632
+ <div class="docs-content" id="docs-content-container">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
633
 
634
+ <div id="doc-overview">
635
+ <h1>1. Обзор архитектуры ClientLess</h1>
636
+ <p>ClientLess спроектирован по принципу <strong>Zero-Trust Server Frontend Interface</strong>. Наш веб-клиент не привязан к единому центральному бэкенду. Каждый администратор разворачивает собственный узел (Node) на базе PostgreSQL / Supabase.</p>
637
+ <p>Клиент осуществляет подключение с помощью двух ключей: <code class="inline">Project URL</code> и публичного API-ключа <code class="inline">Anon Key</code>.</p>
638
+ </div>
639
+
640
+ <div id="doc-schema" class="hidden">
641
+ <h1>2. Полный SQL-скрипт развертывания Supabase</h1>
642
+ <p>Выполните этот код в SQL Editor вашего Supabase проекта, чтобы создать реальную рабочую базу.</p>
643
+
644
+ <pre class="code-block"><code>-- =====================================================
645
+ -- ClientLess Working Database Schema
646
+ -- =====================================================
647
+
648
+ -- 1. Таблица Пользователей
649
+ CREATE TABLE public.users (
650
+ id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
651
+ username VARCHAR(64) UNIQUE NOT NULL,
652
+ created_at TIMESTAMPTZ DEFAULT NOW()
653
+ );
654
+
655
+ -- 2. Таблица Каналов
656
+ CREATE TABLE public.channels (
657
+ id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
658
+ name VARCHAR(64) NOT NULL,
659
+ created_at TIMESTAMPTZ DEFAULT NOW()
660
+ );
661
+
662
+ -- 3. Таблица Сообщений
663
+ CREATE TABLE public.messages (
664
+ id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
665
+ channel_id UUID REFERENCES public.channels(id) ON DELETE CASCADE NOT NULL,
666
+ user_id UUID REFERENCES public.users(id) ON DELETE CASCADE NOT NULL,
667
+ content TEXT NOT NULL,
668
+ reply_to_id UUID REFERENCES public.messages(id) ON DELETE SET NULL,
669
+ created_at TIMESTAMPTZ DEFAULT NOW()
670
+ );
671
+
672
+ -- Включаем Realtime для таблиц
673
+ ALTER PUBLICATION supabase_realtime ADD TABLE public.users;
674
+ ALTER PUBLICATION supabase_realtime ADD TABLE public.channels;
675
+ ALTER PUBLICATION supabase_realtime ADD TABLE public.messages;
676
+
677
+ -- Создаем базовый канал
678
+ INSERT INTO public.channels (name) VALUES ('general');</code></pre>
679
+ </div>
680
+
681
+ <div id="doc-rls" class="hidden">
682
+ <h1>3. Строгая настройка Row Level Security (RLS)</h1>
683
+ <p>Безопасность данных гарантируется на уровне СУБД PostgreSQL. Ни один пользователь не сможет читать личные сообщения чужих приватных каналов.</p>
684
+
685
+ <pre class="code-block"><code>-- Включение RLS для всех таблиц
686
+ ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;
687
+ ALTER TABLE public.channels ENABLE ROW LEVEL SECURITY;
688
+ ALTER TABLE public.channel_members ENABLE ROW LEVEL SECURITY;
689
+ ALTER TABLE public.messages ENABLE ROW LEVEL SECURITY;
690
+
691
+ -- Политики чтения профилей
692
+ CREATE POLICY "Profiles viewable by authenticated"
693
+ ON public.profiles FOR SELECT USING (auth.role() = 'authenticated');
694
+
695
+ -- Политики доступа к сообщениям
696
+ CREATE POLICY "Messages readable by channel members"
697
+ ON public.messages FOR SELECT
698
+ USING (EXISTS (
699
+ SELECT 1 FROM public.channels c
700
+ LEFT JOIN public.channel_members cm ON c.id = cm.channel_id
701
+ WHERE c.id = messages.channel_id
702
+ AND (c.type = 'public' OR cm.user_id = auth.uid())
703
+ ));
704
+
705
+ CREATE POLICY "Insert messages allowed for channel members"
706
+ ON public.messages FOR INSERT
707
+ WITH CHECK (
708
+ auth.uid() = author_id AND EXISTS (
709
+ SELECT 1 FROM public.channels c
710
+ LEFT JOIN public.channel_members cm ON c.id = cm.channel_id
711
+ WHERE c.id = messages.channel_id
712
+ AND (c.type = 'public' OR cm.user_id = auth.uid())
713
+ )
714
+ );
715
+
716
+ CREATE POLICY "Users can edit own messages"
717
+ ON public.messages FOR UPDATE USING (auth.uid() = author_id);
718
+
719
+ CREATE POLICY "Users can delete own messages"
720
+ ON public.messages FOR DELETE USING (auth.uid() = author_id);</code></pre>
721
+ </div>
722
+
723
+ <div id="doc-wss" class="hidden">
724
+ <h1>4. Реальный WebSocket протокол</h1>
725
+ <p>Обмен сообщениями происходит через протокол Realtime Broadcast over WebSockets. Клиент подписывается на топик вида <code class="inline">realtime:public:messages:channel_id=eq.{ID}</code>.</p>
726
  </div>
727
+
728
  </div>
729
  </div>
730
  </div>
731
 
732
+ <!-- Экран подключения к узлу -->
733
+ <div id="screen-server" class="screen">
734
+ <div class="form-card">
735
+ <h2 style="font-size: 22px; margin-bottom: 6px;">Подключение к узлу</h2>
736
+ <p style="color: var(--text-secondary); font-size: 13px; margin-bottom: 24px;">Введите данные вашего узла ClientLess</p>
737
+
738
+ <form onsubmit="handleServerSubmit(event)">
739
+ <div id="server-error" style="color: #ef4444; font-size: 13px; margin-bottom: 10px; display: none;"></div>
740
+ <div class="form-group">
741
+ <label>Project URL</label>
742
+ <input type="text" id="project-url" class="form-input" required placeholder="https://xyz.supabase.co">
 
743
  </div>
744
+ <div class="form-group">
745
+ <label>Anon Key</label>
746
+ <input type="password" id="anon-key" class="form-input" required placeholder="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...">
747
  </div>
748
+ <button type="submit" class="btn-md" style="width: 100%;">Подключиться</button>
749
  </form>
 
 
 
750
  </div>
751
  </div>
752
 
753
+ <!-- Экран Входа / Регистрации -->
754
+ <div id="screen-auth" class="screen">
755
+ <div class="form-card">
756
+ <h2 style="font-size: 22px; margin-bottom: 6px;">Авторизация</h2>
757
+ <p style="color: var(--text-secondary); font-size: 13px; margin-bottom: 24px;">Узел: <span id="display-node" style="font-weight: 500; color: var(--text-primary);"></span></p>
758
+
759
+ <form onsubmit="handleAuthSubmit(event)">
760
+ <div id="auth-error" style="color: #ef4444; font-size: 13px; margin-bottom: 10px; display: none;"></div>
761
+ <div class="form-group">
762
+ <label>Имя пользователя</label>
763
+ <input type="text" id="username" class="form-input" placeholder="например: User123" required>
 
764
  </div>
765
+ <div class="form-group">
766
+ <label>Пароль (Опционально)</label>
767
+ <input type="password" id="password" class="form-input">
768
  </div>
769
+ <button type="submit" class="btn-md" style="width: 100%;">Войти / Зарегистрироваться</button>
770
  </form>
 
 
 
771
  </div>
772
  </div>
773
 
774
+ <!-- Экран Клиента WCL -->
775
  <div id="screen-client" class="screen">
776
  <div id="wcl-layout">
777
+ <div class="wcl-header">
778
+ <div style="display: flex; align-items: center; gap: 12px;">
779
+ <span style="font-weight: 700; margin-left: 8px;">ClientLess</span>
780
+ <span style="opacity: 0.5;">|</span>
781
+ <span id="current-channel-title" style="font-size: 14px; opacity: 0.9;">#general</span>
 
 
 
 
782
  </div>
783
+
784
+ <div style="display: flex; align-items: center; gap: 16px;">
785
+ <button onclick="toggleTheme()" class="theme-toggle-btn">
786
+ <i class="fa-solid fa-moon" id="theme-icon-client"></i>
 
787
  </button>
788
+ <span style="font-size: 13px;" id="wcl-username">Гость</span>
789
+ <button onclick="logout()" style="background:none; border:none; color:inherit; cursor:pointer;" title="Выйти">
790
+ <i class="fa-solid fa-right-from-bracket"></i>
791
+ </button>
792
+ <button onclick="toggleSidebar('right')" style="background:none; border:none; color:inherit; cursor:pointer;" title="Участники">
793
+ <i class="fa-solid fa-users"></i>
794
  </button>
795
  </div>
796
  </div>
797
 
 
798
  <div class="wcl-body">
 
799
  <div id="wcl-overlay" class="wcl-overlay" onclick="closeSidebars()"></div>
800
 
801
+ <!-- Левая боковая панель: Каналы -->
802
  <div id="wcl-left-sidebar" class="wcl-sidebar">
803
+ <div class="list-header">Каналы</div>
804
+ <div style="overflow-y: auto; flex: 1;" id="channels-list"></div>
 
 
 
 
 
805
  </div>
806
 
807
  <!-- Центральная часть: Чат -->
808
  <div class="wcl-main">
809
+ <div class="chat-history" id="chat-box"></div>
 
 
 
810
 
811
+ <!-- Банер ответа / редактирования -->
812
+ <div id="reply-banner" class="hidden" style="background: var(--bg-card); border-top: 1px solid var(--border-color); padding: 8px 16px; display: flex; justify-content: space-between; align-items: center;">
813
+ <div>
814
+ <span id="reply-title" style="font-weight: 700; color: var(--brand-color); font-size: 12px;"></span>
815
+ <div id="reply-text" style="font-size: 13px; color: var(--text-secondary); max-width: 400px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"></div>
816
  </div>
817
+ <button onclick="cancelActionState()" style="background:none; border:none; font-size: 18px; color: var(--text-secondary); cursor:pointer;">&times;</button>
818
  </div>
819
 
 
820
  <div class="chat-input-area">
821
+ <div class="chat-input-wrapper">
822
+ <input type="text" id="message-input" class="form-input selectable-text" placeholder="Написать сообщение..." onkeypress="handleKeyPress(event)">
823
+ <button onclick="sendMessage()" class="btn-md">
824
  <i class="fa-solid fa-paper-plane"></i>
825
  </button>
826
  </div>
827
  </div>
828
  </div>
829
 
830
+ <!-- Правая боковая панель: Список участников -->
831
  <div id="wcl-right-sidebar" class="wcl-right-sidebar">
832
+ <div class="list-header">Участники (<span id="user-count">0</span>)</div>
833
+ <div style="overflow-y: auto; flex: 1;" id="users-list"></div>
 
 
 
 
 
834
  </div>
835
  </div>
836
  </div>
 
839
  <!-- ПК Контекстное меню -->
840
  <div id="context-menu" class="custom-context-menu hidden">
841
  <div class="context-menu-item" onclick="onReplyClick()">
842
+ <i class="fa-solid fa-reply"></i> Ответить
843
  </div>
844
  <div id="context-edit-btn" class="context-menu-item" onclick="onEditClick()">
845
+ <i class="fa-solid fa-pen"></i> Редактировать
846
  </div>
847
  <div id="context-delete-btn" class="context-menu-item danger" onclick="onDeleteClick()">
848
  <i class="fa-solid fa-trash"></i> Удалить
 
852
  <!-- Мобильное действие модальное окно -->
853
  <div id="mobile-action-modal" class="mobile-modal-overlay hidden" onclick="closeMobileModal(event)">
854
  <div class="mobile-modal-sheet" onclick="event.stopPropagation()">
855
+ <div style="text-align: center; font-weight: 700; color: var(--text-secondary); font-size: 12px; margin-bottom: 12px;">ДЕЙСТВИЕ</div>
856
  <div class="context-menu-item" onclick="onReplyClick(); closeMobileModal();">
857
+ <i class="fa-solid fa-reply"></i> Ответить
858
  </div>
859
  <div id="mobile-edit-btn" class="context-menu-item" onclick="onEditClick(); closeMobileModal();">
860
+ <i class="fa-solid fa-pen"></i> Редактировать
861
  </div>
862
  <div id="mobile-delete-btn" class="context-menu-item danger" onclick="onDeleteClick(); closeMobileModal();">
863
+ <i class="fa-solid fa-trash"></i> Удалить
864
  </div>
865
  </div>
866
  </div>
867
 
868
  <script>
869
+ // Глобальные переменные для работы с Supabase
870
+ let supabaseClient = null;
871
+ let currentUser = null;
872
+ let currentChannelId = null;
873
+
874
+ // Данные
875
+ let channelsData = [];
876
+ let messagesData = [];
877
+ let usersData = [];
878
+
879
+ let realtimeSubscription = null;
880
+
881
  // Состояние приложения
882
  let appState = {
883
  projectUrl: '',
884
  anonKey: '',
885
+ username: '',
886
+ theme: 'light'
887
  };
888
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
889
  let selectedMessageId = null;
890
  let replyTargetMsg = null;
891
  let editingMsgId = null;
892
 
893
+ // Переключение тем
894
+ function toggleTheme() {
895
+ appState.theme = appState.theme === 'light' ? 'dark' : 'light';
896
+ document.documentElement.setAttribute('data-theme', appState.theme);
897
+
898
+ const iconNav = document.getElementById('theme-icon-nav');
899
+ const iconClient = document.getElementById('theme-icon-client');
900
+
901
+ if (appState.theme === 'dark') {
902
+ if(iconNav) iconNav.className = 'fa-solid fa-sun';
903
+ if(iconClient) iconClient.className = 'fa-solid fa-sun';
904
+ } else {
905
+ if(iconNav) iconNav.className = 'fa-solid fa-moon';
906
+ if(iconClient) iconClient.className = 'fa-solid fa-moon';
907
+ }
908
+ saveSession();
909
+ }
910
+
911
+ // Запоминание сессии
912
+ function saveSession() {
913
+ if (appState.username && appState.projectUrl) {
914
+ const session = JSON.stringify(appState);
915
+ window.name = session;
916
+ }
917
+ }
918
+
919
+ async function restoreSession() {
920
+ try {
921
+ if (window.name) {
922
+ const saved = JSON.parse(window.name);
923
+ if (saved && saved.username && saved.projectUrl) {
924
+ appState = saved;
925
+ document.getElementById('wcl-username').innerText = appState.username;
926
+ document.documentElement.setAttribute('data-theme', appState.theme || 'light');
927
+
928
+ // Авто-подключение к БД
929
+ supabaseClient = supabase.createClient(appState.projectUrl, appState.anonKey);
930
+
931
+ // Получаем пользователя
932
+ const { data: user } = await supabaseClient
933
+ .from('users')
934
+ .select('*')
935
+ .eq('username', appState.username)
936
+ .single();
937
+
938
+ if (user) {
939
+ currentUser = user;
940
+ await initApp();
941
+ navigate('client');
942
+ return true;
943
+ }
944
+ }
945
+ }
946
+ } catch(e) {
947
+ console.error("Session restore error:", e);
948
+ }
949
+ return false;
950
+ }
951
+
952
  function navigate(screenId) {
953
  document.querySelectorAll('.screen').forEach(el => el.classList.remove('active'));
954
  document.getElementById('screen-' + screenId).classList.add('active');
 
956
  const marketingNav = document.getElementById('marketing-nav');
957
  if (screenId === 'client') {
958
  marketingNav.style.display = 'none';
 
 
 
959
  } else {
960
+ marketingNav.style.display = 'flex';
961
  }
962
  }
963
 
964
+ function switchDocSection(sectionId, el) {
965
+ document.querySelectorAll('.docs-menu-item').forEach(m => m.classList.remove('active'));
966
+ if(el) el.classList.add('active');
967
+
968
+ ['overview', 'schema', 'rls', 'wss'].forEach(id => {
969
+ const docEl = document.getElementById('doc-' + id);
970
+ if (docEl) {
971
+ if (id === sectionId) docEl.classList.remove('hidden');
972
+ else docEl.classList.add('hidden');
973
+ }
974
+ });
975
+ }
976
+
977
+ async function handleServerSubmit(e) {
978
  e.preventDefault();
979
+ const errDiv = document.getElementById('server-error');
980
+ errDiv.style.display = 'none';
981
+ const url = document.getElementById('project-url').value.trim();
982
+ const key = document.getElementById('anon-key').value.trim();
983
 
984
+ try {
985
+ supabaseClient = supabase.createClient(url, key);
986
+ // Проверка соединения - пробуем получить 1 канал
987
+ const { error } = await supabaseClient.from('channels').select('id').limit(1);
988
+ if (error) throw error;
989
+
990
  appState.projectUrl = url;
991
  appState.anonKey = key;
992
+ document.getElementById('display-node').innerText = url;
 
 
 
 
 
 
 
993
  navigate('auth');
994
+ } catch(err) {
995
+ errDiv.innerText = 'Ошибка подключения. Проверьте URL и Key базы данных. ' + (err.message || '');
996
+ errDiv.style.display = 'block';
997
  }
998
  }
999
 
1000
+ async function handleAuthSubmit(e) {
 
1001
  e.preventDefault();
1002
+ const errDiv = document.getElementById('auth-error');
1003
+ errDiv.style.display = 'none';
1004
+ const username = document.getElementById('username').value.trim();
1005
+ if (!username) return;
1006
+
1007
+ try {
1008
+ // Ищем юзера или создаем нового
1009
+ let { data: user, error: searchError } = await supabaseClient
1010
+ .from('users')
1011
+ .select('*')
1012
+ .eq('username', username)
1013
+ .single();
1014
+
1015
+ if (searchError && searchError.code === 'PGRST116') {
1016
+ // Пользователь не найден, создаем
1017
+ const { data: newUser, error: insertError } = await supabaseClient
1018
+ .from('users')
1019
+ .insert([{ username }])
1020
+ .select()
1021
+ .single();
1022
+ if (insertError) throw insertError;
1023
+ user = newUser;
1024
+ } else if (searchError) {
1025
+ throw searchError;
1026
+ }
1027
+
1028
+ currentUser = user;
1029
+ appState.username = user.username;
1030
+ document.getElementById('wcl-username').innerText = user.username;
1031
+ saveSession();
1032
+ await initApp();
1033
  navigate('client');
1034
+ } catch (err) {
1035
+ errDiv.innerText = 'Ошибка авторизации: ' + (err.message || err.details || 'Неизвестная ошибка');
1036
+ errDiv.style.display = 'block';
1037
  }
1038
  }
1039
 
 
1040
  function logout() {
1041
+ if(realtimeSubscription) realtimeSubscription.unsubscribe();
1042
+ appState.username = '';
1043
+ appState.projectUrl = '';
1044
+ appState.anonKey = '';
1045
+ window.name = '';
1046
+ currentUser = null;
1047
+ supabaseClient = null;
1048
  navigate('landing');
1049
  }
1050
 
1051
+ async function initApp() {
1052
+ // Загружаем всех пользователей
1053
+ const { data: uData } = await supabaseClient.from('users').select('*');
1054
+ if (uData) usersData = uData;
1055
+ renderUsersList();
1056
+
1057
+ // Загружаем каналы
1058
+ const { data: cData } = await supabaseClient.from('channels').select('*').order('created_at', { ascending: true });
1059
+ if (cData) channelsData = cData;
1060
+
1061
+ if (channelsData.length > 0) {
1062
+ await switchChannel(channelsData[0].id);
1063
+ }
1064
+
1065
+ // Подписка на Realtime изменения в Supabase
1066
+ if (realtimeSubscription) realtimeSubscription.unsubscribe();
1067
+ realtimeSubscription = supabaseClient.channel('public-db-changes')
1068
+ .on('postgres_changes', { event: '*', schema: 'public', table: 'messages' }, payload => {
1069
+ if (payload.eventType === 'INSERT') {
1070
+ if (payload.new.channel_id === currentChannelId) {
1071
+ messagesData.push(payload.new);
1072
+ renderMessages();
1073
+ }
1074
+ } else if (payload.eventType === 'DELETE') {
1075
+ messagesData = messagesData.filter(m => m.id !== payload.old.id);
1076
+ renderMessages();
1077
+ } else if (payload.eventType === 'UPDATE') {
1078
+ const idx = messagesData.findIndex(m => m.id === payload.new.id);
1079
+ if(idx !== -1) {
1080
+ messagesData[idx] = payload.new;
1081
+ renderMessages();
1082
+ }
1083
+ }
1084
+ })
1085
+ .on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'users' }, payload => {
1086
+ usersData.push(payload.new);
1087
+ renderUsersList();
1088
+ })
1089
+ .on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'channels' }, payload => {
1090
+ channelsData.push(payload.new);
1091
+ renderChannelsList();
1092
+ })
1093
+ .subscribe();
1094
+ }
1095
+
1096
  function toggleSidebar(side) {
1097
+ const right = document.getElementById('wcl-right-sidebar');
 
1098
  const overlay = document.getElementById('wcl-overlay');
1099
 
1100
+ if (side === 'right') {
1101
+ const isOpen = right.classList.contains('open');
 
 
 
 
 
 
 
1102
  closeSidebars();
1103
+ if (!isOpen) { right.classList.add('open'); overlay.classList.add('active'); }
 
 
 
1104
  }
1105
  }
1106
 
1107
  function closeSidebars() {
 
1108
  document.getElementById('wcl-right-sidebar').classList.remove('open');
1109
  document.getElementById('wcl-overlay').classList.remove('active');
1110
  }
1111
 
1112
+ async function switchChannel(channelId) {
1113
+ currentChannelId = channelId;
1114
+ const ch = channelsData.find(c => c.id === channelId);
1115
+ if (ch) {
1116
+ document.getElementById('current-channel-title').innerText = '#' + ch.name;
1117
+ }
1118
 
 
1119
  cancelActionState();
1120
  closeSidebars();
 
 
1121
  renderChannelsList();
1122
+
1123
+ // Загрузка сообщений канала
1124
+ const { data: mData } = await supabaseClient
1125
+ .from('messages')
1126
+ .select('*')
1127
+ .eq('channel_id', channelId)
1128
+ .order('created_at', { ascending: true });
1129
+
1130
+ messagesData = mData || [];
1131
  renderMessages();
1132
  }
1133
 
 
1135
  const container = document.getElementById('channels-list');
1136
  container.innerHTML = '';
1137
 
1138
+ channelsData.forEach(ch => {
 
1139
  const item = document.createElement('div');
1140
+ item.className = `list-item ${ch.id === currentChannelId ? 'active' : ''}`;
1141
+ item.onclick = () => switchChannel(ch.id);
1142
 
 
1143
  item.innerHTML = `
1144
+ <i class="fa-solid fa-hashtag" style="margin-right: 10px;"></i>
1145
+ <span style="font-weight: 500;">${escapeHTML(ch.name)}</span>
1146
  `;
1147
  container.appendChild(item);
1148
  });
 
1151
  function renderUsersList() {
1152
  const container = document.getElementById('users-list');
1153
  container.innerHTML = '';
1154
+ document.getElementById('user-count').innerText = usersData.length;
1155
 
1156
+ usersData.forEach(u => {
 
 
 
 
1157
  const item = document.createElement('div');
1158
  item.className = 'list-item';
1159
+ item.onclick = () => insertMention(u.username);
1160
+
1161
+ const isMe = currentUser && u.id === currentUser.id;
1162
+ const displayName = isMe ? `${u.username} (Вы)` : u.username;
1163
 
1164
  item.innerHTML = `
1165
+ <span class="status-dot status-online"></span>
1166
+ <span style="font-weight: 500;">${escapeHTML(displayName)}</span>
1167
  `;
1168
  container.appendChild(item);
1169
  });
1170
  }
1171
 
 
1172
  function insertMention(username) {
1173
  const input = document.getElementById('message-input');
1174
+ input.value = input.value ? `${input.value} @${username} ` : `@${username} `;
 
1175
  input.focus();
1176
  }
1177
 
1178
+ function getUserName(id) {
1179
+ const u = usersData.find(x => x.id === id);
1180
+ return u ? u.username : 'Unknown';
1181
+ }
1182
+
1183
+ function formatTime(isoStr) {
1184
+ if (!isoStr) return '';
1185
+ const d = new Date(isoStr);
1186
+ return d.getHours().toString().padStart(2, '0') + ':' + d.getMinutes().toString().padStart(2, '0');
1187
+ }
1188
+
1189
  function renderMessages() {
1190
  const chatBox = document.getElementById('chat-box');
1191
+ chatBox.innerHTML = '';
 
 
1192
 
1193
+ messagesData.forEach(msg => {
1194
  const msgDiv = document.createElement('div');
1195
+ const isSelf = currentUser && msg.user_id === currentUser.id;
1196
+ const authorName = getUserName(msg.user_id);
1197
+
1198
+ const isMentioned = currentUser && msg.content.toLowerCase().includes(`@${currentUser.username.toLowerCase()}`);
1199
+
1200
+ msgDiv.className = `message ${isSelf ? 'self' : ''} ${isMentioned ? 'mentioned-me' : ''}`;
1201
+ msgDiv.id = `msg-${msg.id}`;
1202
 
 
1203
  msgDiv.oncontextmenu = (e) => handleMessageContextMenu(e, msg.id, isSelf);
1204
  msgDiv.onclick = (e) => {
1205
+ if (window.innerWidth < 768) handleMessageContextMenu(e, msg.id, isSelf);
 
 
1206
  };
1207
 
1208
  let quoteHtml = '';
1209
+ if (msg.reply_to_id) {
1210
+ const replyOriginalMsg = messagesData.find(m => m.id === msg.reply_to_id);
1211
+ const replyAuthor = replyOriginalMsg ? getUserName(replyOriginalMsg.user_id) : 'Unknown';
1212
+ const replyText = replyOriginalMsg ? replyOriginalMsg.content : 'Удаленное сообщение';
1213
+
1214
  quoteHtml = `
1215
+ <div class="message-quote" onclick="scrollToMessage('${msg.reply_to_id}'); event.stopPropagation();">
1216
+ <div style="font-weight: 700; color: var(--brand-color);">${escapeHTML(replyAuthor)}</div>
1217
+ <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">${escapeHTML(replyText)}</div>
1218
  </div>
1219
  `;
1220
  }
1221
 
1222
  msgDiv.innerHTML = `
1223
+ <div class="message-author">${escapeHTML(authorName)}</div>
1224
  ${quoteHtml}
1225
+ <div class="selectable-text">${formatMessageText(msg.content)}</div>
1226
+ <div class="message-time">${formatTime(msg.created_at)}</div>
1227
  `;
1228
 
1229
  chatBox.appendChild(msgDiv);
 
1232
  chatBox.scrollTop = chatBox.scrollHeight;
1233
  }
1234
 
1235
+ function scrollToMessage(targetId) {
1236
+ const targetEl = document.getElementById(`msg-${targetId}`);
1237
+ if (targetEl) {
1238
+ targetEl.scrollIntoView({ behavior: 'smooth', block: 'center' });
1239
+ targetEl.classList.remove('flash-blue');
1240
+ void targetEl.offsetWidth;
1241
+ targetEl.classList.add('flash-blue');
1242
+ setTimeout(() => targetEl.classList.remove('flash-blue'), 3000);
1243
+ }
1244
+ }
1245
+
1246
+ async function sendMessage() {
1247
  const input = document.getElementById('message-input');
1248
  const text = input.value.trim();
1249
+ if (!text || !currentChannelId || !currentUser) return;
 
 
 
1250
 
1251
  if (editingMsgId !== null) {
1252
+ await supabaseClient.from('messages').update({ content: text }).eq('id', editingMsgId);
 
 
 
 
1253
  } else {
1254
+ await supabaseClient.from('messages').insert([{
1255
+ channel_id: currentChannelId,
1256
+ user_id: currentUser.id,
1257
+ content: text,
1258
+ reply_to_id: replyTargetMsg ? replyTargetMsg.id : null
1259
+ }]);
 
 
 
 
1260
  }
1261
 
1262
  input.value = '';
1263
  cancelActionState();
 
1264
  }
1265
 
1266
  function handleKeyPress(e) {
1267
+ if (e.key === 'Enter') sendMessage();
 
 
1268
  }
1269
 
 
1270
  function formatMessageText(text) {
1271
  const escaped = escapeHTML(text);
1272
  return escaped.replace(/@([a-zA-Z0-9_\-А-Яа-я]+)/g, '<span class="mention-tag" onclick="insertMention(\'$1\'); event.stopPropagation();">@$1</span>');
1273
  }
1274
 
 
1275
  function handleMessageContextMenu(e, msgId, isSelf) {
1276
  e.preventDefault();
1277
  e.stopPropagation();
 
1296
 
1297
  function onReplyClick() {
1298
  hideContextMenus();
1299
+ const msg = messagesData.find(m => m.id === selectedMessageId);
1300
  if (!msg) return;
1301
 
1302
  replyTargetMsg = msg;
1303
  editingMsgId = null;
1304
 
1305
+ document.getElementById('reply-title').innerText = 'Ответ пользователю ' + getUserName(msg.user_id);
1306
+ document.getElementById('reply-text').innerText = msg.content;
1307
  document.getElementById('reply-banner').classList.remove('hidden');
1308
  document.getElementById('message-input').focus();
1309
  }
1310
 
1311
  function onEditClick() {
1312
  hideContextMenus();
1313
+ const msg = messagesData.find(m => m.id === selectedMessageId);
1314
  if (!msg) return;
1315
 
1316
  editingMsgId = msg.id;
1317
  replyTargetMsg = null;
1318
 
1319
  document.getElementById('reply-title').innerText = 'Редактирование сообщения';
1320
+ document.getElementById('reply-text').innerText = msg.content;
1321
  document.getElementById('reply-banner').classList.remove('hidden');
1322
 
1323
  const input = document.getElementById('message-input');
1324
+ input.value = msg.content;
1325
  input.focus();
1326
  }
1327
 
1328
+ async function onDeleteClick() {
1329
  hideContextMenus();
1330
  if (selectedMessageId === null) return;
1331
+
1332
+ await supabaseClient.from('messages').delete().eq('id', selectedMessageId);
1333
+
1334
  cancelActionState();
 
1335
  }
1336
 
1337
  function cancelActionState() {
 
1347
  document.getElementById('mobile-action-modal').classList.add('hidden');
1348
  }
1349
 
1350
+ function closeMobileModal() {
1351
  document.getElementById('mobile-action-modal').classList.add('hidden');
1352
  }
1353
 
 
1354
  document.addEventListener('click', () => {
1355
  document.getElementById('context-menu').classList.add('hidden');
1356
  });
1357
 
 
1358
  function escapeHTML(str) {
1359
  return String(str).replace(/[&<>'"]/g,
1360
  tag => ({
 
1367
  );
1368
  }
1369
 
1370
+ window.onload = async function() {
1371
+ const restored = await restoreSession();
1372
+ if (!restored) {
1373
+ navigate('landing');
1374
+ }
1375
  };
1376
  </script>
1377
  </body>