Spaces:
Running
Running
Update index.html
Browse files- index.html +496 -130
index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Client:Less —
|
| 7 |
<style>
|
| 8 |
:root {
|
| 9 |
--tg-blue: #5682a3;
|
|
@@ -56,6 +56,11 @@
|
|
| 56 |
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
|
| 57 |
z-index: 100;
|
| 58 |
user-select: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
.brand-logo {
|
|
@@ -118,6 +123,7 @@
|
|
| 118 |
flex: 1;
|
| 119 |
position: relative;
|
| 120 |
overflow: hidden;
|
|
|
|
| 121 |
}
|
| 122 |
|
| 123 |
.page {
|
|
@@ -135,6 +141,7 @@
|
|
| 135 |
.page-client-container {
|
| 136 |
padding: 0;
|
| 137 |
overflow: hidden;
|
|
|
|
| 138 |
}
|
| 139 |
|
| 140 |
.content-card {
|
|
@@ -162,7 +169,9 @@
|
|
| 162 |
}
|
| 163 |
|
| 164 |
.btn {
|
| 165 |
-
display: inline-
|
|
|
|
|
|
|
| 166 |
background-color: var(--tg-blue);
|
| 167 |
color: #ffffff;
|
| 168 |
padding: 9px 18px;
|
|
@@ -174,6 +183,7 @@
|
|
| 174 |
transition: background-color 0.15s;
|
| 175 |
font-size: 13px;
|
| 176 |
text-align: center;
|
|
|
|
| 177 |
}
|
| 178 |
|
| 179 |
.btn:hover {
|
|
@@ -185,7 +195,7 @@
|
|
| 185 |
}
|
| 186 |
|
| 187 |
.btn-sm {
|
| 188 |
-
padding: 5px
|
| 189 |
font-size: 12px;
|
| 190 |
}
|
| 191 |
|
|
@@ -199,6 +209,14 @@
|
|
| 199 |
background-color: rgba(86, 130, 162, 0.08);
|
| 200 |
}
|
| 201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
.login-box {
|
| 203 |
max-width: 440px;
|
| 204 |
margin: 30px auto;
|
|
@@ -221,7 +239,7 @@
|
|
| 221 |
font-size: 13px;
|
| 222 |
}
|
| 223 |
|
| 224 |
-
.form-input {
|
| 225 |
width: 100%;
|
| 226 |
padding: 10px 12px;
|
| 227 |
border: 1px solid #ccc;
|
|
@@ -229,9 +247,15 @@
|
|
| 229 |
font-size: 14px;
|
| 230 |
outline: none;
|
| 231 |
transition: border-color 0.15s;
|
|
|
|
| 232 |
}
|
| 233 |
|
| 234 |
-
.form-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
border-color: var(--tg-blue);
|
| 236 |
}
|
| 237 |
|
|
@@ -328,11 +352,12 @@
|
|
| 328 |
height: 100%;
|
| 329 |
width: 100%;
|
| 330 |
background-color: var(--tg-card-bg);
|
|
|
|
| 331 |
}
|
| 332 |
|
| 333 |
.rooms-sidebar {
|
| 334 |
-
width:
|
| 335 |
-
min-width:
|
| 336 |
border-right: 1px solid var(--tg-border);
|
| 337 |
display: flex;
|
| 338 |
flex-direction: column;
|
|
@@ -346,6 +371,7 @@
|
|
| 346 |
display: flex;
|
| 347 |
align-items: center;
|
| 348 |
justify-content: space-between;
|
|
|
|
| 349 |
}
|
| 350 |
|
| 351 |
.user-profile-info {
|
|
@@ -353,6 +379,7 @@
|
|
| 353 |
align-items: center;
|
| 354 |
gap: 10px;
|
| 355 |
overflow: hidden;
|
|
|
|
| 356 |
}
|
| 357 |
|
| 358 |
.user-avatar-sm {
|
|
@@ -367,6 +394,14 @@
|
|
| 367 |
font-weight: bold;
|
| 368 |
font-size: 14px;
|
| 369 |
flex-shrink: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
}
|
| 371 |
|
| 372 |
.user-display-name {
|
|
@@ -377,8 +412,34 @@
|
|
| 377 |
text-overflow: ellipsis;
|
| 378 |
}
|
| 379 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
.search-box {
|
| 381 |
-
padding: 10px;
|
| 382 |
border-bottom: 1px solid #f0f0f0;
|
| 383 |
background: #f7f9fa;
|
| 384 |
}
|
|
@@ -517,6 +578,7 @@
|
|
| 517 |
justify-content: space-between;
|
| 518 |
padding: 0 16px;
|
| 519 |
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
|
|
|
|
| 520 |
}
|
| 521 |
|
| 522 |
.chat-header-title {
|
|
@@ -585,6 +647,7 @@
|
|
| 585 |
display: flex;
|
| 586 |
align-items: center;
|
| 587 |
gap: 10px;
|
|
|
|
| 588 |
}
|
| 589 |
|
| 590 |
.chat-input {
|
|
@@ -603,8 +666,8 @@
|
|
| 603 |
}
|
| 604 |
|
| 605 |
.info-sidebar {
|
| 606 |
-
width:
|
| 607 |
-
min-width:
|
| 608 |
border-left: 1px solid var(--tg-border);
|
| 609 |
background: #ffffff;
|
| 610 |
display: flex;
|
|
@@ -619,6 +682,7 @@
|
|
| 619 |
align-items: center;
|
| 620 |
text-align: center;
|
| 621 |
border-bottom: 1px solid #f0f0f0;
|
|
|
|
| 622 |
}
|
| 623 |
|
| 624 |
.info-avatar {
|
|
@@ -712,6 +776,57 @@
|
|
| 712 |
color: var(--tg-online);
|
| 713 |
}
|
| 714 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
.download-box {
|
| 716 |
display: flex;
|
| 717 |
gap: 20px;
|
|
@@ -751,7 +866,6 @@
|
|
| 751 |
border-radius: 50%;
|
| 752 |
border-top-color: #fff;
|
| 753 |
animation: spin 0.8s linear infinite;
|
| 754 |
-
margin-right: 6px;
|
| 755 |
}
|
| 756 |
|
| 757 |
@keyframes spin {
|
|
@@ -761,26 +875,25 @@
|
|
| 761 |
</head>
|
| 762 |
<body>
|
| 763 |
|
| 764 |
-
<header class="top-navbar">
|
| 765 |
<div class="brand-logo" onclick="switchTab('home')">
|
| 766 |
-
Client:Less <span class="brand-badge">Matrix
|
| 767 |
</div>
|
| 768 |
<ul class="nav-menu">
|
| 769 |
<li class="nav-item"><a class="nav-link active" id="nav-home" onclick="switchTab('home')">Главная</a></li>
|
| 770 |
<li class="nav-item"><a class="nav-link" id="nav-login" onclick="switchTab('login')">Войти</a></li>
|
| 771 |
-
<li class="nav-item"><a class="nav-link" id="nav-servers" onclick="switchTab('servers')">
|
| 772 |
<li class="nav-item"><a class="nav-link" id="nav-download" onclick="switchTab('download')">Скачать приложение</a></li>
|
| 773 |
</ul>
|
| 774 |
</header>
|
| 775 |
|
| 776 |
<div class="page-container">
|
| 777 |
|
| 778 |
-
<!-- Page 1: Home -->
|
| 779 |
<div id="page-home" class="page active">
|
| 780 |
<div class="content-card">
|
| 781 |
<h1 class="content-title">Добро пожаловать в Client:Less</h1>
|
| 782 |
<p class="content-subtitle">
|
| 783 |
-
Автономный веб-клиент для децентрализованной сети Matrix в классическом стиле Telegram Desktop 2015 года. Без
|
| 784 |
</p>
|
| 785 |
<div style="margin-bottom: 20px; display: flex; gap: 10px;">
|
| 786 |
<button class="btn" onclick="switchTab('login')">Открыть веб-клиент</button>
|
|
@@ -789,7 +902,7 @@
|
|
| 789 |
</div>
|
| 790 |
|
| 791 |
<div class="content-card">
|
| 792 |
-
<h2 style="font-size: 18px; color: var(--tg-blue-dark); margin-bottom: 12px;">Прямой доступ к вашим чатам Matrix</h2>
|
| 793 |
<p style="line-height: 1.6; color: #444; margin-bottom: 12px;">
|
| 794 |
Client:Less выполняет реальную синхронизацию данных прямо через стандартный Matrix Client-Server REST API (v3). Вы получаете доступ к вашим настоящим чатам, истории сообщений и списку участников без пр��межуточных прокси.
|
| 795 |
</p>
|
|
@@ -801,7 +914,6 @@
|
|
| 801 |
</div>
|
| 802 |
</div>
|
| 803 |
|
| 804 |
-
<!-- Page 2: Login -->
|
| 805 |
<div id="page-login" class="page">
|
| 806 |
<div class="login-box">
|
| 807 |
<h2 style="font-size: 20px; color: var(--tg-blue-dark); margin-bottom: 8px; text-align: center;">Вход в Matrix</h2>
|
|
@@ -828,16 +940,9 @@
|
|
| 828 |
<button class="btn" id="login-btn-submit" style="width: 100%; text-align: center;" onclick="handleRealLogin()">
|
| 829 |
Подключиться и открыть веб-клиент
|
| 830 |
</button>
|
| 831 |
-
|
| 832 |
-
<div style="text-align: center; margin-top: 18px; border-top: 1px solid #eee; padding-top: 14px;">
|
| 833 |
-
<a style="color: var(--tg-blue); font-size: 12px; cursor: pointer; text-decoration: underline;" onclick="startDemoMode()">
|
| 834 |
-
Запустить демо-интерфейс без авторизации
|
| 835 |
-
</a>
|
| 836 |
-
</div>
|
| 837 |
</div>
|
| 838 |
</div>
|
| 839 |
|
| 840 |
-
<!-- Page 3: Popular Servers (Exact match from screenshot) -->
|
| 841 |
<div id="page-servers" class="page">
|
| 842 |
<div class="content-card servers-card">
|
| 843 |
<h1 class="servers-title">Список самых популярных серверов Matrix</h1>
|
|
@@ -856,24 +961,27 @@
|
|
| 856 |
</tr>
|
| 857 |
</thead>
|
| 858 |
<tbody id="servers-table-body">
|
| 859 |
-
<!-- Populated dynamically via script
|
| 860 |
</tbody>
|
| 861 |
</table>
|
| 862 |
</div>
|
| 863 |
</div>
|
| 864 |
</div>
|
| 865 |
|
| 866 |
-
<!-- Page 4: Telegram 2015 Desktop Web Client -->
|
| 867 |
<div id="page-client" class="page page-client-container">
|
| 868 |
<div class="client-layout">
|
| 869 |
<!-- Column 1: Rooms list & User header -->
|
| 870 |
<div class="rooms-sidebar">
|
| 871 |
<div class="user-profile-header">
|
| 872 |
-
<div class="user-profile-info">
|
| 873 |
<div class="user-avatar-sm" id="client-user-avatar">U</div>
|
| 874 |
<div class="user-display-name" id="client-user-name">Пользователь</div>
|
| 875 |
</div>
|
| 876 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
| 877 |
</div>
|
| 878 |
|
| 879 |
<div class="search-box">
|
|
@@ -897,8 +1005,13 @@
|
|
| 897 |
<div class="chat-header-title" id="active-chat-title">Название чата</div>
|
| 898 |
<div class="chat-header-status" id="active-chat-status">0 участников</div>
|
| 899 |
</div>
|
| 900 |
-
<div
|
| 901 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 902 |
</div>
|
| 903 |
</div>
|
| 904 |
|
|
@@ -919,12 +1032,15 @@
|
|
| 919 |
<div class="info-avatar" id="info-avatar-box">?</div>
|
| 920 |
<div class="info-name" id="info-name-box">Чат не выбран</div>
|
| 921 |
<div class="info-members-count" id="info-count-box">Информационная панель</div>
|
|
|
|
|
|
|
|
|
|
| 922 |
</div>
|
| 923 |
|
| 924 |
<div class="info-section">
|
| 925 |
<div class="info-section-title">О комнате / ��ема</div>
|
| 926 |
<p style="font-size: 13px; color: #444; line-height: 1.4;" id="info-description-box">
|
| 927 |
-
Здесь отображается описание выбр
|
| 928 |
</p>
|
| 929 |
</div>
|
| 930 |
|
|
@@ -938,7 +1054,6 @@
|
|
| 938 |
</div>
|
| 939 |
</div>
|
| 940 |
|
| 941 |
-
<!-- Page 5: Download App -->
|
| 942 |
<div id="page-download" class="page">
|
| 943 |
<div class="content-card">
|
| 944 |
<h1 class="content-title">Скачать Client:Less</h1>
|
|
@@ -968,10 +1083,98 @@
|
|
| 968 |
|
| 969 |
</div>
|
| 970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 971 |
<div class="toast" id="toast-message">Уведомление</div>
|
| 972 |
|
| 973 |
<script>
|
| 974 |
-
// Exact popular servers dataset matching
|
| 975 |
const popularServers = [
|
| 976 |
{
|
| 977 |
name: "matrix.org",
|
|
@@ -1041,7 +1244,6 @@
|
|
| 1041 |
}
|
| 1042 |
];
|
| 1043 |
|
| 1044 |
-
// Global State
|
| 1045 |
let matrixSession = {
|
| 1046 |
homeserver: '',
|
| 1047 |
accessToken: '',
|
|
@@ -1049,9 +1251,8 @@
|
|
| 1049 |
displayName: '',
|
| 1050 |
avatarUrl: '',
|
| 1051 |
nextBatch: '',
|
| 1052 |
-
rooms: {}, // roomId -> { id, name, topic, avatar, messages: [], members: [] }
|
| 1053 |
activeRoomId: null,
|
| 1054 |
-
isDemo: false,
|
| 1055 |
syncTimeoutId: null
|
| 1056 |
};
|
| 1057 |
|
|
@@ -1061,7 +1262,6 @@
|
|
| 1061 |
|
| 1062 |
popularServers.forEach(server => {
|
| 1063 |
const tr = document.createElement('tr');
|
| 1064 |
-
|
| 1065 |
const refsHtml = server.refs.map(r => `<span class="ref-badge">${r}</span>`).join('');
|
| 1066 |
|
| 1067 |
tr.innerHTML = `
|
|
@@ -1086,6 +1286,14 @@
|
|
| 1086 |
document.querySelectorAll('.nav-link').forEach(el => el.classList.remove('active'));
|
| 1087 |
document.querySelectorAll('.page').forEach(el => el.classList.remove('active'));
|
| 1088 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1089 |
const navEl = document.getElementById(`nav-${tabName}`);
|
| 1090 |
if (navEl) navEl.classList.add('active');
|
| 1091 |
|
|
@@ -1120,7 +1328,6 @@
|
|
| 1120 |
return;
|
| 1121 |
}
|
| 1122 |
|
| 1123 |
-
// Normalize homeserver URL
|
| 1124 |
if (!server.startsWith('http://') && !server.startsWith('https://')) {
|
| 1125 |
server = 'https://' + server;
|
| 1126 |
}
|
|
@@ -1150,16 +1357,14 @@
|
|
| 1150 |
matrixSession.accessToken = data.access_token;
|
| 1151 |
matrixSession.userId = data.user_id;
|
| 1152 |
matrixSession.displayName = user;
|
| 1153 |
-
matrixSession.isDemo = false;
|
| 1154 |
matrixSession.rooms = {};
|
|
|
|
| 1155 |
|
| 1156 |
-
|
| 1157 |
-
|
| 1158 |
|
| 1159 |
-
|
| 1160 |
switchTab('client');
|
| 1161 |
-
|
| 1162 |
-
// Start initial Matrix Sync loop
|
| 1163 |
startMatrixSync();
|
| 1164 |
} else {
|
| 1165 |
const errText = data.error || 'Неверный логин или пароль';
|
|
@@ -1174,8 +1379,41 @@
|
|
| 1174 |
}
|
| 1175 |
}
|
| 1176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1177 |
async function startMatrixSync() {
|
| 1178 |
-
if (
|
| 1179 |
|
| 1180 |
const syncStatus = document.getElementById('sync-status-indicator');
|
| 1181 |
if (syncStatus) syncStatus.innerText = 'Синхронизация...';
|
|
@@ -1213,7 +1451,6 @@
|
|
| 1213 |
if (syncStatus) syncStatus.innerText = 'Ошибка соединения';
|
| 1214 |
}
|
| 1215 |
|
| 1216 |
-
// Schedule next long-poll sync
|
| 1217 |
matrixSession.syncTimeoutId = setTimeout(startMatrixSync, 1000);
|
| 1218 |
}
|
| 1219 |
|
|
@@ -1227,6 +1464,7 @@
|
|
| 1227 |
name: roomId,
|
| 1228 |
topic: '',
|
| 1229 |
avatar: '',
|
|
|
|
| 1230 |
messages: [],
|
| 1231 |
members: []
|
| 1232 |
};
|
|
@@ -1235,22 +1473,26 @@
|
|
| 1235 |
|
| 1236 |
const room = matrixSession.rooms[roomId];
|
| 1237 |
|
| 1238 |
-
// Process state events (Room Name, Topic, Avatar)
|
| 1239 |
if (roomData.state && roomData.state.events) {
|
| 1240 |
parseStateEvents(room, roomData.state.events);
|
| 1241 |
}
|
| 1242 |
|
| 1243 |
-
// Process timeline messages
|
| 1244 |
if (roomData.timeline && roomData.timeline.events) {
|
| 1245 |
roomData.timeline.events.forEach(ev => {
|
| 1246 |
-
if (ev.type === 'm.room.name' && ev.content.name) {
|
| 1247 |
room.name = ev.content.name;
|
|
|
|
| 1248 |
}
|
| 1249 |
-
if (ev.type === 'm.room.avatar' && ev.content.url) {
|
| 1250 |
room.avatar = mxcToHttp(ev.content.url);
|
|
|
|
| 1251 |
}
|
| 1252 |
-
if (ev.type === 'm.room.topic' && ev.content.topic) {
|
| 1253 |
room.topic = ev.content.topic;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1254 |
}
|
| 1255 |
|
| 1256 |
if (ev.type === 'm.room.message' && ev.content && ev.content.body) {
|
|
@@ -1274,7 +1516,6 @@
|
|
| 1274 |
}
|
| 1275 |
});
|
| 1276 |
|
| 1277 |
-
// Sort messages by timestamp
|
| 1278 |
room.messages.sort((a, b) => a.ts - b.ts);
|
| 1279 |
}
|
| 1280 |
}
|
|
@@ -1284,20 +1525,24 @@
|
|
| 1284 |
if (matrixSession.activeRoomId && matrixSession.rooms[matrixSession.activeRoomId]) {
|
| 1285 |
const activeRoom = matrixSession.rooms[matrixSession.activeRoomId];
|
| 1286 |
renderMessages(activeRoom);
|
|
|
|
| 1287 |
}
|
| 1288 |
}
|
| 1289 |
}
|
| 1290 |
|
| 1291 |
function parseStateEvents(room, events) {
|
| 1292 |
events.forEach(ev => {
|
| 1293 |
-
if (ev.type === 'm.room.name' && ev.content.name) room.name = ev.content.name;
|
| 1294 |
-
if (ev.type === 'm.room.topic' && ev.content.topic) room.topic = ev.content.topic;
|
| 1295 |
-
if (ev.type === 'm.room.avatar' && ev.content.url) room.avatar = mxcToHttp(ev.content.url);
|
|
|
|
| 1296 |
});
|
| 1297 |
}
|
| 1298 |
|
| 1299 |
function mxcToHttp(mxc) {
|
| 1300 |
-
if (!mxc ||
|
|
|
|
|
|
|
| 1301 |
const parts = mxc.substring(6).split('/');
|
| 1302 |
if (parts.length < 2) return '';
|
| 1303 |
return `${matrixSession.homeserver}/_matrix/media/v3/download/${parts[0]}/${parts[1]}`;
|
|
@@ -1316,26 +1561,6 @@
|
|
| 1316 |
if (!text || !matrixSession.activeRoomId) return;
|
| 1317 |
|
| 1318 |
const roomId = matrixSession.activeRoomId;
|
| 1319 |
-
const room = matrixSession.rooms[roomId];
|
| 1320 |
-
|
| 1321 |
-
if (matrixSession.isDemo) {
|
| 1322 |
-
const now = new Date();
|
| 1323 |
-
const timeStr = `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`;
|
| 1324 |
-
room.messages.push({
|
| 1325 |
-
id: 'demo_' + Date.now(),
|
| 1326 |
-
sender: 'Вы',
|
| 1327 |
-
text: text,
|
| 1328 |
-
time: timeStr,
|
| 1329 |
-
incoming: false,
|
| 1330 |
-
ts: Date.now()
|
| 1331 |
-
});
|
| 1332 |
-
input.value = '';
|
| 1333 |
-
renderMessages(room);
|
| 1334 |
-
renderRoomsList();
|
| 1335 |
-
return;
|
| 1336 |
-
}
|
| 1337 |
-
|
| 1338 |
-
// Real Matrix message send
|
| 1339 |
const txnId = 'm' + Date.now() + '_' + Math.random().toString(36).substring(2, 6);
|
| 1340 |
const sendUrl = `${matrixSession.homeserver}/_matrix/client/v3/rooms/${encodeURIComponent(roomId)}/send/m.room.message/${txnId}`;
|
| 1341 |
|
|
@@ -1363,48 +1588,6 @@
|
|
| 1363 |
}
|
| 1364 |
}
|
| 1365 |
|
| 1366 |
-
function startDemoMode() {
|
| 1367 |
-
matrixSession.isDemo = true;
|
| 1368 |
-
matrixSession.userId = '@demo_user:matrix.org';
|
| 1369 |
-
matrixSession.displayName = 'Demo User';
|
| 1370 |
-
matrixSession.homeserver = 'https://matrix.org';
|
| 1371 |
-
|
| 1372 |
-
matrixSession.rooms = {
|
| 1373 |
-
'!matrix_gen:matrix.org': {
|
| 1374 |
-
id: '!matrix_gen:matrix.org',
|
| 1375 |
-
name: 'Matrix General HQ',
|
| 1376 |
-
topic: 'Главный общественный чат децентрализованной сети Matrix.',
|
| 1377 |
-
avatar: '',
|
| 1378 |
-
messages: [
|
| 1379 |
-
{ id: '1', sender: 'Alice', text: 'Добро пожаловать в Client:Less Matrix!', time: '12:30', incoming: true, ts: 1000 },
|
| 1380 |
-
{ id: '2', sender: 'Bob', text: 'Интерфейс в стиле Telegram 2015 года работает шустро.', time: '12:31', incoming: true, ts: 2000 },
|
| 1381 |
-
{ id: '3', sender: 'Вы', text: 'Проверяем реальный веб-клиент!', time: '12:35', incoming: false, ts: 3000 }
|
| 1382 |
-
],
|
| 1383 |
-
members: [{ name: 'Alice' }, { name: 'Bob' }, { name: 'Demo User' }]
|
| 1384 |
-
},
|
| 1385 |
-
'!dev_room:matrix.org': {
|
| 1386 |
-
id: '!dev_room:matrix.org',
|
| 1387 |
-
name: 'Разработка Client:Less',
|
| 1388 |
-
topic: 'Обсуждение релизов и интеграции REST API.',
|
| 1389 |
-
avatar: '',
|
| 1390 |
-
messages: [
|
| 1391 |
-
{ id: '4', sender: 'Lead Dev', text: 'Полностью удалены мок-новости, подгружаем реальные данные.', time: '10:00', incoming: true, ts: 1000 }
|
| 1392 |
-
],
|
| 1393 |
-
members: [{ name: 'Lead Dev' }]
|
| 1394 |
-
}
|
| 1395 |
-
};
|
| 1396 |
-
|
| 1397 |
-
updateUserProfileUI();
|
| 1398 |
-
switchTab('client');
|
| 1399 |
-
selectRoom('!matrix_gen:matrix.org');
|
| 1400 |
-
showToast('Вы вошли в демо-режим. Для подключения к своим реальным чатам используйте форму Входа.');
|
| 1401 |
-
}
|
| 1402 |
-
|
| 1403 |
-
function updateUserProfileUI() {
|
| 1404 |
-
document.getElementById('client-user-name').innerText = matrixSession.displayName || matrixSession.userId || 'Пользователь';
|
| 1405 |
-
document.getElementById('client-user-avatar').innerText = (matrixSession.displayName || 'U')[0].toUpperCase();
|
| 1406 |
-
}
|
| 1407 |
-
|
| 1408 |
function handleLogout() {
|
| 1409 |
if (matrixSession.syncTimeoutId) clearTimeout(matrixSession.syncTimeoutId);
|
| 1410 |
matrixSession.accessToken = '';
|
|
@@ -1424,7 +1607,7 @@
|
|
| 1424 |
if (roomArray.length === 0) {
|
| 1425 |
container.innerHTML = `
|
| 1426 |
<div style="padding: 20px; text-align: center; color: var(--tg-subtext); font-size: 13px;">
|
| 1427 |
-
|
| 1428 |
</div>
|
| 1429 |
`;
|
| 1430 |
return;
|
|
@@ -1482,11 +1665,16 @@
|
|
| 1482 |
document.getElementById('chat-empty-state').style.display = 'none';
|
| 1483 |
document.getElementById('chat-active-state').style.display = 'flex';
|
| 1484 |
|
| 1485 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1486 |
document.getElementById('active-chat-title').innerText = room.name;
|
| 1487 |
document.getElementById('active-chat-status').innerText = room.id;
|
| 1488 |
|
| 1489 |
-
// Info panel
|
| 1490 |
const initial = room.name ? room.name[0].toUpperCase() : '#';
|
| 1491 |
const avatarBox = document.getElementById('info-avatar-box');
|
| 1492 |
|
|
@@ -1500,20 +1688,24 @@
|
|
| 1500 |
document.getElementById('info-count-box').innerText = room.id;
|
| 1501 |
document.getElementById('info-description-box').innerText = room.topic || 'Описание отсутствует.';
|
| 1502 |
|
| 1503 |
-
|
| 1504 |
-
|
| 1505 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1506 |
}
|
| 1507 |
|
| 1508 |
async function fetchRoomMembersIfNeeded(room) {
|
| 1509 |
const memberList = document.getElementById('info-member-list');
|
| 1510 |
memberList.innerHTML = `<li style="font-size:12px; color:var(--tg-subtext);">Загрузка участников...</li>`;
|
| 1511 |
|
| 1512 |
-
if (matrixSession.isDemo) {
|
| 1513 |
-
renderMembersList(room.members || []);
|
| 1514 |
-
return;
|
| 1515 |
-
}
|
| 1516 |
-
|
| 1517 |
try {
|
| 1518 |
const res = await fetch(`${matrixSession.homeserver}/_matrix/client/v3/rooms/${encodeURIComponent(room.id)}/joined_members`, {
|
| 1519 |
headers: { 'Authorization': `Bearer ${matrixSession.accessToken}` }
|
|
@@ -1601,6 +1793,180 @@
|
|
| 1601 |
container.scrollTop = container.scrollHeight;
|
| 1602 |
}
|
| 1603 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1604 |
function handleKeyPress(e) {
|
| 1605 |
if (e.key === 'Enter') {
|
| 1606 |
sendMessage();
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Client:Less — Matrix Web Client</title>
|
| 7 |
<style>
|
| 8 |
:root {
|
| 9 |
--tg-blue: #5682a3;
|
|
|
|
| 56 |
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
|
| 57 |
z-index: 100;
|
| 58 |
user-select: none;
|
| 59 |
+
flex-shrink: 0;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
.top-navbar.hidden {
|
| 63 |
+
display: none !important;
|
| 64 |
}
|
| 65 |
|
| 66 |
.brand-logo {
|
|
|
|
| 123 |
flex: 1;
|
| 124 |
position: relative;
|
| 125 |
overflow: hidden;
|
| 126 |
+
height: 100%;
|
| 127 |
}
|
| 128 |
|
| 129 |
.page {
|
|
|
|
| 141 |
.page-client-container {
|
| 142 |
padding: 0;
|
| 143 |
overflow: hidden;
|
| 144 |
+
height: 100%;
|
| 145 |
}
|
| 146 |
|
| 147 |
.content-card {
|
|
|
|
| 169 |
}
|
| 170 |
|
| 171 |
.btn {
|
| 172 |
+
display: inline-flex;
|
| 173 |
+
align-items: center;
|
| 174 |
+
justify-content: center;
|
| 175 |
background-color: var(--tg-blue);
|
| 176 |
color: #ffffff;
|
| 177 |
padding: 9px 18px;
|
|
|
|
| 183 |
transition: background-color 0.15s;
|
| 184 |
font-size: 13px;
|
| 185 |
text-align: center;
|
| 186 |
+
gap: 6px;
|
| 187 |
}
|
| 188 |
|
| 189 |
.btn:hover {
|
|
|
|
| 195 |
}
|
| 196 |
|
| 197 |
.btn-sm {
|
| 198 |
+
padding: 5px 10px;
|
| 199 |
font-size: 12px;
|
| 200 |
}
|
| 201 |
|
|
|
|
| 209 |
background-color: rgba(86, 130, 162, 0.08);
|
| 210 |
}
|
| 211 |
|
| 212 |
+
.btn-danger {
|
| 213 |
+
background-color: #d9534f;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
.btn-danger:hover {
|
| 217 |
+
background-color: #c9302c;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
.login-box {
|
| 221 |
max-width: 440px;
|
| 222 |
margin: 30px auto;
|
|
|
|
| 239 |
font-size: 13px;
|
| 240 |
}
|
| 241 |
|
| 242 |
+
.form-input, .form-select, .form-textarea {
|
| 243 |
width: 100%;
|
| 244 |
padding: 10px 12px;
|
| 245 |
border: 1px solid #ccc;
|
|
|
|
| 247 |
font-size: 14px;
|
| 248 |
outline: none;
|
| 249 |
transition: border-color 0.15s;
|
| 250 |
+
background-color: #fff;
|
| 251 |
}
|
| 252 |
|
| 253 |
+
.form-textarea {
|
| 254 |
+
resize: vertical;
|
| 255 |
+
min-height: 70px;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
.form-input:focus, .form-select:focus, .form-textarea:focus {
|
| 259 |
border-color: var(--tg-blue);
|
| 260 |
}
|
| 261 |
|
|
|
|
| 352 |
height: 100%;
|
| 353 |
width: 100%;
|
| 354 |
background-color: var(--tg-card-bg);
|
| 355 |
+
overflow: hidden;
|
| 356 |
}
|
| 357 |
|
| 358 |
.rooms-sidebar {
|
| 359 |
+
width: 310px;
|
| 360 |
+
min-width: 310px;
|
| 361 |
border-right: 1px solid var(--tg-border);
|
| 362 |
display: flex;
|
| 363 |
flex-direction: column;
|
|
|
|
| 371 |
display: flex;
|
| 372 |
align-items: center;
|
| 373 |
justify-content: space-between;
|
| 374 |
+
height: 50px;
|
| 375 |
}
|
| 376 |
|
| 377 |
.user-profile-info {
|
|
|
|
| 379 |
align-items: center;
|
| 380 |
gap: 10px;
|
| 381 |
overflow: hidden;
|
| 382 |
+
cursor: pointer;
|
| 383 |
}
|
| 384 |
|
| 385 |
.user-avatar-sm {
|
|
|
|
| 394 |
font-weight: bold;
|
| 395 |
font-size: 14px;
|
| 396 |
flex-shrink: 0;
|
| 397 |
+
overflow: hidden;
|
| 398 |
+
object-fit: cover;
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
.user-avatar-sm img {
|
| 402 |
+
width: 100%;
|
| 403 |
+
height: 100%;
|
| 404 |
+
object-fit: cover;
|
| 405 |
}
|
| 406 |
|
| 407 |
.user-display-name {
|
|
|
|
| 412 |
text-overflow: ellipsis;
|
| 413 |
}
|
| 414 |
|
| 415 |
+
.sidebar-actions {
|
| 416 |
+
display: flex;
|
| 417 |
+
align-items: center;
|
| 418 |
+
gap: 6px;
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
.icon-btn {
|
| 422 |
+
background: transparent;
|
| 423 |
+
border: none;
|
| 424 |
+
color: rgba(255, 255, 255, 0.85);
|
| 425 |
+
width: 30px;
|
| 426 |
+
height: 30px;
|
| 427 |
+
border-radius: 50%;
|
| 428 |
+
display: flex;
|
| 429 |
+
align-items: center;
|
| 430 |
+
justify-content: center;
|
| 431 |
+
cursor: pointer;
|
| 432 |
+
transition: background 0.15s;
|
| 433 |
+
font-size: 16px;
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
.icon-btn:hover {
|
| 437 |
+
background: rgba(255, 255, 255, 0.15);
|
| 438 |
+
color: #ffffff;
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
.search-box {
|
| 442 |
+
padding: 8px 10px;
|
| 443 |
border-bottom: 1px solid #f0f0f0;
|
| 444 |
background: #f7f9fa;
|
| 445 |
}
|
|
|
|
| 578 |
justify-content: space-between;
|
| 579 |
padding: 0 16px;
|
| 580 |
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
|
| 581 |
+
flex-shrink: 0;
|
| 582 |
}
|
| 583 |
|
| 584 |
.chat-header-title {
|
|
|
|
| 647 |
display: flex;
|
| 648 |
align-items: center;
|
| 649 |
gap: 10px;
|
| 650 |
+
flex-shrink: 0;
|
| 651 |
}
|
| 652 |
|
| 653 |
.chat-input {
|
|
|
|
| 666 |
}
|
| 667 |
|
| 668 |
.info-sidebar {
|
| 669 |
+
width: 280px;
|
| 670 |
+
min-width: 280px;
|
| 671 |
border-left: 1px solid var(--tg-border);
|
| 672 |
background: #ffffff;
|
| 673 |
display: flex;
|
|
|
|
| 682 |
align-items: center;
|
| 683 |
text-align: center;
|
| 684 |
border-bottom: 1px solid #f0f0f0;
|
| 685 |
+
position: relative;
|
| 686 |
}
|
| 687 |
|
| 688 |
.info-avatar {
|
|
|
|
| 776 |
color: var(--tg-online);
|
| 777 |
}
|
| 778 |
|
| 779 |
+
/* Modal windows */
|
| 780 |
+
.modal-overlay {
|
| 781 |
+
position: fixed;
|
| 782 |
+
top: 0;
|
| 783 |
+
left: 0;
|
| 784 |
+
right: 0;
|
| 785 |
+
bottom: 0;
|
| 786 |
+
background: rgba(0, 0, 0, 0.5);
|
| 787 |
+
display: none;
|
| 788 |
+
align-items: center;
|
| 789 |
+
justify-content: center;
|
| 790 |
+
z-index: 1000;
|
| 791 |
+
}
|
| 792 |
+
|
| 793 |
+
.modal-overlay.active {
|
| 794 |
+
display: flex;
|
| 795 |
+
}
|
| 796 |
+
|
| 797 |
+
.modal-card {
|
| 798 |
+
background: #ffffff;
|
| 799 |
+
width: 440px;
|
| 800 |
+
max-width: 90%;
|
| 801 |
+
border-radius: 6px;
|
| 802 |
+
box-shadow: 0 4px 16px rgba(0,0,0,0.2);
|
| 803 |
+
overflow: hidden;
|
| 804 |
+
}
|
| 805 |
+
|
| 806 |
+
.modal-header {
|
| 807 |
+
background: var(--tg-blue);
|
| 808 |
+
color: #ffffff;
|
| 809 |
+
padding: 14px 18px;
|
| 810 |
+
font-weight: 600;
|
| 811 |
+
font-size: 16px;
|
| 812 |
+
display: flex;
|
| 813 |
+
justify-content: space-between;
|
| 814 |
+
align-items: center;
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
.modal-body {
|
| 818 |
+
padding: 20px;
|
| 819 |
+
}
|
| 820 |
+
|
| 821 |
+
.modal-footer {
|
| 822 |
+
padding: 12px 20px;
|
| 823 |
+
background: #f7f9fa;
|
| 824 |
+
border-top: 1px solid #eef2f5;
|
| 825 |
+
display: flex;
|
| 826 |
+
justify-content: flex-end;
|
| 827 |
+
gap: 10px;
|
| 828 |
+
}
|
| 829 |
+
|
| 830 |
.download-box {
|
| 831 |
display: flex;
|
| 832 |
gap: 20px;
|
|
|
|
| 866 |
border-radius: 50%;
|
| 867 |
border-top-color: #fff;
|
| 868 |
animation: spin 0.8s linear infinite;
|
|
|
|
| 869 |
}
|
| 870 |
|
| 871 |
@keyframes spin {
|
|
|
|
| 875 |
</head>
|
| 876 |
<body>
|
| 877 |
|
| 878 |
+
<header class="top-navbar" id="site-top-navbar">
|
| 879 |
<div class="brand-logo" onclick="switchTab('home')">
|
| 880 |
+
Client:Less <span class="brand-badge">Matrix REST</span>
|
| 881 |
</div>
|
| 882 |
<ul class="nav-menu">
|
| 883 |
<li class="nav-item"><a class="nav-link active" id="nav-home" onclick="switchTab('home')">Главная</a></li>
|
| 884 |
<li class="nav-item"><a class="nav-link" id="nav-login" onclick="switchTab('login')">Войти</a></li>
|
| 885 |
+
<li class="nav-item"><a class="nav-link" id="nav-servers" onclick="switchTab('servers')">Список популярных серверов</a></li>
|
| 886 |
<li class="nav-item"><a class="nav-link" id="nav-download" onclick="switchTab('download')">Скачать приложение</a></li>
|
| 887 |
</ul>
|
| 888 |
</header>
|
| 889 |
|
| 890 |
<div class="page-container">
|
| 891 |
|
|
|
|
| 892 |
<div id="page-home" class="page active">
|
| 893 |
<div class="content-card">
|
| 894 |
<h1 class="content-title">Добро пожаловать в Client:Less</h1>
|
| 895 |
<p class="content-subtitle">
|
| 896 |
+
Автономный веб-клиент для децентрализованной сети Matrix в классическом стиле Telegram Desktop 2015 года. Без CDN, тяжелых фреймворков и фейковых данных.
|
| 897 |
</p>
|
| 898 |
<div style="margin-bottom: 20px; display: flex; gap: 10px;">
|
| 899 |
<button class="btn" onclick="switchTab('login')">Открыть веб-клиент</button>
|
|
|
|
| 902 |
</div>
|
| 903 |
|
| 904 |
<div class="content-card">
|
| 905 |
+
<h2 style="font-size: 18px; color: var(--tg-blue-dark); margin-bottom: 12px;">Прямой доступ к вашим настоящим чатам Matrix</h2>
|
| 906 |
<p style="line-height: 1.6; color: #444; margin-bottom: 12px;">
|
| 907 |
Client:Less выполняет реальную синхронизацию данных прямо через стандартный Matrix Client-Server REST API (v3). Вы получаете доступ к вашим настоящим чатам, истории сообщений и списку участников без пр��межуточных прокси.
|
| 908 |
</p>
|
|
|
|
| 914 |
</div>
|
| 915 |
</div>
|
| 916 |
|
|
|
|
| 917 |
<div id="page-login" class="page">
|
| 918 |
<div class="login-box">
|
| 919 |
<h2 style="font-size: 20px; color: var(--tg-blue-dark); margin-bottom: 8px; text-align: center;">Вход в Matrix</h2>
|
|
|
|
| 940 |
<button class="btn" id="login-btn-submit" style="width: 100%; text-align: center;" onclick="handleRealLogin()">
|
| 941 |
Подключиться и открыть веб-клиент
|
| 942 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 943 |
</div>
|
| 944 |
</div>
|
| 945 |
|
|
|
|
| 946 |
<div id="page-servers" class="page">
|
| 947 |
<div class="content-card servers-card">
|
| 948 |
<h1 class="servers-title">Список самых популярных серверов Matrix</h1>
|
|
|
|
| 961 |
</tr>
|
| 962 |
</thead>
|
| 963 |
<tbody id="servers-table-body">
|
| 964 |
+
<!-- Populated dynamically via script -->
|
| 965 |
</tbody>
|
| 966 |
</table>
|
| 967 |
</div>
|
| 968 |
</div>
|
| 969 |
</div>
|
| 970 |
|
|
|
|
| 971 |
<div id="page-client" class="page page-client-container">
|
| 972 |
<div class="client-layout">
|
| 973 |
<!-- Column 1: Rooms list & User header -->
|
| 974 |
<div class="rooms-sidebar">
|
| 975 |
<div class="user-profile-header">
|
| 976 |
+
<div class="user-profile-info" onclick="openProfileModal()">
|
| 977 |
<div class="user-avatar-sm" id="client-user-avatar">U</div>
|
| 978 |
<div class="user-display-name" id="client-user-name">Пользователь</div>
|
| 979 |
</div>
|
| 980 |
+
<div class="sidebar-actions">
|
| 981 |
+
<button class="icon-btn" title="Создать комнату" onclick="openCreateRoomModal()">✚</button>
|
| 982 |
+
<button class="icon-btn" title="Настройки профиля" onclick="openProfileModal()">⚙</button>
|
| 983 |
+
<button class="icon-btn" title="Выйти из аккаунта" onclick="handleLogout()">✖</button>
|
| 984 |
+
</div>
|
| 985 |
</div>
|
| 986 |
|
| 987 |
<div class="search-box">
|
|
|
|
| 1005 |
<div class="chat-header-title" id="active-chat-title">Название чата</div>
|
| 1006 |
<div class="chat-header-status" id="active-chat-status">0 участников</div>
|
| 1007 |
</div>
|
| 1008 |
+
<div style="display: flex; align-items: center; gap: 10px;">
|
| 1009 |
+
<button class="btn btn-sm btn-outline" id="btn-edit-room-top" style="display: none;" onclick="openEditRoomModal()">
|
| 1010 |
+
✎ Настройки комнаты
|
| 1011 |
+
</button>
|
| 1012 |
+
<div id="sync-status-indicator" style="font-size: 11px; color: var(--tg-subtext);">
|
| 1013 |
+
Matrix REST Sync
|
| 1014 |
+
</div>
|
| 1015 |
</div>
|
| 1016 |
</div>
|
| 1017 |
|
|
|
|
| 1032 |
<div class="info-avatar" id="info-avatar-box">?</div>
|
| 1033 |
<div class="info-name" id="info-name-box">Чат не выбран</div>
|
| 1034 |
<div class="info-members-count" id="info-count-box">Информационная панель</div>
|
| 1035 |
+
<button class="btn btn-sm btn-outline" id="btn-edit-room-side" style="margin-top: 10px; display: none;" onclick="openEditRoomModal()">
|
| 1036 |
+
✎ Редактировать комнату
|
| 1037 |
+
</button>
|
| 1038 |
</div>
|
| 1039 |
|
| 1040 |
<div class="info-section">
|
| 1041 |
<div class="info-section-title">О комнате / ��ема</div>
|
| 1042 |
<p style="font-size: 13px; color: #444; line-height: 1.4;" id="info-description-box">
|
| 1043 |
+
Здесь отображается описание выбранного чата и список участников.
|
| 1044 |
</p>
|
| 1045 |
</div>
|
| 1046 |
|
|
|
|
| 1054 |
</div>
|
| 1055 |
</div>
|
| 1056 |
|
|
|
|
| 1057 |
<div id="page-download" class="page">
|
| 1058 |
<div class="content-card">
|
| 1059 |
<h1 class="content-title">Скачать Client:Less</h1>
|
|
|
|
| 1083 |
|
| 1084 |
</div>
|
| 1085 |
|
| 1086 |
+
<!-- Modal: User Profile Settings -->
|
| 1087 |
+
<div class="modal-overlay" id="modal-profile">
|
| 1088 |
+
<div class="modal-card">
|
| 1089 |
+
<div class="modal-header">
|
| 1090 |
+
<span>Настройки профиля</span>
|
| 1091 |
+
<span style="cursor: pointer;" onclick="closeModal('modal-profile')">✖</span>
|
| 1092 |
+
</div>
|
| 1093 |
+
<div class="modal-body">
|
| 1094 |
+
<div class="form-group">
|
| 1095 |
+
<label>Matrix ID</label>
|
| 1096 |
+
<input type="text" id="profile-userid-input" class="form-input" disabled readonly style="background:#eee;">
|
| 1097 |
+
</div>
|
| 1098 |
+
<div class="form-group">
|
| 1099 |
+
<label>Отображаемое имя (Display Name)</label>
|
| 1100 |
+
<input type="text" id="profile-name-input" class="form-input" placeholder="Введите имя">
|
| 1101 |
+
</div>
|
| 1102 |
+
<div class="form-group">
|
| 1103 |
+
<label>URL аватарки (MXC или HTTP URL)</label>
|
| 1104 |
+
<input type="text" id="profile-avatar-input" class="form-input" placeholder="mxc://... или https://...">
|
| 1105 |
+
<div class="form-hint">Укажите ссылку на изображение для вашего профиля Matrix</div>
|
| 1106 |
+
</div>
|
| 1107 |
+
</div>
|
| 1108 |
+
<div class="modal-footer">
|
| 1109 |
+
<button class="btn btn-outline" onclick="closeModal('modal-profile')">Отмена</button>
|
| 1110 |
+
<button class="btn" onclick="saveProfileSettings()">Сохранить</button>
|
| 1111 |
+
</div>
|
| 1112 |
+
</div>
|
| 1113 |
+
</div>
|
| 1114 |
+
|
| 1115 |
+
<!-- Modal: Create New Room -->
|
| 1116 |
+
<div class="modal-overlay" id="modal-create-room">
|
| 1117 |
+
<div class="modal-card">
|
| 1118 |
+
<div class="modal-header">
|
| 1119 |
+
<span>Создать новую комнату</span>
|
| 1120 |
+
<span style="cursor: pointer;" onclick="closeModal('modal-create-room')">✖</span>
|
| 1121 |
+
</div>
|
| 1122 |
+
<div class="modal-body">
|
| 1123 |
+
<div class="form-group">
|
| 1124 |
+
<label>Название комнаты *</label>
|
| 1125 |
+
<input type="text" id="newroom-name-input" class="form-input" placeholder="Например: Обсуждение проекта">
|
| 1126 |
+
</div>
|
| 1127 |
+
<div class="form-group">
|
| 1128 |
+
<label>Тема / Описание (Topic)</label>
|
| 1129 |
+
<textarea id="newroom-topic-input" class="form-textarea" placeholder="Краткое описание темы общения"></textarea>
|
| 1130 |
+
</div>
|
| 1131 |
+
<div class="form-group">
|
| 1132 |
+
<label>Тип комнаты</label>
|
| 1133 |
+
<select id="newroom-preset-select" class="form-select">
|
| 1134 |
+
<option value="private_chat">Приватная комната (по приглашениям)</option>
|
| 1135 |
+
<option value="public_chat">Публичная комната</option>
|
| 1136 |
+
</select>
|
| 1137 |
+
</div>
|
| 1138 |
+
</div>
|
| 1139 |
+
<div class="modal-footer">
|
| 1140 |
+
<button class="btn btn-outline" onclick="closeModal('modal-create-room')">Отмена</button>
|
| 1141 |
+
<button class="btn" onclick="submitCreateRoom()">Создать</button>
|
| 1142 |
+
</div>
|
| 1143 |
+
</div>
|
| 1144 |
+
</div>
|
| 1145 |
+
|
| 1146 |
+
<!-- Modal: Edit Room Settings -->
|
| 1147 |
+
<div class="modal-overlay" id="modal-edit-room">
|
| 1148 |
+
<div class="modal-card">
|
| 1149 |
+
<div class="modal-header">
|
| 1150 |
+
<span>Редактирование комнаты</span>
|
| 1151 |
+
<span style="cursor: pointer;" onclick="closeModal('modal-edit-room')">✖</span>
|
| 1152 |
+
</div>
|
| 1153 |
+
<div class="modal-body">
|
| 1154 |
+
<div class="form-group">
|
| 1155 |
+
<label>Название комнаты</label>
|
| 1156 |
+
<input type="text" id="editroom-name-input" class="form-input" placeholder="Название комнаты">
|
| 1157 |
+
</div>
|
| 1158 |
+
<div class="form-group">
|
| 1159 |
+
<label>Тема комнаты (Topic)</label>
|
| 1160 |
+
<textarea id="editroom-topic-input" class="form-textarea" placeholder="Описание комнаты"></textarea>
|
| 1161 |
+
</div>
|
| 1162 |
+
<div class="form-group">
|
| 1163 |
+
<label>URL Аватарки комнаты (MXC или HTTP)</label>
|
| 1164 |
+
<input type="text" id="editroom-avatar-input" class="form-input" placeholder="mxc://... или https://...">
|
| 1165 |
+
</div>
|
| 1166 |
+
</div>
|
| 1167 |
+
<div class="modal-footer">
|
| 1168 |
+
<button class="btn btn-outline" onclick="closeModal('modal-edit-room')">Отмена</button>
|
| 1169 |
+
<button class="btn" onclick="saveRoomSettings()">Сохранить изменения</button>
|
| 1170 |
+
</div>
|
| 1171 |
+
</div>
|
| 1172 |
+
</div>
|
| 1173 |
+
|
| 1174 |
<div class="toast" id="toast-message">Уведомление</div>
|
| 1175 |
|
| 1176 |
<script>
|
| 1177 |
+
// Exact popular servers dataset matching screenshot
|
| 1178 |
const popularServers = [
|
| 1179 |
{
|
| 1180 |
name: "matrix.org",
|
|
|
|
| 1244 |
}
|
| 1245 |
];
|
| 1246 |
|
|
|
|
| 1247 |
let matrixSession = {
|
| 1248 |
homeserver: '',
|
| 1249 |
accessToken: '',
|
|
|
|
| 1251 |
displayName: '',
|
| 1252 |
avatarUrl: '',
|
| 1253 |
nextBatch: '',
|
| 1254 |
+
rooms: {}, // roomId -> { id, name, topic, avatar, creator, messages: [], members: [] }
|
| 1255 |
activeRoomId: null,
|
|
|
|
| 1256 |
syncTimeoutId: null
|
| 1257 |
};
|
| 1258 |
|
|
|
|
| 1262 |
|
| 1263 |
popularServers.forEach(server => {
|
| 1264 |
const tr = document.createElement('tr');
|
|
|
|
| 1265 |
const refsHtml = server.refs.map(r => `<span class="ref-badge">${r}</span>`).join('');
|
| 1266 |
|
| 1267 |
tr.innerHTML = `
|
|
|
|
| 1286 |
document.querySelectorAll('.nav-link').forEach(el => el.classList.remove('active'));
|
| 1287 |
document.querySelectorAll('.page').forEach(el => el.classList.remove('active'));
|
| 1288 |
|
| 1289 |
+
const topNavbar = document.getElementById('site-top-navbar');
|
| 1290 |
+
|
| 1291 |
+
if (tabName === 'client') {
|
| 1292 |
+
topNavbar.classList.add('hidden');
|
| 1293 |
+
} else {
|
| 1294 |
+
topNavbar.classList.remove('hidden');
|
| 1295 |
+
}
|
| 1296 |
+
|
| 1297 |
const navEl = document.getElementById(`nav-${tabName}`);
|
| 1298 |
if (navEl) navEl.classList.add('active');
|
| 1299 |
|
|
|
|
| 1328 |
return;
|
| 1329 |
}
|
| 1330 |
|
|
|
|
| 1331 |
if (!server.startsWith('http://') && !server.startsWith('https://')) {
|
| 1332 |
server = 'https://' + server;
|
| 1333 |
}
|
|
|
|
| 1357 |
matrixSession.accessToken = data.access_token;
|
| 1358 |
matrixSession.userId = data.user_id;
|
| 1359 |
matrixSession.displayName = user;
|
|
|
|
| 1360 |
matrixSession.rooms = {};
|
| 1361 |
+
matrixSession.nextBatch = '';
|
| 1362 |
|
| 1363 |
+
// Fetch user profile details
|
| 1364 |
+
fetchUserProfile();
|
| 1365 |
|
| 1366 |
+
showToast('Авторизация успешна! Подгружаем ваши реальные чаты...');
|
| 1367 |
switchTab('client');
|
|
|
|
|
|
|
| 1368 |
startMatrixSync();
|
| 1369 |
} else {
|
| 1370 |
const errText = data.error || 'Неверный логин или пароль';
|
|
|
|
| 1379 |
}
|
| 1380 |
}
|
| 1381 |
|
| 1382 |
+
async function fetchUserProfile() {
|
| 1383 |
+
if (!matrixSession.accessToken || !matrixSession.userId) return;
|
| 1384 |
+
|
| 1385 |
+
try {
|
| 1386 |
+
const res = await fetch(`${matrixSession.homeserver}/_matrix/client/v3/profile/${encodeURIComponent(matrixSession.userId)}`, {
|
| 1387 |
+
headers: { 'Authorization': `Bearer ${matrixSession.accessToken}` }
|
| 1388 |
+
});
|
| 1389 |
+
|
| 1390 |
+
if (res.ok) {
|
| 1391 |
+
const data = await res.json();
|
| 1392 |
+
if (data.displayname) matrixSession.displayName = data.displayname;
|
| 1393 |
+
if (data.avatar_url) matrixSession.avatarUrl = mxcToHttp(data.avatar_url);
|
| 1394 |
+
}
|
| 1395 |
+
} catch (e) {
|
| 1396 |
+
console.warn('Failed to fetch user profile details:', e);
|
| 1397 |
+
}
|
| 1398 |
+
updateUserProfileUI();
|
| 1399 |
+
}
|
| 1400 |
+
|
| 1401 |
+
function updateUserProfileUI() {
|
| 1402 |
+
const displayName = matrixSession.displayName || matrixSession.userId || 'Пользователь';
|
| 1403 |
+
document.getElementById('client-user-name').innerText = displayName;
|
| 1404 |
+
|
| 1405 |
+
const avatarEl = document.getElementById('client-user-avatar');
|
| 1406 |
+
const initial = displayName[0] ? displayName[0].toUpperCase() : 'U';
|
| 1407 |
+
|
| 1408 |
+
if (matrixSession.avatarUrl) {
|
| 1409 |
+
avatarEl.innerHTML = `<img src="${matrixSession.avatarUrl}" alt="Avatar" onerror="this.parentNode.innerText='${initial}'">`;
|
| 1410 |
+
} else {
|
| 1411 |
+
avatarEl.innerText = initial;
|
| 1412 |
+
}
|
| 1413 |
+
}
|
| 1414 |
+
|
| 1415 |
async function startMatrixSync() {
|
| 1416 |
+
if (!matrixSession.accessToken) return;
|
| 1417 |
|
| 1418 |
const syncStatus = document.getElementById('sync-status-indicator');
|
| 1419 |
if (syncStatus) syncStatus.innerText = 'Синхронизация...';
|
|
|
|
| 1451 |
if (syncStatus) syncStatus.innerText = 'Ошибка соединения';
|
| 1452 |
}
|
| 1453 |
|
|
|
|
| 1454 |
matrixSession.syncTimeoutId = setTimeout(startMatrixSync, 1000);
|
| 1455 |
}
|
| 1456 |
|
|
|
|
| 1464 |
name: roomId,
|
| 1465 |
topic: '',
|
| 1466 |
avatar: '',
|
| 1467 |
+
creator: '',
|
| 1468 |
messages: [],
|
| 1469 |
members: []
|
| 1470 |
};
|
|
|
|
| 1473 |
|
| 1474 |
const room = matrixSession.rooms[roomId];
|
| 1475 |
|
|
|
|
| 1476 |
if (roomData.state && roomData.state.events) {
|
| 1477 |
parseStateEvents(room, roomData.state.events);
|
| 1478 |
}
|
| 1479 |
|
|
|
|
| 1480 |
if (roomData.timeline && roomData.timeline.events) {
|
| 1481 |
roomData.timeline.events.forEach(ev => {
|
| 1482 |
+
if (ev.type === 'm.room.name' && ev.content && ev.content.name) {
|
| 1483 |
room.name = ev.content.name;
|
| 1484 |
+
updated = true;
|
| 1485 |
}
|
| 1486 |
+
if (ev.type === 'm.room.avatar' && ev.content && ev.content.url) {
|
| 1487 |
room.avatar = mxcToHttp(ev.content.url);
|
| 1488 |
+
updated = true;
|
| 1489 |
}
|
| 1490 |
+
if (ev.type === 'm.room.topic' && ev.content && ev.content.topic) {
|
| 1491 |
room.topic = ev.content.topic;
|
| 1492 |
+
updated = true;
|
| 1493 |
+
}
|
| 1494 |
+
if (ev.type === 'm.room.create' && ev.content && ev.content.creator) {
|
| 1495 |
+
room.creator = ev.content.creator;
|
| 1496 |
}
|
| 1497 |
|
| 1498 |
if (ev.type === 'm.room.message' && ev.content && ev.content.body) {
|
|
|
|
| 1516 |
}
|
| 1517 |
});
|
| 1518 |
|
|
|
|
| 1519 |
room.messages.sort((a, b) => a.ts - b.ts);
|
| 1520 |
}
|
| 1521 |
}
|
|
|
|
| 1525 |
if (matrixSession.activeRoomId && matrixSession.rooms[matrixSession.activeRoomId]) {
|
| 1526 |
const activeRoom = matrixSession.rooms[matrixSession.activeRoomId];
|
| 1527 |
renderMessages(activeRoom);
|
| 1528 |
+
updateRoomHeaderAndSide(activeRoom);
|
| 1529 |
}
|
| 1530 |
}
|
| 1531 |
}
|
| 1532 |
|
| 1533 |
function parseStateEvents(room, events) {
|
| 1534 |
events.forEach(ev => {
|
| 1535 |
+
if (ev.type === 'm.room.name' && ev.content && ev.content.name) room.name = ev.content.name;
|
| 1536 |
+
if (ev.type === 'm.room.topic' && ev.content && ev.content.topic) room.topic = ev.content.topic;
|
| 1537 |
+
if (ev.type === 'm.room.avatar' && ev.content && ev.content.url) room.avatar = mxcToHttp(ev.content.url);
|
| 1538 |
+
if (ev.type === 'm.room.create' && ev.content && ev.content.creator) room.creator = ev.content.creator;
|
| 1539 |
});
|
| 1540 |
}
|
| 1541 |
|
| 1542 |
function mxcToHttp(mxc) {
|
| 1543 |
+
if (!mxc || typeof mxc !== 'string') return '';
|
| 1544 |
+
if (mxc.startsWith('http://') || mxc.startsWith('https://')) return mxc;
|
| 1545 |
+
if (!mxc.startsWith('mxc://')) return '';
|
| 1546 |
const parts = mxc.substring(6).split('/');
|
| 1547 |
if (parts.length < 2) return '';
|
| 1548 |
return `${matrixSession.homeserver}/_matrix/media/v3/download/${parts[0]}/${parts[1]}`;
|
|
|
|
| 1561 |
if (!text || !matrixSession.activeRoomId) return;
|
| 1562 |
|
| 1563 |
const roomId = matrixSession.activeRoomId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1564 |
const txnId = 'm' + Date.now() + '_' + Math.random().toString(36).substring(2, 6);
|
| 1565 |
const sendUrl = `${matrixSession.homeserver}/_matrix/client/v3/rooms/${encodeURIComponent(roomId)}/send/m.room.message/${txnId}`;
|
| 1566 |
|
|
|
|
| 1588 |
}
|
| 1589 |
}
|
| 1590 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1591 |
function handleLogout() {
|
| 1592 |
if (matrixSession.syncTimeoutId) clearTimeout(matrixSession.syncTimeoutId);
|
| 1593 |
matrixSession.accessToken = '';
|
|
|
|
| 1607 |
if (roomArray.length === 0) {
|
| 1608 |
container.innerHTML = `
|
| 1609 |
<div style="padding: 20px; text-align: center; color: var(--tg-subtext); font-size: 13px;">
|
| 1610 |
+
Загрузка комнат из Matrix...
|
| 1611 |
</div>
|
| 1612 |
`;
|
| 1613 |
return;
|
|
|
|
| 1665 |
document.getElementById('chat-empty-state').style.display = 'none';
|
| 1666 |
document.getElementById('chat-active-state').style.display = 'flex';
|
| 1667 |
|
| 1668 |
+
updateRoomHeaderAndSide(room);
|
| 1669 |
+
renderMessages(room);
|
| 1670 |
+
renderRoomsList();
|
| 1671 |
+
fetchRoomMembersIfNeeded(room);
|
| 1672 |
+
}
|
| 1673 |
+
|
| 1674 |
+
function updateRoomHeaderAndSide(room) {
|
| 1675 |
document.getElementById('active-chat-title').innerText = room.name;
|
| 1676 |
document.getElementById('active-chat-status').innerText = room.id;
|
| 1677 |
|
|
|
|
| 1678 |
const initial = room.name ? room.name[0].toUpperCase() : '#';
|
| 1679 |
const avatarBox = document.getElementById('info-avatar-box');
|
| 1680 |
|
|
|
|
| 1688 |
document.getElementById('info-count-box').innerText = room.id;
|
| 1689 |
document.getElementById('info-description-box').innerText = room.topic || 'Описание отсутствует.';
|
| 1690 |
|
| 1691 |
+
// Show edit room buttons if user is creator
|
| 1692 |
+
const isCreator = room.creator === matrixSession.userId || room.id.includes(matrixSession.userId.split(':')[0]);
|
| 1693 |
+
const btnTop = document.getElementById('btn-edit-room-top');
|
| 1694 |
+
const btnSide = document.getElementById('btn-edit-room-side');
|
| 1695 |
+
|
| 1696 |
+
if (isCreator) {
|
| 1697 |
+
btnTop.style.display = 'inline-flex';
|
| 1698 |
+
btnSide.style.display = 'inline-flex';
|
| 1699 |
+
} else {
|
| 1700 |
+
btnTop.style.display = 'none';
|
| 1701 |
+
btnSide.style.display = 'none';
|
| 1702 |
+
}
|
| 1703 |
}
|
| 1704 |
|
| 1705 |
async function fetchRoomMembersIfNeeded(room) {
|
| 1706 |
const memberList = document.getElementById('info-member-list');
|
| 1707 |
memberList.innerHTML = `<li style="font-size:12px; color:var(--tg-subtext);">Загрузка участников...</li>`;
|
| 1708 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1709 |
try {
|
| 1710 |
const res = await fetch(`${matrixSession.homeserver}/_matrix/client/v3/rooms/${encodeURIComponent(room.id)}/joined_members`, {
|
| 1711 |
headers: { 'Authorization': `Bearer ${matrixSession.accessToken}` }
|
|
|
|
| 1793 |
container.scrollTop = container.scrollHeight;
|
| 1794 |
}
|
| 1795 |
|
| 1796 |
+
function openProfileModal() {
|
| 1797 |
+
document.getElementById('profile-userid-input').value = matrixSession.userId || '';
|
| 1798 |
+
document.getElementById('profile-name-input').value = matrixSession.displayName || '';
|
| 1799 |
+
document.getElementById('profile-avatar-input').value = matrixSession.avatarUrl || '';
|
| 1800 |
+
document.getElementById('modal-profile').classList.add('active');
|
| 1801 |
+
}
|
| 1802 |
+
|
| 1803 |
+
function openCreateRoomModal() {
|
| 1804 |
+
document.getElementById('newroom-name-input').value = '';
|
| 1805 |
+
document.getElementById('newroom-topic-input').value = '';
|
| 1806 |
+
document.getElementById('modal-create-room').classList.add('active');
|
| 1807 |
+
}
|
| 1808 |
+
|
| 1809 |
+
function openEditRoomModal() {
|
| 1810 |
+
if (!matrixSession.activeRoomId) return;
|
| 1811 |
+
const room = matrixSession.rooms[matrixSession.activeRoomId];
|
| 1812 |
+
if (!room) return;
|
| 1813 |
+
|
| 1814 |
+
document.getElementById('editroom-name-input').value = room.name || '';
|
| 1815 |
+
document.getElementById('editroom-topic-input').value = room.topic || '';
|
| 1816 |
+
document.getElementById('editroom-avatar-input').value = room.avatar || '';
|
| 1817 |
+
document.getElementById('modal-edit-room').classList.add('active');
|
| 1818 |
+
}
|
| 1819 |
+
|
| 1820 |
+
function closeModal(id) {
|
| 1821 |
+
document.getElementById(id).classList.remove('active');
|
| 1822 |
+
}
|
| 1823 |
+
|
| 1824 |
+
async function saveProfileSettings() {
|
| 1825 |
+
const newName = document.getElementById('profile-name-input').value.trim();
|
| 1826 |
+
const newAvatar = document.getElementById('profile-avatar-input').value.trim();
|
| 1827 |
+
|
| 1828 |
+
if (!matrixSession.accessToken || !matrixSession.userId) return;
|
| 1829 |
+
|
| 1830 |
+
try {
|
| 1831 |
+
if (newName) {
|
| 1832 |
+
await fetch(`${matrixSession.homeserver}/_matrix/client/v3/profile/${encodeURIComponent(matrixSession.userId)}/displayname`, {
|
| 1833 |
+
method: 'PUT',
|
| 1834 |
+
headers: {
|
| 1835 |
+
'Authorization': `Bearer ${matrixSession.accessToken}`,
|
| 1836 |
+
'Content-Type': 'application/json'
|
| 1837 |
+
},
|
| 1838 |
+
body: JSON.stringify({ displayname: newName })
|
| 1839 |
+
});
|
| 1840 |
+
matrixSession.displayName = newName;
|
| 1841 |
+
}
|
| 1842 |
+
|
| 1843 |
+
if (newAvatar) {
|
| 1844 |
+
await fetch(`${matrixSession.homeserver}/_matrix/client/v3/profile/${encodeURIComponent(matrixSession.userId)}/avatar_url`, {
|
| 1845 |
+
method: 'PUT',
|
| 1846 |
+
headers: {
|
| 1847 |
+
'Authorization': `Bearer ${matrixSession.accessToken}`,
|
| 1848 |
+
'Content-Type': 'application/json'
|
| 1849 |
+
},
|
| 1850 |
+
body: JSON.stringify({ avatar_url: newAvatar })
|
| 1851 |
+
});
|
| 1852 |
+
matrixSession.avatarUrl = mxcToHttp(newAvatar);
|
| 1853 |
+
}
|
| 1854 |
+
|
| 1855 |
+
updateUserProfileUI();
|
| 1856 |
+
showToast('Профиль успешно обновлен');
|
| 1857 |
+
closeModal('modal-profile');
|
| 1858 |
+
} catch (err) {
|
| 1859 |
+
console.error('Save profile error:', err);
|
| 1860 |
+
showToast('Не удалось обновить профиль');
|
| 1861 |
+
}
|
| 1862 |
+
}
|
| 1863 |
+
|
| 1864 |
+
async function submitCreateRoom() {
|
| 1865 |
+
const name = document.getElementById('newroom-name-input').value.trim();
|
| 1866 |
+
const topic = document.getElementById('newroom-topic-input').value.trim();
|
| 1867 |
+
const preset = document.getElementById('newroom-preset-select').value;
|
| 1868 |
+
|
| 1869 |
+
if (!name) {
|
| 1870 |
+
showToast('Введите название комна��ы');
|
| 1871 |
+
return;
|
| 1872 |
+
}
|
| 1873 |
+
|
| 1874 |
+
try {
|
| 1875 |
+
const res = await fetch(`${matrixSession.homeserver}/_matrix/client/v3/createRoom`, {
|
| 1876 |
+
method: 'POST',
|
| 1877 |
+
headers: {
|
| 1878 |
+
'Authorization': `Bearer ${matrixSession.accessToken}`,
|
| 1879 |
+
'Content-Type': 'application/json'
|
| 1880 |
+
},
|
| 1881 |
+
body: JSON.stringify({
|
| 1882 |
+
name: name,
|
| 1883 |
+
topic: topic,
|
| 1884 |
+
preset: preset
|
| 1885 |
+
})
|
| 1886 |
+
});
|
| 1887 |
+
|
| 1888 |
+
const data = await res.json();
|
| 1889 |
+
if (res.ok && data.room_id) {
|
| 1890 |
+
showToast('Комната успешно создана!');
|
| 1891 |
+
closeModal('modal-create-room');
|
| 1892 |
+
|
| 1893 |
+
matrixSession.rooms[data.room_id] = {
|
| 1894 |
+
id: data.room_id,
|
| 1895 |
+
name: name,
|
| 1896 |
+
topic: topic,
|
| 1897 |
+
avatar: '',
|
| 1898 |
+
creator: matrixSession.userId,
|
| 1899 |
+
messages: [],
|
| 1900 |
+
members: []
|
| 1901 |
+
};
|
| 1902 |
+
renderRoomsList();
|
| 1903 |
+
selectRoom(data.room_id);
|
| 1904 |
+
} else {
|
| 1905 |
+
showToast(`Ошибка: ${data.error || 'Не удалось создать комнату'}`);
|
| 1906 |
+
}
|
| 1907 |
+
} catch (err) {
|
| 1908 |
+
console.error('Create room error:', err);
|
| 1909 |
+
showToast('Ошибка сети при создании комнаты');
|
| 1910 |
+
}
|
| 1911 |
+
}
|
| 1912 |
+
|
| 1913 |
+
async function saveRoomSettings() {
|
| 1914 |
+
if (!matrixSession.activeRoomId) return;
|
| 1915 |
+
|
| 1916 |
+
const roomId = matrixSession.activeRoomId;
|
| 1917 |
+
const newName = document.getElementById('editroom-name-input').value.trim();
|
| 1918 |
+
const newTopic = document.getElementById('editroom-topic-input').value.trim();
|
| 1919 |
+
const newAvatar = document.getElementById('editroom-avatar-input').value.trim();
|
| 1920 |
+
|
| 1921 |
+
const room = matrixSession.rooms[roomId];
|
| 1922 |
+
|
| 1923 |
+
try {
|
| 1924 |
+
if (newName && newName !== room.name) {
|
| 1925 |
+
await fetch(`${matrixSession.homeserver}/_matrix/client/v3/rooms/${encodeURIComponent(roomId)}/state/m.room.name`, {
|
| 1926 |
+
method: 'PUT',
|
| 1927 |
+
headers: {
|
| 1928 |
+
'Authorization': `Bearer ${matrixSession.accessToken}`,
|
| 1929 |
+
'Content-Type': 'application/json'
|
| 1930 |
+
},
|
| 1931 |
+
body: JSON.stringify({ name: newName })
|
| 1932 |
+
});
|
| 1933 |
+
room.name = newName;
|
| 1934 |
+
}
|
| 1935 |
+
|
| 1936 |
+
if (newTopic !== room.topic) {
|
| 1937 |
+
await fetch(`${matrixSession.homeserver}/_matrix/client/v3/rooms/${encodeURIComponent(roomId)}/state/m.room.topic`, {
|
| 1938 |
+
method: 'PUT',
|
| 1939 |
+
headers: {
|
| 1940 |
+
'Authorization': `Bearer ${matrixSession.accessToken}`,
|
| 1941 |
+
'Content-Type': 'application/json'
|
| 1942 |
+
},
|
| 1943 |
+
body: JSON.stringify({ topic: newTopic })
|
| 1944 |
+
});
|
| 1945 |
+
room.topic = newTopic;
|
| 1946 |
+
}
|
| 1947 |
+
|
| 1948 |
+
if (newAvatar && newAvatar !== room.avatar) {
|
| 1949 |
+
await fetch(`${matrixSession.homeserver}/_matrix/client/v3/rooms/${encodeURIComponent(roomId)}/state/m.room.avatar`, {
|
| 1950 |
+
method: 'PUT',
|
| 1951 |
+
headers: {
|
| 1952 |
+
'Authorization': `Bearer ${matrixSession.accessToken}`,
|
| 1953 |
+
'Content-Type': 'application/json'
|
| 1954 |
+
},
|
| 1955 |
+
body: JSON.stringify({ url: newAvatar })
|
| 1956 |
+
});
|
| 1957 |
+
room.avatar = mxcToHttp(newAvatar);
|
| 1958 |
+
}
|
| 1959 |
+
|
| 1960 |
+
showToast('Настройки комнаты сохранены!');
|
| 1961 |
+
updateRoomHeaderAndSide(room);
|
| 1962 |
+
renderRoomsList();
|
| 1963 |
+
closeModal('modal-edit-room');
|
| 1964 |
+
} catch (err) {
|
| 1965 |
+
console.error('Edit room error:', err);
|
| 1966 |
+
showToast('Ошибка при обновлении параметров комнаты');
|
| 1967 |
+
}
|
| 1968 |
+
}
|
| 1969 |
+
|
| 1970 |
function handleKeyPress(e) {
|
| 1971 |
if (e.key === 'Enter') {
|
| 1972 |
sendMessage();
|