diff --git a/static/js/chat_sockets.js b/static/js/chat_sockets.js
index 692fe96..f3d5cba 100644
--- a/static/js/chat_sockets.js
+++ b/static/js/chat_sockets.js
@@ -4,17 +4,7 @@
// localStorage.setItem('senderName', senderName);
// }
//
-// chatSocket.onmessage = function (e) {
-// let data = JSON.parse(e.data);
-// console.log('Data:', data);
//
-// if (data.type === 'chat') {
-// let messages = document.getElementById('messages')
-// let cssClass = data.sender === senderName? 'sender' : 'receiver';
-// messages.insertAdjacentHTML('beforeend', `
`)
-// }
// }
// let form = document.getElementById('form')
// form.addEventListener('submit', (e) => {
@@ -42,20 +32,31 @@ chatSocket.onmessage = function (e) {
// chatSocket.onopen = function () {
// console.log("open")
// }
-
-chatSocket.onopen = function(){
- console.log("open")
+function open_socket () {
+ chatSocket.onopen = function(){
+ console.log("open")
+ }
}
+
chatSocket.onclose = function () {
console.log("close")
}
function sendMessageSocket (data) {
//
-
- chatSocket.send(JSON.stringify(data))
+ // open_socket()
+ chatSocket.send(JSON.stringify(data))
// }
}
+chatSocket.onmessage = function (e) {
+ let data = JSON.parse(e.data);
+ console.log('Data:', data);
+ console.log("return")
+ if (data.type === 'chat'){
+ document.querySelector(".container-messages").innerHTML = data.html;
+ document.querySelector(".enter-message-inp").focus()
+ }
+}
\ No newline at end of file