0.0.154
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
export function update_count_unread_messages (data) {
|
||||
function update_count_unread_messages (data) {
|
||||
let list_unrd = document.querySelectorAll(".qs")
|
||||
let i = 0
|
||||
for (i;i < list_unrd.length;i++){
|
||||
@@ -7,7 +7,7 @@ export function update_count_unread_messages (data) {
|
||||
}
|
||||
}
|
||||
|
||||
export function play_required_beep (data) {
|
||||
function play_required_beep (data) {
|
||||
const beep = new Audio('/static/sounds/beep_2.mp3')
|
||||
beep.play()
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
export function inital_old_tab (){
|
||||
function inital_old_tab (){
|
||||
let el_tab = document.querySelector(".tab_user_messanger.select")
|
||||
let old_item_tab_user = null;
|
||||
if (el_tab !== null){
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
export function update_chat_html (data,msg_cont) {
|
||||
function update_chat_html (data,msg_cont) {
|
||||
if (data.chat_html){
|
||||
if (msg_cont !== null){
|
||||
if (msg_cont.dataset['curReceiver'] === ""){
|
||||
@@ -16,7 +16,7 @@ export function update_chat_html (data,msg_cont) {
|
||||
}
|
||||
|
||||
|
||||
export function update_list_w_users (data,old_item_tab_user) {
|
||||
function update_list_w_users (data,old_item_tab_user) {
|
||||
let list_of_users = document.querySelector(".block-list-of-users")
|
||||
if (list_of_users) {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
export function update_tickets_operations_manager (data,old_item_tab_user,w=null,wo=null) {
|
||||
function update_tickets_operations_manager (data,old_item_tab_user,w=null,wo=null) {
|
||||
let insert_type = null
|
||||
if (w !== null){
|
||||
insert_type = 'data.tickets_w_manager_html'
|
||||
@@ -70,7 +70,7 @@ function clear_messenger (data) {
|
||||
}
|
||||
}
|
||||
|
||||
export function update_support_chat_func (data){
|
||||
function update_support_chat_func (data){
|
||||
if (msg_cont !== null){
|
||||
if (msg_cont.dataset['curReceiver'] === ""){
|
||||
document.querySelector(".info_profile").innerHTML = data.support_chat_html
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
|
||||
// let senderName = localStorage.getItem('senderName');
|
||||
// if (!senderName) {
|
||||
// localStorage.setItem('senderName', senderName);
|
||||
@@ -40,15 +40,24 @@
|
||||
// }
|
||||
|
||||
// var i = 0
|
||||
$.import_js('/chat_socket_functions/inital_old_tab.js');
|
||||
// import "chat_socket_functions/inital_old_tab.js"
|
||||
import "chat_socket_functions/etc_operations_for_chat_socket.js"
|
||||
import "chat_socket_functions/update_messenger.js"
|
||||
import "chat_socket_functions/update_tickets_operations_manager.js"
|
||||
//
|
||||
const chatSocket = new WebSocket(ws_url);
|
||||
|
||||
|
||||
// $.import_js('/chat_socket_functions/inital_old_tab.js');
|
||||
// $.import_js('/chat_socket_functions/etc_operations_for_chat_socket.js');
|
||||
// $.import_js('/chat_socket_functions/update_messenger.js');
|
||||
// $.import_js('/chat_socket_functions/update_tickets_operations_manager.js');
|
||||
// import "chat_socket_functions/etc_operations_for_chat_socket.js"
|
||||
// import "chat_socket_functions/update_messenger.js"
|
||||
// import "chat_socket_functions/update_tickets_operations_manager.js"
|
||||
//
|
||||
|
||||
// import { update_chat_html, update_list_w_users } from "./chat_socket_functions/update_messenger.js";
|
||||
// import { update_support_chat_func, update_tickets_operations_manager } from "./chat_socket_functions/update_tickets_operations_manager.js";
|
||||
// import { play_required_beep, update_count_unread_messages } from "./chat_socket_functions/etc_operations_for_chat_socket.js";
|
||||
// import { inital_old_tab } from "./chat_socket_functions/inital_old_tab.js";
|
||||
|
||||
const chatSocket = new WebSocket(ws_url);
|
||||
|
||||
function sendMessageSocket (data) {
|
||||
chatSocket.send(JSON.stringify(data));
|
||||
if (!data.ticket_id){
|
||||
@@ -60,8 +69,12 @@ function sendMessageSocket (data) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
chatSocket.onmessage = function (e) {
|
||||
inital_old_tab()
|
||||
|
||||
let old_item_tab_user = inital_old_tab()
|
||||
let data = JSON.parse(e.data);
|
||||
console.log('Data:', data);
|
||||
console.log("return")
|
||||
@@ -100,6 +113,150 @@ chatSocket.onmessage = function (e) {
|
||||
|
||||
|
||||
|
||||
function update_tickets_operations_manager (data,old_item_tab_user,w=null,wo=null) {
|
||||
let insert_type = null
|
||||
if (w !== null){
|
||||
insert_type = 'data.tickets_w_manager_html'
|
||||
} else if (wo !== null){
|
||||
insert_type = 'data.tickets_wo_manager_html'
|
||||
}
|
||||
if (insert_type) {
|
||||
if (document.querySelector(".list_linked_tickets") !== null || document.querySelector(".list_unlinked_tickets") !== null) {
|
||||
document.querySelector(".list_unlinked_tickets").innerHTML = insert_type
|
||||
// if (el_tab !== null) {
|
||||
// let select_tab = document.querySelector(".tab_user_messanger.select")
|
||||
// if (select_tab) {
|
||||
// select_tab.classList.remove("select")
|
||||
// }
|
||||
// let old_insert_tab = document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]`)
|
||||
// if (old_insert_tab) {
|
||||
// old_insert_tab.classList.add("select")
|
||||
// old_insert_tab.scrollIntoView({behavior: "smooth"});
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// let container_messenger = document.querySelector(".container-messages")
|
||||
// if (container_messenger){
|
||||
// let dataset_cont_mes = container_messenger.dataset
|
||||
// if (dataset_cont_mes){
|
||||
// let ticket_id = dataset_cont_mes["ticketId"]
|
||||
// if (ticket_id !== ""){
|
||||
// let ticket = document.querySelector(`[data-cur-receiver-item="${ticket_id}"]`)
|
||||
// if (ticket === null){
|
||||
// let chat = document.querySelector(".block-chat").innerHTML = ""
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
select_and_scroll_to_ticket(data,old_item_tab_user)
|
||||
clear_messenger(data)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// function select_and_scroll_to_ticket (data,old_item_tab_user){
|
||||
// if (el_tab !== null){
|
||||
// document.querySelector(".tab_user_messanger.select").classList.remove("select")
|
||||
// let old_insert_tab = document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]`)
|
||||
// if (old_insert_tab) {
|
||||
// old_insert_tab.classList.add("select")
|
||||
// old_insert_tab.scrollIntoView({behavior: "smooth"});
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// function clear_messenger (data) {
|
||||
// let container_messenger = document.querySelector(".container-messages")
|
||||
// if (container_messenger){
|
||||
// let dataset_cont_mes = container_messenger.dataset
|
||||
// if (dataset_cont_mes){
|
||||
// let ticket_id = dataset_cont_mes["ticketId"]
|
||||
// if (ticket_id !== ""){
|
||||
// let ticket = document.querySelector(`[data-cur-receiver-item="${ticket_id}"]`)
|
||||
// if (ticket === null){
|
||||
// let chat = document.querySelector(".block-chat").innerHTML = ""
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// function update_support_chat_func (data){
|
||||
// if (msg_cont !== null){
|
||||
// if (msg_cont.dataset['curReceiver'] === ""){
|
||||
// document.querySelector(".info_profile").innerHTML = data.support_chat_html
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// function update_chat_html (data,msg_cont) {
|
||||
// if (data.chat_html){
|
||||
// if (msg_cont !== null){
|
||||
// if (msg_cont.dataset['curReceiver'] === ""){
|
||||
// document.querySelector(".fotter-chat")
|
||||
// msg_cont.innerHTML = data.chat_html
|
||||
// } else {
|
||||
// // что бы не выводился левый чат
|
||||
// if (msg_cont.dataset['curReceiver'] === data['sender'].toString() || msg_cont.dataset['curReceiver'] === data['receiver'].toString()) {
|
||||
// msg_cont.innerHTML = data.chat_html
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// function update_list_w_users (data,old_item_tab_user) {
|
||||
// let list_of_users = document.querySelector(".block-list-of-users")
|
||||
// if (list_of_users) {
|
||||
//
|
||||
// if (data.users_list_html){
|
||||
// list_of_users.innerHTML = data.users_list_html
|
||||
// if (el_tab !== null){
|
||||
// document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]` ).classList.add("select")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// function inital_old_tab (){
|
||||
// let el_tab = document.querySelector(".tab_user_messanger.select")
|
||||
// let old_item_tab_user = null;
|
||||
// if (el_tab !== null){
|
||||
// let dataset = el_tab.dataset;
|
||||
// old_item_tab_user = dataset['curReceiverItem'];
|
||||
// }
|
||||
// return old_item_tab_user
|
||||
// }
|
||||
//
|
||||
//
|
||||
// function update_count_unread_messages (data) {
|
||||
// let list_unrd = document.querySelectorAll(".qs")
|
||||
// let i = 0
|
||||
// for (i;i < list_unrd.length;i++){
|
||||
// list_unrd[i].innerHTML = data.unread_msgs_count.toString()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// function play_required_beep (data) {
|
||||
// const beep = new Audio('/static/sounds/beep_2.mp3')
|
||||
// beep.play()
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
//end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// function update_tickets_w_manager (data,old_item_tab_user){
|
||||
// if (data.tickets_w_manager_html) {
|
||||
// if (document.querySelector(".list_linked_tickets") !== null || document.querySelector(".list_unlinked_tickets") !== null) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
function createTicketShow () {
|
||||
$.ajax({
|
||||
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||||
@@ -199,12 +201,19 @@ function selectedUserMessenger (ticket_id=null,user_id=null){
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function sendMessage(id_ticket=null,sender,receiver){
|
||||
// import {sendMessageSocket} from "./chat_sockets";
|
||||
|
||||
event.preventDefault()
|
||||
|
||||
let text = document.querySelector(".enter-message-inp").value
|
||||
document.querySelector(".enter-message-inp").value = null
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (text.length === 0){
|
||||
//
|
||||
}
|
||||
@@ -250,6 +259,7 @@ function sendMessage(id_ticket=null,sender,receiver){
|
||||
// document.querySelector(".enter-message-inp").focus()
|
||||
// }
|
||||
// });
|
||||
|
||||
sendMessageSocket(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,18 @@
|
||||
<script src='{% static "js/ion.rangeSlider.min.js" %}'> </script>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet">
|
||||
<script src='{% static "js/user_profile.js" %}'> </script>
|
||||
<script src='{% static "js/user_profile(boris).js" %}'> </script>
|
||||
|
||||
{# <script src='{% static "js/chat_sockets.js" %}'></script>#}
|
||||
|
||||
<script type="module" src="{% static "js/chat_socket_functions/etc_operations_for_chat_socket.js" %}"></script>
|
||||
<script type="module" src="{% static "js/chat_socket_functions/inital_old_tab.js" %}"></script>
|
||||
<script type="module" src="{% static "js/chat_socket_functions/update_messenger.js" %}"></script>
|
||||
<script type="module" src="{% static "js/chat_socket_functions/update_tickets_operations_manager.js" %}"></script>
|
||||
<link rel="stylesheet" href="{% static 'css/ion.rangeSlider.min.css' %}">
|
||||
|
||||
<script src="{% static "js/chat_socket_functions/etc_operations_for_chat_socket.js" %}"></script>
|
||||
<script src="{% static "js/chat_socket_functions/inital_old_tab.js" %}"></script>
|
||||
<script src="{% static "js/chat_socket_functions/update_messenger.js" %}"></script>
|
||||
<script src="{% static "js/chat_socket_functions/update_tickets_operations_manager.js" %}"></script>
|
||||
<link rel="stylesheet" href="{% static 'css/ion.rangeSlider.min.css' %}">
|
||||
<script src='{% static "js/user_profile(boris).js" %}'> </script>
|
||||
<script src='{% static "js/chat_sockets.js" %}'> </script>
|
||||
|
||||
<script defer src='{% static "js/check_new_messages.js" %}'></script>
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
</script>
|
||||
|
||||
<script type="module" src='{% static "js/chat_sockets.js" %}'></script>
|
||||
<script src='{% static "js/chat_sockets.js" %}'></script>
|
||||
|
||||
|
||||
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
|
||||
|
||||
Reference in New Issue
Block a user