From 812b27ca93356f38d1bc9494433d52d824dd6421 Mon Sep 17 00:00:00 2001 From: borissedw Date: Wed, 9 Aug 2023 19:17:11 +0300 Subject: [PATCH] 0.0.99 --- static/js/check_new_messages.js | 11 +++++++--- static/js/global_js.js | 35 ++++++++++++++++++++++++-------- static/js/user_profile(boris).js | 2 +- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/static/js/check_new_messages.js b/static/js/check_new_messages.js index f76c39d..f9dfee2 100644 --- a/static/js/check_new_messages.js +++ b/static/js/check_new_messages.js @@ -30,7 +30,7 @@ function check_new_messages_timeout(){ check_new_messages(window,it) } }, - 1000) + 60000) } @@ -110,8 +110,13 @@ function success_check_new_messages (data) { beep.play() } - - // document.cookie = old_cookeis + name_delete + 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') + // document.cookie = document.cookie.replace(search_cookie,name_cookie + "=") + document.cookie = updatedCookie + // document.cookie = document.cookie.slice(0,-26) + // document.cookie = document.cookie.replace('user_alerts="{\"new_message\": true}"','user_alerts=;') } function userOnline (set=null,check=null) { diff --git a/static/js/global_js.js b/static/js/global_js.js index 1605409..8b34349 100644 --- a/static/js/global_js.js +++ b/static/js/global_js.js @@ -4,24 +4,41 @@ $(document).ready(function (){ function getNewMessageSession (){ let prs_ = null - let r = getCookieValue('user_alerts') - if (r !== undefined && r !== null && r !== ""){ + if (r !== 'undefined' && r !== null && r !== ""){ let prs = JSON.parse(r) prs_ = JSON.parse(r) } else { - // + // } + let r = getCookieValue('user_alerts') return prs_; } -var old_cookeis = document.cookie -var name_delete = null +var res_cookie = null +var name_cookie = null -function getCookieValue(name) { - let result = document.cookie.match("(^|[^;]+)\s*" + name + "\s*=\s*([^;]+)") - return result ? result.pop() : "" - name_delete = name +// var old_cookeis = document.cookie +// var name_delete = null + +function getCookieValue(name_1) { + name_cookie = name_1 + let cur_state = document.cookie; + + let finded_str = ''; + let cur_state_by_opts = cur_state.split('; '); + for (let i=0; i= 0) { + finded_str = cur_state_by_opts[i]; + delete cur_state_by_opts[i]; + } + } + let save_str = cur_state_by_opts.join('; '); + + let result = document.cookie.match("(^|[^;]+)\s*" + name_1 + "\s*=\s*([^;]+)") + res_cookie = result ? result.pop() : "" + return res_cookie + // name_delete = name } \ No newline at end of file diff --git a/static/js/user_profile(boris).js b/static/js/user_profile(boris).js index 58145ee..fb57192 100644 --- a/static/js/user_profile(boris).js +++ b/static/js/user_profile(boris).js @@ -224,7 +224,7 @@ function sendMessage(id_ticket=null,sender,receiver){ // enctype: 'json', data: JSON.stringify(data), success: function(data){ - getNewMessageSession() + getNewMessageSession() document.querySelector(".container-messages").innerHTML = data.html; document.querySelector(".enter-message-inp").value = null