DmitrMakeev commited on
Commit
f7b3b67
·
verified ·
1 Parent(s): 0e82141

Update chat.html

Browse files
Files changed (1) hide show
  1. chat.html +4 -12
chat.html CHANGED
@@ -18,10 +18,12 @@
18
  display: flex;
19
  justify-content: center;
20
  align-items: center;
 
21
  }
22
 
23
  .chat-container {
24
- width: 400px;
 
25
  height: 600px;
26
  background: white;
27
  border-radius: 15px;
@@ -121,7 +123,6 @@
121
  font-size: 0.9em;
122
  }
123
 
124
- /* Стили для скроллбара */
125
  .messages-container::-webkit-scrollbar {
126
  width: 6px;
127
  }
@@ -176,10 +177,8 @@
176
  }
177
 
178
  init() {
179
- // Загружаем историю сообщений при загрузке
180
  this.loadMessages();
181
 
182
- // Настраиваем обработчики событий
183
  this.sendButton.addEventListener('click', () => this.sendMessage());
184
  this.messageInput.addEventListener('keypress', (e) => {
185
  if (e.key === 'Enter') {
@@ -187,10 +186,7 @@
187
  }
188
  });
189
 
190
- // Обновляем сообщения каждые 2 секунды
191
  setInterval(() => this.loadNewMessages(), 2000);
192
-
193
- // Автофокус на поле ввода
194
  this.messageInput.focus();
195
  }
196
 
@@ -199,7 +195,6 @@
199
 
200
  if (!message) return;
201
 
202
- // Блокируем кнопку во время отправки
203
  this.sendButton.disabled = true;
204
  this.sendButton.textContent = 'Отправка...';
205
 
@@ -219,7 +214,7 @@
219
 
220
  if (result.status === 'success') {
221
  this.messageInput.value = '';
222
- this.loadNewMessages(); // Обновляем сообщения сразу после отправки
223
  } else {
224
  alert('Ошибка отправки: ' + result.message);
225
  }
@@ -260,10 +255,8 @@
260
 
261
  displayMessages(messages, clear = true) {
262
  if (clear) {
263
- // Убираем приветственное сообщение
264
  const welcomeMsg = document.getElementById('welcome-message');
265
  if (welcomeMsg) welcomeMsg.remove();
266
-
267
  this.messagesContainer.innerHTML = '';
268
  }
269
 
@@ -297,7 +290,6 @@
297
  }
298
  }
299
 
300
- // Инициализация чата после загрузки страницы
301
  document.addEventListener('DOMContentLoaded', () => {
302
  new Chat();
303
  });
 
18
  display: flex;
19
  justify-content: center;
20
  align-items: center;
21
+ padding: 20px;
22
  }
23
 
24
  .chat-container {
25
+ width: 100%;
26
+ max-width: 400px;
27
  height: 600px;
28
  background: white;
29
  border-radius: 15px;
 
123
  font-size: 0.9em;
124
  }
125
 
 
126
  .messages-container::-webkit-scrollbar {
127
  width: 6px;
128
  }
 
177
  }
178
 
179
  init() {
 
180
  this.loadMessages();
181
 
 
182
  this.sendButton.addEventListener('click', () => this.sendMessage());
183
  this.messageInput.addEventListener('keypress', (e) => {
184
  if (e.key === 'Enter') {
 
186
  }
187
  });
188
 
 
189
  setInterval(() => this.loadNewMessages(), 2000);
 
 
190
  this.messageInput.focus();
191
  }
192
 
 
195
 
196
  if (!message) return;
197
 
 
198
  this.sendButton.disabled = true;
199
  this.sendButton.textContent = 'Отправка...';
200
 
 
214
 
215
  if (result.status === 'success') {
216
  this.messageInput.value = '';
217
+ this.loadNewMessages();
218
  } else {
219
  alert('Ошибка отправки: ' + result.message);
220
  }
 
255
 
256
  displayMessages(messages, clear = true) {
257
  if (clear) {
 
258
  const welcomeMsg = document.getElementById('welcome-message');
259
  if (welcomeMsg) welcomeMsg.remove();
 
260
  this.messagesContainer.innerHTML = '';
261
  }
262
 
 
290
  }
291
  }
292
 
 
293
  document.addEventListener('DOMContentLoaded', () => {
294
  new Chat();
295
  });