From d1c133309b9d32f9cba43a8303cca38cf60cf061 Mon Sep 17 00:00:00 2001 From: borissedw Date: Mon, 7 Aug 2023 17:12:21 +0300 Subject: [PATCH] 0.0.56 --- static/js/check_new_messages.js | 36 +++++++++++++++++++ templates/blocks/profile/b_chats.html | 9 +++-- .../blocks/profile/b_messages_container.html | 7 +++- templates/blocks/profile/b_new_route.html | 2 +- templates/widgets/w_message.html | 2 ++ 5 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 static/js/check_new_messages.js diff --git a/static/js/check_new_messages.js b/static/js/check_new_messages.js new file mode 100644 index 0000000..a81ff24 --- /dev/null +++ b/static/js/check_new_messages.js @@ -0,0 +1,36 @@ +var user_online = true + +function check_new_messages (sender,receiver,ticket_id=null){ + // let user_online_check = document.addEventListener("mouseover"); + let data = { + 'sender':sender, + 'receiver':receiver, + 'ticket_id':ticket_id + } + + $.ajax({ + headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, + url: '/ru/messages/update_chat/', + type: "POST", + // async: true, + cache: false, + processData: false, + contentType: false, + // enctype: 'json', + data: JSON.stringify(data), + success: function(data){ + + if (data.msgs_count > 1){ + document.querySelector(".container-messages").innerHTML = data.html; + } else { + document.querySelector(".info_profile").innerHTML = data.html; + } + + }, + error: function (data){ + + document.querySelector(".info_profile").innerHTML = data.responseJSON.html; + + } + }); +} \ No newline at end of file diff --git a/templates/blocks/profile/b_chats.html b/templates/blocks/profile/b_chats.html index ac821e3..5308a67 100644 --- a/templates/blocks/profile/b_chats.html +++ b/templates/blocks/profile/b_chats.html @@ -38,7 +38,7 @@ {##} -
+
@@ -50,10 +50,11 @@
-
+
{% include "blocks/profile/b_messages_container.html" %}
+ \ No newline at end of file +
+ + \ No newline at end of file diff --git a/templates/blocks/profile/b_messages_container.html b/templates/blocks/profile/b_messages_container.html index 656bbf2..7498981 100644 --- a/templates/blocks/profile/b_messages_container.html +++ b/templates/blocks/profile/b_messages_container.html @@ -7,5 +7,10 @@ {% else %} {% for msg in messages %} {% include "widgets/w_message.html" %} + {% if forloop.last %} + + {% endif %} {% endfor %} -{% endif %} \ No newline at end of file +{% endif %} + + diff --git a/templates/blocks/profile/b_new_route.html b/templates/blocks/profile/b_new_route.html index 0232bb1..1002853 100644 --- a/templates/blocks/profile/b_new_route.html +++ b/templates/blocks/profile/b_new_route.html @@ -185,7 +185,7 @@ {% for item in form.fields.cargo_type.choices %}
+ + {#
#} {#
#} {# #}