Spaces:
Running
Running
Update index.html
Browse files- index.html +405 -64
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>Matrix Web Client</title>
|
| 7 |
<style>
|
| 8 |
:root {
|
| 9 |
--bg-dark: #090d12;
|
|
@@ -58,6 +58,8 @@
|
|
| 58 |
margin: 0;
|
| 59 |
padding: 0;
|
| 60 |
font-family: var(--font-family);
|
|
|
|
|
|
|
| 61 |
}
|
| 62 |
|
| 63 |
body, html {
|
|
@@ -68,6 +70,21 @@
|
|
| 68 |
overflow: hidden;
|
| 69 |
}
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
/* App Layout */
|
| 72 |
#appContainer {
|
| 73 |
display: flex;
|
|
@@ -183,6 +200,10 @@
|
|
| 183 |
cursor: pointer;
|
| 184 |
background: var(--accent);
|
| 185 |
color: #000;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
transition: background 0.2s;
|
| 187 |
}
|
| 188 |
|
|
@@ -233,6 +254,7 @@
|
|
| 233 |
cursor: pointer;
|
| 234 |
transition: background 0.15s;
|
| 235 |
user-select: none;
|
|
|
|
| 236 |
}
|
| 237 |
|
| 238 |
.room-item:hover {
|
|
@@ -257,6 +279,13 @@
|
|
| 257 |
color: var(--accent);
|
| 258 |
border: 1px solid var(--border-color);
|
| 259 |
flex-shrink: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
}
|
| 261 |
|
| 262 |
.room-info {
|
|
@@ -268,6 +297,7 @@
|
|
| 268 |
display: flex;
|
| 269 |
justify-content: space-between;
|
| 270 |
align-items: center;
|
|
|
|
| 271 |
}
|
| 272 |
|
| 273 |
.room-name {
|
|
@@ -291,12 +321,19 @@
|
|
| 291 |
.workspace {
|
| 292 |
flex: 1;
|
| 293 |
display: flex;
|
| 294 |
-
flex-direction: column;
|
| 295 |
background: var(--bg-dark);
|
| 296 |
min-width: 0;
|
| 297 |
position: relative;
|
| 298 |
}
|
| 299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
.chat-header {
|
| 301 |
height: 64px;
|
| 302 |
padding: 0 20px;
|
|
@@ -341,13 +378,15 @@
|
|
| 341 |
padding: 20px;
|
| 342 |
display: flex;
|
| 343 |
flex-direction: column;
|
| 344 |
-
gap:
|
| 345 |
}
|
| 346 |
|
| 347 |
.message-group {
|
| 348 |
display: flex;
|
| 349 |
flex-direction: column;
|
| 350 |
max-width: 75%;
|
|
|
|
|
|
|
| 351 |
}
|
| 352 |
|
| 353 |
.message-group.me {
|
|
@@ -382,9 +421,8 @@
|
|
| 382 |
border-radius: 14px;
|
| 383 |
font-size: 14px;
|
| 384 |
line-height: 1.4;
|
| 385 |
-
word-break: break-word;
|
| 386 |
-
white-space: pre-wrap;
|
| 387 |
position: relative;
|
|
|
|
| 388 |
}
|
| 389 |
|
| 390 |
.message-group.me .message-bubble {
|
|
@@ -400,13 +438,28 @@
|
|
| 400 |
border-top-left-radius: 2px;
|
| 401 |
}
|
| 402 |
|
| 403 |
-
.
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
}
|
| 411 |
|
| 412 |
/* Input Footer */
|
|
@@ -461,12 +514,40 @@
|
|
| 461 |
display: flex;
|
| 462 |
align-items: center;
|
| 463 |
justify-content: center;
|
|
|
|
| 464 |
}
|
| 465 |
|
| 466 |
.icon-btn:hover {
|
| 467 |
background: var(--bg-hover);
|
| 468 |
}
|
| 469 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
/* Modals & Overlays */
|
| 471 |
.modal-overlay {
|
| 472 |
position: fixed;
|
|
@@ -491,6 +572,8 @@
|
|
| 491 |
flex-direction: column;
|
| 492 |
gap: 16px;
|
| 493 |
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
|
|
|
|
|
|
|
| 494 |
}
|
| 495 |
|
| 496 |
.modal-header {
|
|
@@ -499,6 +582,12 @@
|
|
| 499 |
align-items: center;
|
| 500 |
font-size: 18px;
|
| 501 |
font-weight: bold;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
}
|
| 503 |
|
| 504 |
.form-group {
|
|
@@ -522,6 +611,7 @@
|
|
| 522 |
color: var(--text-main);
|
| 523 |
font-size: 14px;
|
| 524 |
outline: none;
|
|
|
|
| 525 |
}
|
| 526 |
|
| 527 |
.form-input:focus, .form-select:focus {
|
|
@@ -582,11 +672,62 @@
|
|
| 582 |
margin-top: 4px;
|
| 583 |
}
|
| 584 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 585 |
.hidden { display: none !important; }
|
| 586 |
</style>
|
| 587 |
</head>
|
| 588 |
<body id="appBody">
|
| 589 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 590 |
<!-- Toast Notifications Container -->
|
| 591 |
<div id="toastContainer" style="position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px;"></div>
|
| 592 |
|
|
@@ -609,7 +750,6 @@
|
|
| 609 |
<option value="https://matrix.org">matrix.org</option>
|
| 610 |
<option value="https://matrix.unredacted.org">matrix.unredacted.org</option>
|
| 611 |
<option value="https://matrix.envs.net">matrix.envs.net</option>
|
| 612 |
-
<option value="https://mozilla.org">mozilla.org</option>
|
| 613 |
<option value="custom">Свой сервер...</option>
|
| 614 |
</select>
|
| 615 |
<input type="url" id="hsCustomInput" class="form-input hidden" style="margin-top: 6px;" placeholder="https://your-homeserver.com">
|
|
@@ -649,13 +789,22 @@
|
|
| 649 |
<!-- Left Nav Sidebar -->
|
| 650 |
<div class="nav-bar">
|
| 651 |
<div class="nav-logo">M</div>
|
| 652 |
-
<button onclick="switchTab('chats')" id="tabBtn-chats" class="nav-btn active" title="Чаты">
|
| 653 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 654 |
<button onclick="switchTab('inbox')" id="tabBtn-inbox" class="nav-btn" title="Приглашения">
|
| 655 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 656 |
</button>
|
| 657 |
-
<button onclick="switchTab('settings')" id="tabBtn-settings" class="nav-btn" title="Настройки">⚙️</button>
|
| 658 |
-
<button onclick="logout()" class="nav-btn" style="margin-top: auto; color: var(--danger);" title="Выйти">🚪</button>
|
| 659 |
</div>
|
| 660 |
|
| 661 |
<!-- Secondary List Sidebar -->
|
|
@@ -664,9 +813,15 @@
|
|
| 664 |
<div class="sidebar-title-row">
|
| 665 |
<h2 id="sidebarTitle" class="sidebar-title">Чаты</h2>
|
| 666 |
<div id="chatActionBtns" class="action-btns">
|
| 667 |
-
<button onclick="openModal('createDmModal')" class="btn-sm btn-secondary" title="Начать ЛС">
|
| 668 |
-
|
| 669 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 670 |
</div>
|
| 671 |
</div>
|
| 672 |
<input type="text" id="searchInput" class="search-input" oninput="filterRooms()" placeholder="Поиск...">
|
|
@@ -679,7 +834,7 @@
|
|
| 679 |
<div class="workspace">
|
| 680 |
|
| 681 |
<!-- Chat View -->
|
| 682 |
-
<div id="chatView"
|
| 683 |
<div class="chat-header">
|
| 684 |
<div class="chat-header-info">
|
| 685 |
<div id="currentRoomAvatar" class="avatar">#</div>
|
|
@@ -688,7 +843,14 @@
|
|
| 688 |
<p id="currentRoomTopic" class="chat-subtitle">Matrix Client</p>
|
| 689 |
</div>
|
| 690 |
</div>
|
| 691 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 692 |
</div>
|
| 693 |
|
| 694 |
<div id="messageTimeline" class="timeline">
|
|
@@ -700,20 +862,31 @@
|
|
| 700 |
<div class="chat-footer">
|
| 701 |
<div id="replyBanner" class="reply-banner hidden">
|
| 702 |
<span id="replyText">Ответ на сообщение...</span>
|
| 703 |
-
<button onclick="cancelReply()" style="background:none; border:none; color:var(--text-muted); cursor:pointer;">
|
|
|
|
|
|
|
| 704 |
</div>
|
| 705 |
<form onsubmit="sendMessage(event)" class="input-row">
|
| 706 |
<label class="icon-btn" title="Отправить файл">
|
| 707 |
-
|
|
|
|
| 708 |
</label>
|
| 709 |
-
<input type="text" id="msgInput" class="chat-input" placeholder="Написать сообщение..." autocomplete="off">
|
| 710 |
-
<button type="submit" class="btn-sm" style="padding: 12px
|
|
|
|
|
|
|
| 711 |
</form>
|
| 712 |
</div>
|
| 713 |
</div>
|
| 714 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
<!-- Settings View -->
|
| 716 |
-
<div id="settingsView" class="hidden" style="padding: 40px; overflow-y: auto;">
|
| 717 |
<div style="max-width: 500px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px;">
|
| 718 |
<h2>Настройки профиля</h2>
|
| 719 |
|
|
@@ -760,7 +933,9 @@
|
|
| 760 |
<div class="modal-card">
|
| 761 |
<div class="modal-header">
|
| 762 |
<span>Создать комнату</span>
|
| 763 |
-
<button onclick="closeModal('createRoomModal')" style="background:none; border:none; color:var(--text-main); cursor:pointer;">
|
|
|
|
|
|
|
| 764 |
</div>
|
| 765 |
<form onsubmit="handleCreateRoom(event)" style="display: flex; flex-direction: column; gap: 12px;">
|
| 766 |
<div class="form-group">
|
|
@@ -793,7 +968,9 @@
|
|
| 793 |
<div class="modal-card">
|
| 794 |
<div class="modal-header">
|
| 795 |
<span>Написать пользователю (ЛС)</span>
|
| 796 |
-
<button onclick="closeModal('createDmModal')" style="background:none; border:none; color:var(--text-main); cursor:pointer;">
|
|
|
|
|
|
|
| 797 |
</div>
|
| 798 |
<form onsubmit="handleStartDm(event)" style="display: flex; flex-direction: column; gap: 12px;">
|
| 799 |
<div class="form-group">
|
|
@@ -810,7 +987,9 @@
|
|
| 810 |
<div class="modal-card">
|
| 811 |
<div class="modal-header">
|
| 812 |
<span>Присоединиться к комнате</span>
|
| 813 |
-
<button onclick="closeModal('joinRoomModal')" style="background:none; border:none; color:var(--text-main); cursor:pointer;">
|
|
|
|
|
|
|
| 814 |
</div>
|
| 815 |
<form onsubmit="handleJoinRoom(event)" style="display: flex; flex-direction: column; gap: 12px;">
|
| 816 |
<div class="form-group">
|
|
@@ -827,14 +1006,16 @@
|
|
| 827 |
<div class="modal-card">
|
| 828 |
<div class="modal-header">
|
| 829 |
<span>Информация о комнате</span>
|
| 830 |
-
<button onclick="closeModal('roomDetailsModal')" style="background:none; border:none; color:var(--text-main); cursor:pointer;">
|
|
|
|
|
|
|
| 831 |
</div>
|
| 832 |
<div style="display: flex; flex-direction: column; items-center; gap: 12px; text-align: center;">
|
| 833 |
<div id="infoModalAvatar" class="avatar" style="width: 64px; height: 64px; margin: 0 auto; font-size: 24px;">#</div>
|
| 834 |
-
<h3 id="infoModalName"></h3>
|
| 835 |
<p id="infoModalTopic" style="font-size: 13px; color: var(--text-muted);"></p>
|
| 836 |
<div class="form-group" style="text-align: left; width: 100%; margin-top: 12px;">
|
| 837 |
-
<label class="form-label">
|
| 838 |
<input type="text" id="infoModalId" class="form-input" readonly>
|
| 839 |
</div>
|
| 840 |
<button onclick="leaveCurrentRoom()" class="btn-sm" style="background: var(--danger); color: white; width: 100%; margin-top: 12px;">Выйти из комнаты</button>
|
|
@@ -856,13 +1037,12 @@
|
|
| 856 |
rooms: {},
|
| 857 |
invites: {},
|
| 858 |
currentRoomId: null,
|
| 859 |
-
activeTab: 'chats',
|
| 860 |
syncing: false,
|
| 861 |
replyToEvent: null,
|
| 862 |
-
|
| 863 |
};
|
| 864 |
|
| 865 |
-
// Utility: Show Toast Notifications
|
| 866 |
function showToast(msg, isError = false) {
|
| 867 |
const container = document.getElementById('toastContainer');
|
| 868 |
const toast = document.createElement('div');
|
|
@@ -884,15 +1064,19 @@
|
|
| 884 |
}, 3000);
|
| 885 |
}
|
| 886 |
|
| 887 |
-
//
|
| 888 |
function mxcToHttp(mxcUrl) {
|
| 889 |
-
if (!mxcUrl || !mxcUrl.startsWith('mxc://')) return null;
|
| 890 |
const parts = mxcUrl.substring(6).split('/');
|
| 891 |
if (parts.length < 2) return null;
|
| 892 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 893 |
}
|
| 894 |
|
| 895 |
-
// Matrix API Client helper
|
| 896 |
async function apiReq(endpoint, method = 'GET', body = null, isRaw = false) {
|
| 897 |
const headers = {};
|
| 898 |
if (state.accessToken) headers['Authorization'] = `Bearer ${state.accessToken}`;
|
|
@@ -912,7 +1096,6 @@
|
|
| 912 |
}
|
| 913 |
}
|
| 914 |
|
| 915 |
-
// Login Handler
|
| 916 |
function toggleCustomServerInput() {
|
| 917 |
const select = document.getElementById('hsSelect');
|
| 918 |
const customInput = document.getElementById('hsCustomInput');
|
|
@@ -1008,7 +1191,7 @@
|
|
| 1008 |
if (data.displayname) document.getElementById('settingsDisplayName').value = data.displayname;
|
| 1009 |
if (data.avatar_url) {
|
| 1010 |
const httpUrl = mxcToHttp(data.avatar_url);
|
| 1011 |
-
if (httpUrl) document.getElementById('settingsAvatarPreview').innerHTML = `<img src="${httpUrl}"
|
| 1012 |
}
|
| 1013 |
} catch(e){}
|
| 1014 |
}
|
|
@@ -1035,24 +1218,79 @@
|
|
| 1035 |
if (data.rooms?.join) {
|
| 1036 |
for (const [roomId, roomData] of Object.entries(data.rooms.join)) {
|
| 1037 |
if (!state.rooms[roomId]) {
|
| 1038 |
-
state.rooms[roomId] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1039 |
}
|
| 1040 |
const room = state.rooms[roomId];
|
| 1041 |
|
| 1042 |
const allEvents = [...(roomData.state?.events || []), ...(roomData.timeline?.events || [])];
|
| 1043 |
for (const ev of allEvents) {
|
| 1044 |
-
|
| 1045 |
-
if (ev.type === 'm.room.
|
| 1046 |
-
|
| 1047 |
-
|
| 1048 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1049 |
if (ev.type === 'm.room.message') {
|
| 1050 |
if (!room.events.some(e => e.event_id === ev.event_id)) {
|
| 1051 |
room.events.push(ev);
|
| 1052 |
if (roomId !== state.currentRoomId) room.unread++;
|
| 1053 |
}
|
| 1054 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1055 |
}
|
|
|
|
|
|
|
|
|
|
| 1056 |
}
|
| 1057 |
}
|
| 1058 |
|
|
@@ -1072,6 +1310,25 @@
|
|
| 1072 |
updateUI();
|
| 1073 |
}
|
| 1074 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1075 |
function updateUI() {
|
| 1076 |
const inviteCount = Object.keys(state.invites).length;
|
| 1077 |
const badge = document.getElementById('inboxBadge');
|
|
@@ -1079,7 +1336,10 @@
|
|
| 1079 |
if (inviteCount > 0) badge.classList.remove('hidden'); else badge.classList.add('hidden');
|
| 1080 |
|
| 1081 |
renderSidebarList();
|
| 1082 |
-
if (state.currentRoomId)
|
|
|
|
|
|
|
|
|
|
| 1083 |
}
|
| 1084 |
|
| 1085 |
function renderSidebarList() {
|
|
@@ -1102,11 +1362,11 @@
|
|
| 1102 |
item.oncontextmenu = (e) => showRoomContextMenu(e, id);
|
| 1103 |
|
| 1104 |
const avatarHtml = room.avatar
|
| 1105 |
-
? `<img src="${room.avatar}"
|
| 1106 |
-
:
|
| 1107 |
|
| 1108 |
item.innerHTML = `
|
| 1109 |
-
${avatarHtml}
|
| 1110 |
<div class="room-info">
|
| 1111 |
<div class="room-name-row">
|
| 1112 |
<span class="room-name">${escapeHtml(room.name)}</span>
|
|
@@ -1150,11 +1410,27 @@
|
|
| 1150 |
document.getElementById('currentRoomTopic').innerText = room ? (room.topic || 'Без темы') : '';
|
| 1151 |
|
| 1152 |
const avatarEl = document.getElementById('currentRoomAvatar');
|
| 1153 |
-
if (room && room.avatar)
|
| 1154 |
-
|
|
|
|
|
|
|
|
|
|
| 1155 |
|
| 1156 |
renderSidebarList();
|
| 1157 |
renderTimeline();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1158 |
}
|
| 1159 |
|
| 1160 |
function renderTimeline() {
|
|
@@ -1176,7 +1452,7 @@
|
|
| 1176 |
group.className = `message-group ${isMe ? 'me' : 'other'}`;
|
| 1177 |
group.oncontextmenu = (e) => showMessageContextMenu(e, ev);
|
| 1178 |
|
| 1179 |
-
let contentHtml =
|
| 1180 |
if (ev.content?.msgtype === 'm.image' && ev.content.url) {
|
| 1181 |
const imgUrl = mxcToHttp(ev.content.url);
|
| 1182 |
contentHtml = `<img src="${imgUrl}" class="media-img" onclick="openImageViewer('${imgUrl}')"><br>` + contentHtml;
|
|
@@ -1185,12 +1461,27 @@
|
|
| 1185 |
contentHtml = `<video src="${videoUrl}" controls class="media-video"></video><br>` + contentHtml;
|
| 1186 |
}
|
| 1187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1188 |
group.innerHTML = `
|
| 1189 |
<div class="message-header">
|
| 1190 |
-
<span class="sender-name">${escapeHtml(
|
| 1191 |
<span class="message-time">${time}</span>
|
| 1192 |
</div>
|
| 1193 |
<div class="message-bubble">${contentHtml}</div>
|
|
|
|
| 1194 |
`;
|
| 1195 |
container.appendChild(group);
|
| 1196 |
});
|
|
@@ -1198,6 +1489,31 @@
|
|
| 1198 |
container.scrollTop = container.scrollHeight;
|
| 1199 |
}
|
| 1200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1201 |
function showRoomContextMenu(e, roomId) {
|
| 1202 |
e.preventDefault();
|
| 1203 |
closeContextMenu();
|
|
@@ -1205,8 +1521,12 @@
|
|
| 1205 |
menu.style.left = `${e.clientX}px`;
|
| 1206 |
menu.style.top = `${e.clientY}px`;
|
| 1207 |
menu.innerHTML = `
|
| 1208 |
-
<div class="context-item" onclick="openRoomDetailsModal('${roomId}')">
|
| 1209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1210 |
`;
|
| 1211 |
menu.classList.remove('hidden');
|
| 1212 |
}
|
|
@@ -1214,12 +1534,13 @@
|
|
| 1214 |
function showMessageContextMenu(e, ev) {
|
| 1215 |
e.preventDefault();
|
| 1216 |
closeContextMenu();
|
| 1217 |
-
state.contextTarget = ev;
|
| 1218 |
const menu = document.getElementById('customContextMenu');
|
| 1219 |
menu.style.left = `${e.clientX}px`;
|
| 1220 |
menu.style.top = `${e.clientY}px`;
|
| 1221 |
menu.innerHTML = `
|
| 1222 |
<div class="context-item" onclick="setReply('${ev.event_id}', '${escapeHtml(ev.content?.body)}')">↩️ Ответить</div>
|
|
|
|
|
|
|
| 1223 |
<div class="context-item danger" onclick="deleteMessageLocally('${ev.event_id}')">🗑️ Удалить у себя</div>
|
| 1224 |
`;
|
| 1225 |
menu.classList.remove('hidden');
|
|
@@ -1248,7 +1569,23 @@
|
|
| 1248 |
if (room) {
|
| 1249 |
room.events = room.events.filter(e => e.event_id !== eventId);
|
| 1250 |
renderTimeline();
|
| 1251 |
-
showToast('Сообщение удалено
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1252 |
}
|
| 1253 |
}
|
| 1254 |
|
|
@@ -1323,7 +1660,7 @@
|
|
| 1323 |
});
|
| 1324 |
closeModal('createDmModal');
|
| 1325 |
if (res.room_id) {
|
| 1326 |
-
if (!state.rooms[res.room_id]) state.rooms[res.room_id] = { name: targetUser, topic: '', avatar: null, events: [], unread: 0, isDirect: true };
|
| 1327 |
else state.rooms[res.room_id].isDirect = true;
|
| 1328 |
selectRoom(res.room_id);
|
| 1329 |
}
|
|
@@ -1393,9 +1730,14 @@
|
|
| 1393 |
function openRoomDetailsModal(roomId) {
|
| 1394 |
const room = state.rooms[roomId];
|
| 1395 |
if (!room) return;
|
| 1396 |
-
document.getElementById('infoModalName').innerText = room.name;
|
| 1397 |
document.getElementById('infoModalTopic').innerText = room.topic || 'Без темы';
|
| 1398 |
document.getElementById('infoModalId').value = roomId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1399 |
openModal('roomDetailsModal');
|
| 1400 |
}
|
| 1401 |
|
|
@@ -1486,7 +1828,6 @@
|
|
| 1486 |
return str.replace(/[&<>"']/g, m => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[m]));
|
| 1487 |
}
|
| 1488 |
|
| 1489 |
-
// Auto Load saved session on launch
|
| 1490 |
window.onload = checkSavedSession;
|
| 1491 |
</script>
|
| 1492 |
</body>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Matrix Web Client Pro</title>
|
| 7 |
<style>
|
| 8 |
:root {
|
| 9 |
--bg-dark: #090d12;
|
|
|
|
| 58 |
margin: 0;
|
| 59 |
padding: 0;
|
| 60 |
font-family: var(--font-family);
|
| 61 |
+
overflow-wrap: anywhere;
|
| 62 |
+
word-break: break-word;
|
| 63 |
}
|
| 64 |
|
| 65 |
body, html {
|
|
|
|
| 70 |
overflow: hidden;
|
| 71 |
}
|
| 72 |
|
| 73 |
+
/* SVG Icon styling */
|
| 74 |
+
.svg-icon {
|
| 75 |
+
width: 20px;
|
| 76 |
+
height: 20px;
|
| 77 |
+
fill: currentColor;
|
| 78 |
+
display: inline-block;
|
| 79 |
+
vertical-align: middle;
|
| 80 |
+
flex-shrink: 0;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
.svg-icon.sm {
|
| 84 |
+
width: 16px;
|
| 85 |
+
height: 16px;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
/* App Layout */
|
| 89 |
#appContainer {
|
| 90 |
display: flex;
|
|
|
|
| 200 |
cursor: pointer;
|
| 201 |
background: var(--accent);
|
| 202 |
color: #000;
|
| 203 |
+
display: inline-flex;
|
| 204 |
+
align-items: center;
|
| 205 |
+
justify-content: center;
|
| 206 |
+
gap: 6px;
|
| 207 |
transition: background 0.2s;
|
| 208 |
}
|
| 209 |
|
|
|
|
| 254 |
cursor: pointer;
|
| 255 |
transition: background 0.15s;
|
| 256 |
user-select: none;
|
| 257 |
+
min-width: 0;
|
| 258 |
}
|
| 259 |
|
| 260 |
.room-item:hover {
|
|
|
|
| 279 |
color: var(--accent);
|
| 280 |
border: 1px solid var(--border-color);
|
| 281 |
flex-shrink: 0;
|
| 282 |
+
overflow: hidden;
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
.avatar img {
|
| 286 |
+
width: 100%;
|
| 287 |
+
height: 100%;
|
| 288 |
+
object-fit: cover;
|
| 289 |
}
|
| 290 |
|
| 291 |
.room-info {
|
|
|
|
| 297 |
display: flex;
|
| 298 |
justify-content: space-between;
|
| 299 |
align-items: center;
|
| 300 |
+
gap: 6px;
|
| 301 |
}
|
| 302 |
|
| 303 |
.room-name {
|
|
|
|
| 321 |
.workspace {
|
| 322 |
flex: 1;
|
| 323 |
display: flex;
|
|
|
|
| 324 |
background: var(--bg-dark);
|
| 325 |
min-width: 0;
|
| 326 |
position: relative;
|
| 327 |
}
|
| 328 |
|
| 329 |
+
.chat-container {
|
| 330 |
+
flex: 1;
|
| 331 |
+
display: flex;
|
| 332 |
+
flex-direction: column;
|
| 333 |
+
min-width: 0;
|
| 334 |
+
height: 100%;
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
.chat-header {
|
| 338 |
height: 64px;
|
| 339 |
padding: 0 20px;
|
|
|
|
| 378 |
padding: 20px;
|
| 379 |
display: flex;
|
| 380 |
flex-direction: column;
|
| 381 |
+
gap: 14px;
|
| 382 |
}
|
| 383 |
|
| 384 |
.message-group {
|
| 385 |
display: flex;
|
| 386 |
flex-direction: column;
|
| 387 |
max-width: 75%;
|
| 388 |
+
word-break: break-word;
|
| 389 |
+
overflow-wrap: anywhere;
|
| 390 |
}
|
| 391 |
|
| 392 |
.message-group.me {
|
|
|
|
| 421 |
border-radius: 14px;
|
| 422 |
font-size: 14px;
|
| 423 |
line-height: 1.4;
|
|
|
|
|
|
|
| 424 |
position: relative;
|
| 425 |
+
max-width: 100%;
|
| 426 |
}
|
| 427 |
|
| 428 |
.message-group.me .message-bubble {
|
|
|
|
| 438 |
border-top-left-radius: 2px;
|
| 439 |
}
|
| 440 |
|
| 441 |
+
.reactions-row {
|
| 442 |
+
display: flex;
|
| 443 |
+
flex-wrap: wrap;
|
| 444 |
+
gap: 4px;
|
| 445 |
+
margin-top: 4px;
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
.reaction-chip {
|
| 449 |
+
background: var(--bg-card);
|
| 450 |
+
border: 1px solid var(--border-color);
|
| 451 |
+
border-radius: 12px;
|
| 452 |
+
padding: 2px 8px;
|
| 453 |
+
font-size: 11px;
|
| 454 |
+
cursor: pointer;
|
| 455 |
+
display: flex;
|
| 456 |
+
align-items: center;
|
| 457 |
+
gap: 4px;
|
| 458 |
+
color: var(--text-main);
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
.reaction-chip:hover {
|
| 462 |
+
border-color: var(--accent);
|
| 463 |
}
|
| 464 |
|
| 465 |
/* Input Footer */
|
|
|
|
| 514 |
display: flex;
|
| 515 |
align-items: center;
|
| 516 |
justify-content: center;
|
| 517 |
+
transition: all 0.2s;
|
| 518 |
}
|
| 519 |
|
| 520 |
.icon-btn:hover {
|
| 521 |
background: var(--bg-hover);
|
| 522 |
}
|
| 523 |
|
| 524 |
+
/* Members Drawer Panel */
|
| 525 |
+
.members-sidebar {
|
| 526 |
+
width: 260px;
|
| 527 |
+
background: var(--bg-sidebar);
|
| 528 |
+
border-left: 1px solid var(--border-color);
|
| 529 |
+
display: flex;
|
| 530 |
+
flex-direction: column;
|
| 531 |
+
padding: 16px;
|
| 532 |
+
gap: 12px;
|
| 533 |
+
overflow-y: auto;
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
.member-item {
|
| 537 |
+
display: flex;
|
| 538 |
+
align-items: center;
|
| 539 |
+
gap: 10px;
|
| 540 |
+
padding: 6px 0;
|
| 541 |
+
min-width: 0;
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
.member-name {
|
| 545 |
+
font-size: 13px;
|
| 546 |
+
white-space: nowrap;
|
| 547 |
+
overflow: hidden;
|
| 548 |
+
text-overflow: ellipsis;
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
/* Modals & Overlays */
|
| 552 |
.modal-overlay {
|
| 553 |
position: fixed;
|
|
|
|
| 572 |
flex-direction: column;
|
| 573 |
gap: 16px;
|
| 574 |
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
|
| 575 |
+
max-height: 90vh;
|
| 576 |
+
overflow-y: auto;
|
| 577 |
}
|
| 578 |
|
| 579 |
.modal-header {
|
|
|
|
| 582 |
align-items: center;
|
| 583 |
font-size: 18px;
|
| 584 |
font-weight: bold;
|
| 585 |
+
gap: 12px;
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
.modal-header span {
|
| 589 |
+
overflow-wrap: anywhere;
|
| 590 |
+
word-break: break-word;
|
| 591 |
}
|
| 592 |
|
| 593 |
.form-group {
|
|
|
|
| 611 |
color: var(--text-main);
|
| 612 |
font-size: 14px;
|
| 613 |
outline: none;
|
| 614 |
+
width: 100%;
|
| 615 |
}
|
| 616 |
|
| 617 |
.form-input:focus, .form-select:focus {
|
|
|
|
| 672 |
margin-top: 4px;
|
| 673 |
}
|
| 674 |
|
| 675 |
+
.code-block {
|
| 676 |
+
background: var(--bg-dark);
|
| 677 |
+
border: 1px solid var(--border-color);
|
| 678 |
+
padding: 8px 12px;
|
| 679 |
+
border-radius: 6px;
|
| 680 |
+
font-family: monospace;
|
| 681 |
+
font-size: 12px;
|
| 682 |
+
margin-top: 4px;
|
| 683 |
+
overflow-x: auto;
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
.hidden { display: none !important; }
|
| 687 |
</style>
|
| 688 |
</head>
|
| 689 |
<body id="appBody">
|
| 690 |
|
| 691 |
+
<!-- SVG Icon Definitions -->
|
| 692 |
+
<svg style="display: none;">
|
| 693 |
+
<symbol id="icon-chat" viewBox="0 0 24 24">
|
| 694 |
+
<path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H5.2L4 17.2V4h16v12z"/>
|
| 695 |
+
</symbol>
|
| 696 |
+
<symbol id="icon-user" viewBox="0 0 24 24">
|
| 697 |
+
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
|
| 698 |
+
</symbol>
|
| 699 |
+
<symbol id="icon-inbox" viewBox="0 0 24 24">
|
| 700 |
+
<path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5v-3h3.58c.77 1.19 2.08 2 3.58 2s2.81-.81 3.58-2H19v3zm0-5h-4.17c-.41 1.16-1.52 2-2.83 2s-2.42-.84-2.83-2H5V5h14v9z"/>
|
| 701 |
+
</symbol>
|
| 702 |
+
<symbol id="icon-settings" viewBox="0 0 24 24">
|
| 703 |
+
<path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"/>
|
| 704 |
+
</symbol>
|
| 705 |
+
<symbol id="icon-logout" viewBox="0 0 24 24">
|
| 706 |
+
<path d="M17 7l-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4V5z"/>
|
| 707 |
+
</symbol>
|
| 708 |
+
<symbol id="icon-plus" viewBox="0 0 24 24">
|
| 709 |
+
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
| 710 |
+
</symbol>
|
| 711 |
+
<symbol id="icon-link" viewBox="0 0 24 24">
|
| 712 |
+
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>
|
| 713 |
+
</symbol>
|
| 714 |
+
<symbol id="icon-attach" viewBox="0 0 24 24">
|
| 715 |
+
<path d="M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z"/>
|
| 716 |
+
</symbol>
|
| 717 |
+
<symbol id="icon-send" viewBox="0 0 24 24">
|
| 718 |
+
<path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/>
|
| 719 |
+
</symbol>
|
| 720 |
+
<symbol id="icon-close" viewBox="0 0 24 24">
|
| 721 |
+
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
|
| 722 |
+
</symbol>
|
| 723 |
+
<symbol id="icon-info" viewBox="0 0 24 24">
|
| 724 |
+
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/>
|
| 725 |
+
</symbol>
|
| 726 |
+
<symbol id="icon-members" viewBox="0 0 24 24">
|
| 727 |
+
<path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/>
|
| 728 |
+
</symbol>
|
| 729 |
+
</svg>
|
| 730 |
+
|
| 731 |
<!-- Toast Notifications Container -->
|
| 732 |
<div id="toastContainer" style="position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px;"></div>
|
| 733 |
|
|
|
|
| 750 |
<option value="https://matrix.org">matrix.org</option>
|
| 751 |
<option value="https://matrix.unredacted.org">matrix.unredacted.org</option>
|
| 752 |
<option value="https://matrix.envs.net">matrix.envs.net</option>
|
|
|
|
| 753 |
<option value="custom">Свой сервер...</option>
|
| 754 |
</select>
|
| 755 |
<input type="url" id="hsCustomInput" class="form-input hidden" style="margin-top: 6px;" placeholder="https://your-homeserver.com">
|
|
|
|
| 789 |
<!-- Left Nav Sidebar -->
|
| 790 |
<div class="nav-bar">
|
| 791 |
<div class="nav-logo">M</div>
|
| 792 |
+
<button onclick="switchTab('chats')" id="tabBtn-chats" class="nav-btn active" title="Чаты">
|
| 793 |
+
<svg class="svg-icon"><use href="#icon-chat"/></svg>
|
| 794 |
+
</button>
|
| 795 |
+
<button onclick="switchTab('dms')" id="tabBtn-dms" class="nav-btn" title="Личные сообщения">
|
| 796 |
+
<svg class="svg-icon"><use href="#icon-user"/></svg>
|
| 797 |
+
</button>
|
| 798 |
<button onclick="switchTab('inbox')" id="tabBtn-inbox" class="nav-btn" title="Приглашения">
|
| 799 |
+
<svg class="svg-icon"><use href="#icon-inbox"/></svg>
|
| 800 |
+
<span id="inboxBadge" class="badge hidden">0</span>
|
| 801 |
+
</button>
|
| 802 |
+
<button onclick="switchTab('settings')" id="tabBtn-settings" class="nav-btn" title="Настройки">
|
| 803 |
+
<svg class="svg-icon"><use href="#icon-settings"/></svg>
|
| 804 |
+
</button>
|
| 805 |
+
<button onclick="logout()" class="nav-btn" style="margin-top: auto; color: var(--danger);" title="Выйти">
|
| 806 |
+
<svg class="svg-icon"><use href="#icon-logout"/></svg>
|
| 807 |
</button>
|
|
|
|
|
|
|
| 808 |
</div>
|
| 809 |
|
| 810 |
<!-- Secondary List Sidebar -->
|
|
|
|
| 813 |
<div class="sidebar-title-row">
|
| 814 |
<h2 id="sidebarTitle" class="sidebar-title">Чаты</h2>
|
| 815 |
<div id="chatActionBtns" class="action-btns">
|
| 816 |
+
<button onclick="openModal('createDmModal')" class="btn-sm btn-secondary" title="Начать ЛС">
|
| 817 |
+
<svg class="svg-icon sm"><use href="#icon-user"/></svg>+
|
| 818 |
+
</button>
|
| 819 |
+
<button onclick="openModal('createRoomModal')" class="btn-sm" title="Создать комнату">
|
| 820 |
+
<svg class="svg-icon sm"><use href="#icon-plus"/></svg>
|
| 821 |
+
</button>
|
| 822 |
+
<button onclick="openModal('joinRoomModal')" class="btn-sm btn-secondary" title="Присоединиться">
|
| 823 |
+
<svg class="svg-icon sm"><use href="#icon-link"/></svg>
|
| 824 |
+
</button>
|
| 825 |
</div>
|
| 826 |
</div>
|
| 827 |
<input type="text" id="searchInput" class="search-input" oninput="filterRooms()" placeholder="Поиск...">
|
|
|
|
| 834 |
<div class="workspace">
|
| 835 |
|
| 836 |
<!-- Chat View -->
|
| 837 |
+
<div id="chatView" class="chat-container">
|
| 838 |
<div class="chat-header">
|
| 839 |
<div class="chat-header-info">
|
| 840 |
<div id="currentRoomAvatar" class="avatar">#</div>
|
|
|
|
| 843 |
<p id="currentRoomTopic" class="chat-subtitle">Matrix Client</p>
|
| 844 |
</div>
|
| 845 |
</div>
|
| 846 |
+
<div style="display: flex; gap: 8px;">
|
| 847 |
+
<button onclick="toggleMembersSidebar()" class="btn-sm btn-secondary" title="Участники">
|
| 848 |
+
<svg class="svg-icon sm"><use href="#icon-members"/></svg>
|
| 849 |
+
</button>
|
| 850 |
+
<button onclick="openCurrentRoomDetails()" class="btn-sm btn-secondary" title="Инфо">
|
| 851 |
+
<svg class="svg-icon sm"><use href="#icon-info"/></svg>
|
| 852 |
+
</button>
|
| 853 |
+
</div>
|
| 854 |
</div>
|
| 855 |
|
| 856 |
<div id="messageTimeline" class="timeline">
|
|
|
|
| 862 |
<div class="chat-footer">
|
| 863 |
<div id="replyBanner" class="reply-banner hidden">
|
| 864 |
<span id="replyText">Ответ на сообщение...</span>
|
| 865 |
+
<button onclick="cancelReply()" style="background:none; border:none; color:var(--text-muted); cursor:pointer;">
|
| 866 |
+
<svg class="svg-icon sm"><use href="#icon-close"/></svg>
|
| 867 |
+
</button>
|
| 868 |
</div>
|
| 869 |
<form onsubmit="sendMessage(event)" class="input-row">
|
| 870 |
<label class="icon-btn" title="Отправить файл">
|
| 871 |
+
<svg class="svg-icon"><use href="#icon-attach"/></svg>
|
| 872 |
+
<input type="file" id="fileInput" onchange="sendFile(this)" style="display: none;">
|
| 873 |
</label>
|
| 874 |
+
<input type="text" id="msgInput" class="chat-input" placeholder="Написать сообщение (поддерживается **bold**, *italic*, `code`)..." autocomplete="off">
|
| 875 |
+
<button type="submit" class="btn-sm" style="padding: 12px 18px;">
|
| 876 |
+
<svg class="svg-icon"><use href="#icon-send"/></svg>
|
| 877 |
+
</button>
|
| 878 |
</form>
|
| 879 |
</div>
|
| 880 |
</div>
|
| 881 |
|
| 882 |
+
<!-- Members Sidebar Panel -->
|
| 883 |
+
<div id="membersSidebar" class="members-sidebar hidden">
|
| 884 |
+
<h4 style="font-size: 14px; margin-bottom: 8px;">Участники</h4>
|
| 885 |
+
<div id="membersList" style="display: flex; flex-direction: column; gap: 8px;"></div>
|
| 886 |
+
</div>
|
| 887 |
+
|
| 888 |
<!-- Settings View -->
|
| 889 |
+
<div id="settingsView" class="hidden" style="flex: 1; padding: 40px; overflow-y: auto;">
|
| 890 |
<div style="max-width: 500px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px;">
|
| 891 |
<h2>Настройки профиля</h2>
|
| 892 |
|
|
|
|
| 933 |
<div class="modal-card">
|
| 934 |
<div class="modal-header">
|
| 935 |
<span>Создать комнату</span>
|
| 936 |
+
<button onclick="closeModal('createRoomModal')" style="background:none; border:none; color:var(--text-main); cursor:pointer;">
|
| 937 |
+
<svg class="svg-icon"><use href="#icon-close"/></svg>
|
| 938 |
+
</button>
|
| 939 |
</div>
|
| 940 |
<form onsubmit="handleCreateRoom(event)" style="display: flex; flex-direction: column; gap: 12px;">
|
| 941 |
<div class="form-group">
|
|
|
|
| 968 |
<div class="modal-card">
|
| 969 |
<div class="modal-header">
|
| 970 |
<span>Написать пользователю (ЛС)</span>
|
| 971 |
+
<button onclick="closeModal('createDmModal')" style="background:none; border:none; color:var(--text-main); cursor:pointer;">
|
| 972 |
+
<svg class="svg-icon"><use href="#icon-close"/></svg>
|
| 973 |
+
</button>
|
| 974 |
</div>
|
| 975 |
<form onsubmit="handleStartDm(event)" style="display: flex; flex-direction: column; gap: 12px;">
|
| 976 |
<div class="form-group">
|
|
|
|
| 987 |
<div class="modal-card">
|
| 988 |
<div class="modal-header">
|
| 989 |
<span>Присоединиться к комнате</span>
|
| 990 |
+
<button onclick="closeModal('joinRoomModal')" style="background:none; border:none; color:var(--text-main); cursor:pointer;">
|
| 991 |
+
<svg class="svg-icon"><use href="#icon-close"/></svg>
|
| 992 |
+
</button>
|
| 993 |
</div>
|
| 994 |
<form onsubmit="handleJoinRoom(event)" style="display: flex; flex-direction: column; gap: 12px;">
|
| 995 |
<div class="form-group">
|
|
|
|
| 1006 |
<div class="modal-card">
|
| 1007 |
<div class="modal-header">
|
| 1008 |
<span>Информация о комнате</span>
|
| 1009 |
+
<button onclick="closeModal('roomDetailsModal')" style="background:none; border:none; color:var(--text-main); cursor:pointer;">
|
| 1010 |
+
<svg class="svg-icon"><use href="#icon-close"/></svg>
|
| 1011 |
+
</button>
|
| 1012 |
</div>
|
| 1013 |
<div style="display: flex; flex-direction: column; items-center; gap: 12px; text-align: center;">
|
| 1014 |
<div id="infoModalAvatar" class="avatar" style="width: 64px; height: 64px; margin: 0 auto; font-size: 24px;">#</div>
|
| 1015 |
+
<h3 id="infoModalName" style="max-width: 100%;"></h3>
|
| 1016 |
<p id="infoModalTopic" style="font-size: 13px; color: var(--text-muted);"></p>
|
| 1017 |
<div class="form-group" style="text-align: left; width: 100%; margin-top: 12px;">
|
| 1018 |
+
<label class="form-label">ROOM ID</label>
|
| 1019 |
<input type="text" id="infoModalId" class="form-input" readonly>
|
| 1020 |
</div>
|
| 1021 |
<button onclick="leaveCurrentRoom()" class="btn-sm" style="background: var(--danger); color: white; width: 100%; margin-top: 12px;">Выйти из комнаты</button>
|
|
|
|
| 1037 |
rooms: {},
|
| 1038 |
invites: {},
|
| 1039 |
currentRoomId: null,
|
| 1040 |
+
activeTab: 'chats',
|
| 1041 |
syncing: false,
|
| 1042 |
replyToEvent: null,
|
| 1043 |
+
showMembers: false
|
| 1044 |
};
|
| 1045 |
|
|
|
|
| 1046 |
function showToast(msg, isError = false) {
|
| 1047 |
const container = document.getElementById('toastContainer');
|
| 1048 |
const toast = document.createElement('div');
|
|
|
|
| 1064 |
}, 3000);
|
| 1065 |
}
|
| 1066 |
|
| 1067 |
+
// MXC URI converter with authenticated media fallback
|
| 1068 |
function mxcToHttp(mxcUrl) {
|
| 1069 |
+
if (!mxcUrl || typeof mxcUrl !== 'string' || !mxcUrl.startsWith('mxc://')) return null;
|
| 1070 |
const parts = mxcUrl.substring(6).split('/');
|
| 1071 |
if (parts.length < 2) return null;
|
| 1072 |
+
|
| 1073 |
+
const serverName = parts[0];
|
| 1074 |
+
const mediaId = parts[1];
|
| 1075 |
+
|
| 1076 |
+
// Modern Matrix endpoint & legacy fallbacks
|
| 1077 |
+
return `${state.hsUrl}/_matrix/media/v3/download/${serverName}/${mediaId}`;
|
| 1078 |
}
|
| 1079 |
|
|
|
|
| 1080 |
async function apiReq(endpoint, method = 'GET', body = null, isRaw = false) {
|
| 1081 |
const headers = {};
|
| 1082 |
if (state.accessToken) headers['Authorization'] = `Bearer ${state.accessToken}`;
|
|
|
|
| 1096 |
}
|
| 1097 |
}
|
| 1098 |
|
|
|
|
| 1099 |
function toggleCustomServerInput() {
|
| 1100 |
const select = document.getElementById('hsSelect');
|
| 1101 |
const customInput = document.getElementById('hsCustomInput');
|
|
|
|
| 1191 |
if (data.displayname) document.getElementById('settingsDisplayName').value = data.displayname;
|
| 1192 |
if (data.avatar_url) {
|
| 1193 |
const httpUrl = mxcToHttp(data.avatar_url);
|
| 1194 |
+
if (httpUrl) document.getElementById('settingsAvatarPreview').innerHTML = `<img src="${httpUrl}">`;
|
| 1195 |
}
|
| 1196 |
} catch(e){}
|
| 1197 |
}
|
|
|
|
| 1218 |
if (data.rooms?.join) {
|
| 1219 |
for (const [roomId, roomData] of Object.entries(data.rooms.join)) {
|
| 1220 |
if (!state.rooms[roomId]) {
|
| 1221 |
+
state.rooms[roomId] = {
|
| 1222 |
+
id: roomId,
|
| 1223 |
+
name: null,
|
| 1224 |
+
topic: '',
|
| 1225 |
+
avatar: null,
|
| 1226 |
+
events: [],
|
| 1227 |
+
reactions: {},
|
| 1228 |
+
members: {},
|
| 1229 |
+
unread: 0,
|
| 1230 |
+
isDirect: false
|
| 1231 |
+
};
|
| 1232 |
}
|
| 1233 |
const room = state.rooms[roomId];
|
| 1234 |
|
| 1235 |
const allEvents = [...(roomData.state?.events || []), ...(roomData.timeline?.events || [])];
|
| 1236 |
for (const ev of allEvents) {
|
| 1237 |
+
// Room Name
|
| 1238 |
+
if (ev.type === 'm.room.name' && ev.content?.name) {
|
| 1239 |
+
room.name = ev.content.name;
|
| 1240 |
+
}
|
| 1241 |
+
// Canonical Alias
|
| 1242 |
+
if (ev.type === 'm.room.canonical_alias' && ev.content?.alias && !room.name) {
|
| 1243 |
+
room.name = ev.content.alias;
|
| 1244 |
+
}
|
| 1245 |
+
// Room Topic
|
| 1246 |
+
if (ev.type === 'm.room.topic' && ev.content?.topic) {
|
| 1247 |
+
room.topic = ev.content.topic;
|
| 1248 |
+
}
|
| 1249 |
+
// Direct Room Avatar
|
| 1250 |
+
if (ev.type === 'm.room.avatar' && ev.content?.url) {
|
| 1251 |
+
room.avatar = mxcToHttp(ev.content.url);
|
| 1252 |
+
}
|
| 1253 |
+
// Direct Message state
|
| 1254 |
+
if (ev.type === 'm.direct') {
|
| 1255 |
+
room.isDirect = true;
|
| 1256 |
+
}
|
| 1257 |
+
|
| 1258 |
+
// Room Members & User Avatars
|
| 1259 |
+
if (ev.type === 'm.room.member') {
|
| 1260 |
+
const sender = ev.state_key || ev.sender;
|
| 1261 |
+
const memberAvatar = mxcToHttp(ev.content?.avatar_url);
|
| 1262 |
+
const displayName = ev.content?.displayname || sender;
|
| 1263 |
+
|
| 1264 |
+
room.members[sender] = {
|
| 1265 |
+
userId: sender,
|
| 1266 |
+
name: displayName,
|
| 1267 |
+
avatar: memberAvatar
|
| 1268 |
+
};
|
| 1269 |
+
}
|
| 1270 |
+
|
| 1271 |
+
// Message events
|
| 1272 |
if (ev.type === 'm.room.message') {
|
| 1273 |
if (!room.events.some(e => e.event_id === ev.event_id)) {
|
| 1274 |
room.events.push(ev);
|
| 1275 |
if (roomId !== state.currentRoomId) room.unread++;
|
| 1276 |
}
|
| 1277 |
}
|
| 1278 |
+
|
| 1279 |
+
// Reactions
|
| 1280 |
+
if (ev.type === 'm.reaction' && ev.content?.['m.relates_to']) {
|
| 1281 |
+
const rel = ev.content['m.relates_to'];
|
| 1282 |
+
const targetId = rel.event_id;
|
| 1283 |
+
const emojiKey = rel.key;
|
| 1284 |
+
if (targetId && emojiKey) {
|
| 1285 |
+
if (!room.reactions[targetId]) room.reactions[targetId] = {};
|
| 1286 |
+
if (!room.reactions[targetId][emojiKey]) room.reactions[targetId][emojiKey] = 0;
|
| 1287 |
+
room.reactions[targetId][emojiKey]++;
|
| 1288 |
+
}
|
| 1289 |
+
}
|
| 1290 |
}
|
| 1291 |
+
|
| 1292 |
+
// Dynamically resolve room display name and avatar if not explicitly set
|
| 1293 |
+
computeRoomNameAndAvatar(room);
|
| 1294 |
}
|
| 1295 |
}
|
| 1296 |
|
|
|
|
| 1310 |
updateUI();
|
| 1311 |
}
|
| 1312 |
|
| 1313 |
+
// Resolves DM names and member-based fallback avatars properly
|
| 1314 |
+
function computeRoomNameAndAvatar(room) {
|
| 1315 |
+
const memberKeys = Object.keys(room.members).filter(id => id !== state.userId);
|
| 1316 |
+
|
| 1317 |
+
if (memberKeys.length === 1) {
|
| 1318 |
+
room.isDirect = true;
|
| 1319 |
+
const partner = room.members[memberKeys[0]];
|
| 1320 |
+
if (!room.name) room.name = partner.name || partner.userId;
|
| 1321 |
+
if (!room.avatar) room.avatar = partner.avatar;
|
| 1322 |
+
} else if (!room.name) {
|
| 1323 |
+
if (memberKeys.length > 1) {
|
| 1324 |
+
const names = memberKeys.slice(0, 3).map(k => room.members[k]?.name || k);
|
| 1325 |
+
room.name = names.join(', ');
|
| 1326 |
+
} else {
|
| 1327 |
+
room.name = room.id;
|
| 1328 |
+
}
|
| 1329 |
+
}
|
| 1330 |
+
}
|
| 1331 |
+
|
| 1332 |
function updateUI() {
|
| 1333 |
const inviteCount = Object.keys(state.invites).length;
|
| 1334 |
const badge = document.getElementById('inboxBadge');
|
|
|
|
| 1336 |
if (inviteCount > 0) badge.classList.remove('hidden'); else badge.classList.add('hidden');
|
| 1337 |
|
| 1338 |
renderSidebarList();
|
| 1339 |
+
if (state.currentRoomId) {
|
| 1340 |
+
renderTimeline();
|
| 1341 |
+
renderMembersList();
|
| 1342 |
+
}
|
| 1343 |
}
|
| 1344 |
|
| 1345 |
function renderSidebarList() {
|
|
|
|
| 1362 |
item.oncontextmenu = (e) => showRoomContextMenu(e, id);
|
| 1363 |
|
| 1364 |
const avatarHtml = room.avatar
|
| 1365 |
+
? `<img src="${room.avatar}" onerror="this.onerror=null; this.parentElement.innerText='${(room.name[0] || '#').toUpperCase()}';">`
|
| 1366 |
+
: (room.name[0] || '#').toUpperCase();
|
| 1367 |
|
| 1368 |
item.innerHTML = `
|
| 1369 |
+
<div class="avatar">${avatarHtml}</div>
|
| 1370 |
<div class="room-info">
|
| 1371 |
<div class="room-name-row">
|
| 1372 |
<span class="room-name">${escapeHtml(room.name)}</span>
|
|
|
|
| 1410 |
document.getElementById('currentRoomTopic').innerText = room ? (room.topic || 'Без темы') : '';
|
| 1411 |
|
| 1412 |
const avatarEl = document.getElementById('currentRoomAvatar');
|
| 1413 |
+
if (room && room.avatar) {
|
| 1414 |
+
avatarEl.innerHTML = `<img src="${room.avatar}" onerror="this.onerror=null; this.parentElement.innerText='${(room.name[0] || '#').toUpperCase()}';">`;
|
| 1415 |
+
} else {
|
| 1416 |
+
avatarEl.innerText = room ? (room.name[0] || '#').toUpperCase() : '#';
|
| 1417 |
+
}
|
| 1418 |
|
| 1419 |
renderSidebarList();
|
| 1420 |
renderTimeline();
|
| 1421 |
+
renderMembersList();
|
| 1422 |
+
}
|
| 1423 |
+
|
| 1424 |
+
// Formatting markdown and text content securely
|
| 1425 |
+
function formatMessageContent(text) {
|
| 1426 |
+
let html = escapeHtml(text);
|
| 1427 |
+
// Bold
|
| 1428 |
+
html = html.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
|
| 1429 |
+
// Italic
|
| 1430 |
+
html = html.replace(/\*(.*?)\*/g, '<em>$1</em>');
|
| 1431 |
+
// Code inline
|
| 1432 |
+
html = html.replace(/`(.*?)`/g, '<code class="code-block">$1</code>');
|
| 1433 |
+
return html;
|
| 1434 |
}
|
| 1435 |
|
| 1436 |
function renderTimeline() {
|
|
|
|
| 1452 |
group.className = `message-group ${isMe ? 'me' : 'other'}`;
|
| 1453 |
group.oncontextmenu = (e) => showMessageContextMenu(e, ev);
|
| 1454 |
|
| 1455 |
+
let contentHtml = formatMessageContent(body);
|
| 1456 |
if (ev.content?.msgtype === 'm.image' && ev.content.url) {
|
| 1457 |
const imgUrl = mxcToHttp(ev.content.url);
|
| 1458 |
contentHtml = `<img src="${imgUrl}" class="media-img" onclick="openImageViewer('${imgUrl}')"><br>` + contentHtml;
|
|
|
|
| 1461 |
contentHtml = `<video src="${videoUrl}" controls class="media-video"></video><br>` + contentHtml;
|
| 1462 |
}
|
| 1463 |
|
| 1464 |
+
// Render message reactions
|
| 1465 |
+
let reactionsHtml = '';
|
| 1466 |
+
const evReactions = room.reactions[ev.event_id];
|
| 1467 |
+
if (evReactions) {
|
| 1468 |
+
reactionsHtml = '<div class="reactions-row">';
|
| 1469 |
+
for (const [emoji, count] of Object.entries(evReactions)) {
|
| 1470 |
+
reactionsHtml += `<div class="reaction-chip" onclick="sendReaction('${ev.event_id}', '${emoji}')">${emoji} ${count}</div>`;
|
| 1471 |
+
}
|
| 1472 |
+
reactionsHtml += '</div>';
|
| 1473 |
+
}
|
| 1474 |
+
|
| 1475 |
+
const senderMember = room.members[ev.sender];
|
| 1476 |
+
const displayName = senderMember?.name || ev.sender;
|
| 1477 |
+
|
| 1478 |
group.innerHTML = `
|
| 1479 |
<div class="message-header">
|
| 1480 |
+
<span class="sender-name">${escapeHtml(displayName)}</span>
|
| 1481 |
<span class="message-time">${time}</span>
|
| 1482 |
</div>
|
| 1483 |
<div class="message-bubble">${contentHtml}</div>
|
| 1484 |
+
${reactionsHtml}
|
| 1485 |
`;
|
| 1486 |
container.appendChild(group);
|
| 1487 |
});
|
|
|
|
| 1489 |
container.scrollTop = container.scrollHeight;
|
| 1490 |
}
|
| 1491 |
|
| 1492 |
+
function toggleMembersSidebar() {
|
| 1493 |
+
state.showMembers = !state.showMembers;
|
| 1494 |
+
document.getElementById('membersSidebar').classList.toggle('hidden', !state.showMembers);
|
| 1495 |
+
}
|
| 1496 |
+
|
| 1497 |
+
function renderMembersList() {
|
| 1498 |
+
const container = document.getElementById('membersList');
|
| 1499 |
+
container.innerHTML = '';
|
| 1500 |
+
const room = state.rooms[state.currentRoomId];
|
| 1501 |
+
if (!room) return;
|
| 1502 |
+
|
| 1503 |
+
Object.values(room.members).forEach(m => {
|
| 1504 |
+
const item = document.createElement('div');
|
| 1505 |
+
item.className = 'member-item';
|
| 1506 |
+
const avatarHtml = m.avatar
|
| 1507 |
+
? `<img src="${m.avatar}" onerror="this.onerror=null; this.parentElement.innerText='${(m.name[0] || '?').toUpperCase()}';">`
|
| 1508 |
+
: (m.name[0] || '?').toUpperCase();
|
| 1509 |
+
item.innerHTML = `
|
| 1510 |
+
<div class="avatar" style="width:28px; height:28px; font-size:12px;">${avatarHtml}</div>
|
| 1511 |
+
<span class="member-name">${escapeHtml(m.name)}</span>
|
| 1512 |
+
`;
|
| 1513 |
+
container.appendChild(item);
|
| 1514 |
+
});
|
| 1515 |
+
}
|
| 1516 |
+
|
| 1517 |
function showRoomContextMenu(e, roomId) {
|
| 1518 |
e.preventDefault();
|
| 1519 |
closeContextMenu();
|
|
|
|
| 1521 |
menu.style.left = `${e.clientX}px`;
|
| 1522 |
menu.style.top = `${e.clientY}px`;
|
| 1523 |
menu.innerHTML = `
|
| 1524 |
+
<div class="context-item" onclick="openRoomDetailsModal('${roomId}')">
|
| 1525 |
+
<svg class="svg-icon sm"><use href="#icon-info"/></svg> Информация
|
| 1526 |
+
</div>
|
| 1527 |
+
<div class="context-item danger" onclick="leaveRoom('${roomId}')">
|
| 1528 |
+
<svg class="svg-icon sm"><use href="#icon-logout"/></svg> Выйти из комнаты
|
| 1529 |
+
</div>
|
| 1530 |
`;
|
| 1531 |
menu.classList.remove('hidden');
|
| 1532 |
}
|
|
|
|
| 1534 |
function showMessageContextMenu(e, ev) {
|
| 1535 |
e.preventDefault();
|
| 1536 |
closeContextMenu();
|
|
|
|
| 1537 |
const menu = document.getElementById('customContextMenu');
|
| 1538 |
menu.style.left = `${e.clientX}px`;
|
| 1539 |
menu.style.top = `${e.clientY}px`;
|
| 1540 |
menu.innerHTML = `
|
| 1541 |
<div class="context-item" onclick="setReply('${ev.event_id}', '${escapeHtml(ev.content?.body)}')">↩️ Ответить</div>
|
| 1542 |
+
<div class="context-item" onclick="sendReaction('${ev.event_id}', '👍')">👍 Реакция</div>
|
| 1543 |
+
<div class="context-item" onclick="sendReaction('${ev.event_id}', '❤️')">❤️ Реакция</div>
|
| 1544 |
<div class="context-item danger" onclick="deleteMessageLocally('${ev.event_id}')">🗑️ Удалить у себя</div>
|
| 1545 |
`;
|
| 1546 |
menu.classList.remove('hidden');
|
|
|
|
| 1569 |
if (room) {
|
| 1570 |
room.events = room.events.filter(e => e.event_id !== eventId);
|
| 1571 |
renderTimeline();
|
| 1572 |
+
showToast('Сообщение удалено');
|
| 1573 |
+
}
|
| 1574 |
+
}
|
| 1575 |
+
|
| 1576 |
+
async function sendReaction(eventId, emoji) {
|
| 1577 |
+
if (!state.currentRoomId) return;
|
| 1578 |
+
const txnId = 'm' + Date.now();
|
| 1579 |
+
try {
|
| 1580 |
+
await apiReq(`client/v3/rooms/${encodeURIComponent(state.currentRoomId)}/send/m.reaction/${txnId}`, 'PUT', {
|
| 1581 |
+
'm.relates_to': {
|
| 1582 |
+
rel_type: 'm.annotation',
|
| 1583 |
+
event_id: eventId,
|
| 1584 |
+
key: emoji
|
| 1585 |
+
}
|
| 1586 |
+
});
|
| 1587 |
+
} catch (err) {
|
| 1588 |
+
showToast(`Ошибка реакции: ${err.message}`, true);
|
| 1589 |
}
|
| 1590 |
}
|
| 1591 |
|
|
|
|
| 1660 |
});
|
| 1661 |
closeModal('createDmModal');
|
| 1662 |
if (res.room_id) {
|
| 1663 |
+
if (!state.rooms[res.room_id]) state.rooms[res.room_id] = { id: res.room_id, name: targetUser, topic: '', avatar: null, events: [], reactions: {}, members: {}, unread: 0, isDirect: true };
|
| 1664 |
else state.rooms[res.room_id].isDirect = true;
|
| 1665 |
selectRoom(res.room_id);
|
| 1666 |
}
|
|
|
|
| 1730 |
function openRoomDetailsModal(roomId) {
|
| 1731 |
const room = state.rooms[roomId];
|
| 1732 |
if (!room) return;
|
| 1733 |
+
document.getElementById('infoModalName').innerText = room.name || roomId;
|
| 1734 |
document.getElementById('infoModalTopic').innerText = room.topic || 'Без темы';
|
| 1735 |
document.getElementById('infoModalId').value = roomId;
|
| 1736 |
+
|
| 1737 |
+
const avatarEl = document.getElementById('infoModalAvatar');
|
| 1738 |
+
if (room.avatar) avatarEl.innerHTML = `<img src="${room.avatar}">`;
|
| 1739 |
+
else avatarEl.innerText = (room.name[0] || '#').toUpperCase();
|
| 1740 |
+
|
| 1741 |
openModal('roomDetailsModal');
|
| 1742 |
}
|
| 1743 |
|
|
|
|
| 1828 |
return str.replace(/[&<>"']/g, m => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[m]));
|
| 1829 |
}
|
| 1830 |
|
|
|
|
| 1831 |
window.onload = checkSavedSession;
|
| 1832 |
</script>
|
| 1833 |
</body>
|