From 10e38edab8022942b7daf0dd9c8b63ee8439a6de Mon Sep 17 00:00:00 2001 From: borissedw Date: Sun, 10 Sep 2023 19:02:11 +0300 Subject: [PATCH] 0.0.237 --- static/js/user_profile(boris).js | 124 ++++++++++++------- templates/blocks/profile/b_support_chat.html | 2 +- 2 files changed, 77 insertions(+), 49 deletions(-) diff --git a/static/js/user_profile(boris).js b/static/js/user_profile(boris).js index c433748..b76372c 100644 --- a/static/js/user_profile(boris).js +++ b/static/js/user_profile(boris).js @@ -74,7 +74,7 @@ function attachFileCreateTicket () { } -function attachFilemeassge (el) { +function attachFilemeassge (el,id_ticket=null,sender,receiver) { let input = inputQuest() let file = input.files[0] let int = setInterval(function (){ @@ -90,10 +90,12 @@ function attachFilemeassge (el) { el.dataset['file_img'] = data input.remove() clearInterval(int) + sendMessage(id_ticket,sender,receiver,'pst_img') } },1000) + } function createTicket (el) { @@ -169,67 +171,93 @@ function selectedUserMessenger (ticket_id=null,user_id=null){ } -function sendMessage(id_ticket=null,sender,receiver){ +function sendMessage(id_ticket=null,sender,receiver,img_post=null){ // import {sendMessageSocket} from "./chat_sockets"; - - event.preventDefault() - + if (!img_post){ + event.preventDefault() + } let text = document.querySelector(".enter-message-inp").value document.querySelector(".enter-message-inp").value = null let img = document.querySelector(".attach-file-btn-message").dataset["file_img"] + if (img_post){ - - if (text.length === 0){ - // - } - else { let data = {} - if (id_ticket === null){ - data = { - 'sender': sender, - 'receiver': receiver, - 'text': text, - 'img': img + if (id_ticket === null){ + data = { + 'sender': sender, + 'receiver': receiver, + 'text': '', + 'img': img + } + } else { + data = { + 'ticket_id': id_ticket, + 'sender': sender, + 'receiver': receiver, + 'text': '', + 'img': img + } } - } else { - data = { - 'ticket_id': id_ticket, - 'sender': sender, - 'receiver': receiver, - 'text': text, - 'img': img - } - } - // $.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){ - // middleWareJS() - // - // 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) + + } else { + + if (text.length === 0){ + // + } + else { + let data = {} + if (id_ticket === null){ + data = { + 'sender': sender, + 'receiver': receiver, + 'text': text, + 'img': img + } + } else { + data = { + 'ticket_id': id_ticket, + 'sender': sender, + 'receiver': receiver, + 'text': text, + 'img': img + } + } + + + + // $.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){ + // middleWareJS() + // + // 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) + } } } diff --git a/templates/blocks/profile/b_support_chat.html b/templates/blocks/profile/b_support_chat.html index af5bb5f..9ff0713 100644 --- a/templates/blocks/profile/b_support_chat.html +++ b/templates/blocks/profile/b_support_chat.html @@ -52,7 +52,7 @@
- +