From 1d64583697ff806ea8e4f8cd2be2ab9c1c3a0d83 Mon Sep 17 00:00:00 2001 From: borissedw Date: Sat, 12 Aug 2023 13:14:26 +0300 Subject: [PATCH] 0.0.117 --- static/js/chat_sockets.js | 16 ++++++++--- static/js/check_new_messages.js | 4 +-- static/js/user_profile(boris).js | 47 ++++++++++++++++---------------- 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/static/js/chat_sockets.js b/static/js/chat_sockets.js index 24e8fdf..692fe96 100644 --- a/static/js/chat_sockets.js +++ b/static/js/chat_sockets.js @@ -43,11 +43,19 @@ chatSocket.onmessage = function (e) { // console.log("open") // } +chatSocket.onopen = function(){ + console.log("open") +} + chatSocket.onclose = function () { console.log("close") } -chatSocket.onopen = function(){ - console.log("open") - chatSocket.send('A'); -} \ No newline at end of file +function sendMessageSocket (data) { + // + + chatSocket.send(JSON.stringify(data)) + // } +} + + diff --git a/static/js/check_new_messages.js b/static/js/check_new_messages.js index 2d5876e..19da4fd 100644 --- a/static/js/check_new_messages.js +++ b/static/js/check_new_messages.js @@ -34,7 +34,7 @@ // // check_new_messages_timeout(60000,it_set_func,it_func) // // } // -// function check_new_messages_timeout(timeout_time=short_timeout){ +function check_new_messages_timeout(timeout_time=1000){ // if (check_msg){ // clearInterval(check_msg) // } @@ -77,7 +77,7 @@ // // }, // timeout_time) -// } +} // // // diff --git a/static/js/user_profile(boris).js b/static/js/user_profile(boris).js index f5e4f3c..771a414 100644 --- a/static/js/user_profile(boris).js +++ b/static/js/user_profile(boris).js @@ -225,29 +225,30 @@ function sendMessage(id_ticket=null,sender,receiver){ - $.ajax({ - headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, - url: '/ru/messages/send_msg/', - type: "POST", - // async: true, - cache: false, - processData: false, - contentType: false, - // enctype: 'json', - data: JSON.stringify(data), - success: function(data){ - getNewMessageSession() - - document.querySelector(".container-messages").innerHTML = data.html; - document.querySelector(".enter-message-inp").focus() - - }, - error: function (data){ - - document.querySelector(".container-messages").innerHTML = data.responseJSON.error; - document.querySelector(".enter-message-inp").focus() - } - }); + // $.ajax({ + // headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, + // url: '/ru/messages/send_msg/', + // type: "POST", + // // async: true, + // cache: false, + // processData: false, + // contentType: false, + // // enctype: 'json', + // data: JSON.stringify(data), + // success: function(data){ + // getNewMessageSession() + // + // document.querySelector(".container-messages").innerHTML = data.html; + // document.querySelector(".enter-message-inp").focus() + // + // }, + // error: function (data){ + // + // document.querySelector(".container-messages").innerHTML = data.responseJSON.error; + // document.querySelector(".enter-message-inp").focus() + // } + // }); + sendMessageSocket(data) } }