From 9bfa6dfee6d8bc7c61da962b97cc154d27ec77fe Mon Sep 17 00:00:00 2001 From: borissedw Date: Fri, 11 Aug 2023 17:59:41 +0300 Subject: [PATCH] 0.0.107 --- static/js/check_new_messages.js | 52 +++++++++++++++++--------------- static/js/global_js.js | 13 +++++--- static/js/user_profile(boris).js | 3 +- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/static/js/check_new_messages.js b/static/js/check_new_messages.js index 1884f1c..d8e05b2 100644 --- a/static/js/check_new_messages.js +++ b/static/js/check_new_messages.js @@ -139,46 +139,50 @@ function check_new_messages (window,only_sender_mode){ function success_check_new_messages (data) { + let window = document.querySelector(".container-messages") if (window === null){ clearTimeout(check_msg) } else { - if (data.html) { - if (data_new_messages['ticket_id'] !== 'null') { + if (data !== null) { + if (data_new_messages['ticket_id'] && data_new_messages['ticket_id'] !== "null") { if (data.msgs_count > 1) { - if (document.querySelector(".container-messages")){ + if (document.querySelector(".container-messages")) { document.querySelector(".container-messages").innerHTML = data.html; } + else if (data.tickets_list_html){ + if (document.querySelector(".block-list-of-users")) { + document.querySelector(".block-list-of-users").innerHTML = data.tickets_list_html + } + } + } else { document.querySelector(".info_profile").innerHTML = data.html; } - } else { - if (document.querySelector(".container-messages")) { + } - document.querySelector(".container-messages").innerHTML = data.html; + else if (data.chat_html) { + if (document.querySelector(".container-messages")) { + document.querySelector(".container-messages").innerHTML = data.chat_html; + } + if (data.users_list_html){ + if (document.querySelector(".block-list-of-users")) { + document.querySelector(".block-list-of-users").innerHTML = data.users_list_html; + } } } - } - if (data.users_list_html){ - if (document.querySelector(".block-list-of-users")) { - document.querySelector(".block-list-of-users").innerHTML = data.users_list_html; + + + if (data.required_beep === true){ + const beep = new Audio('/static/sounds/beep_2.mp3') + beep.play() + } + + } - } - if (data.required_beep === true){ - const beep = new Audio('/static/sounds/beep_2.mp3') - beep.play() } - if (data.users_list_html){ - if (document.querySelector(".block-list-of-users")) { - document.querySelector(".block-list-of-users").innerHTML = data.users_list_html - } - } - if (data.tickets_list_html){ - if (document.querySelector(".block-list-of-users")) { - document.querySelector(".block-list-of-users").innerHTML = data.tickets_list_html - } - } + // let updatedCookie = encodeURIComponent(name_cookie) + "=" + encodeURIComponent(''); // let search_cookie = document.cookie.match("(^|[^;]+)\s*" + name_cookie + "\s*=\s*([^;]+)")[0].substring(1) // let search_cookie = getCookieValue('user_alerts') diff --git a/static/js/global_js.js b/static/js/global_js.js index 5311260..b5ae68a 100644 --- a/static/js/global_js.js +++ b/static/js/global_js.js @@ -4,17 +4,20 @@ $(document).ready(function (){ function getNewMessageSession(){ let window_messages = document.querySelector(".container-messages") + let new_timeout_time; if (window_messages !== null){ // check_new_messages(window) - if (check_msg !== null){ - clearInterval(check_msg) - } - check_new_messages_timeout(1000) + new_timeout_time = 1000 } else { - check_new_messages(window_messages,true) + new_timeout_time = 60000 } + if (check_msg !== null){ + clearInterval(check_msg) + } + check_new_messages_timeout(new_timeout_time) } + // var window_messages = document.querySelector(".container-messages") // function getNewMessageSession (){ diff --git a/static/js/user_profile(boris).js b/static/js/user_profile(boris).js index ea740bf..f5e4f3c 100644 --- a/static/js/user_profile(boris).js +++ b/static/js/user_profile(boris).js @@ -201,6 +201,7 @@ function sendMessage(id_ticket=null,sender,receiver){ event.preventDefault() let text = document.querySelector(".enter-message-inp").value + document.querySelector(".enter-message-inp").value = null if (text.length === 0){ // @@ -238,14 +239,12 @@ function sendMessage(id_ticket=null,sender,receiver){ getNewMessageSession() document.querySelector(".container-messages").innerHTML = data.html; - document.querySelector(".enter-message-inp").value = null document.querySelector(".enter-message-inp").focus() }, error: function (data){ document.querySelector(".container-messages").innerHTML = data.responseJSON.error; - document.querySelector(".enter-message-inp").value = null document.querySelector(".enter-message-inp").focus() } });