|
|
|
@ -1,6 +1,4 @@
|
|
|
|
|
const chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
|
|
|
|
|
const protocol = window.location.protocol === "https:" ? "https" : "http";
|
|
|
|
|
const domain = "osina.ositcom.com";
|
|
|
|
|
|
|
|
|
|
let osichatSocket;
|
|
|
|
|
let isOpen = false;
|
|
|
|
|
let chatLoaded = false;
|
|
|
|
@ -88,7 +86,7 @@ async function fetchSessionID() {
|
|
|
|
|
let session_id = 'Unknown';
|
|
|
|
|
while (session_id === 'Unknown') {
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch('https://ositcom.com/get-client-session/');
|
|
|
|
|
const response = await fetch(`${protocol}://${ositcomDomain}/get-client-session/`);
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
if (data.session_id) {
|
|
|
|
|
session_id = data.session_id;
|
|
|
|
@ -164,10 +162,10 @@ function handleLoadChatEvent(data, osichatSocket) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!document.querySelector(`script[src="${protocol}://${domain}/static/js/osichat/chat-toggle.js"]`)) {
|
|
|
|
|
if (!document.querySelector(`script[src="${protocol}://${osinaDomain}/static/js/osichat/chat-toggle.js"]`)) {
|
|
|
|
|
const script = document.createElement('script');
|
|
|
|
|
script.type = 'text/javascript';
|
|
|
|
|
script.src = `${protocol}://${domain}/static/js/osichat/chat-toggle.js`;
|
|
|
|
|
script.src = `${protocol}://${osinaDomain}/static/js/osichat/chat-toggle.js`;
|
|
|
|
|
chatDiv.appendChild(script);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -178,17 +176,17 @@ function handleLoadChatEvent(data, osichatSocket) {
|
|
|
|
|
|
|
|
|
|
const sendMessageContainer = document.getElementById('sendMessage'); //Case where returned is chat-room.html
|
|
|
|
|
if (sendMessageContainer) {
|
|
|
|
|
appendTextAreaScript(domain, chatDiv);
|
|
|
|
|
appendTextAreaScript(osinaDomain, chatDiv);
|
|
|
|
|
handleFormSubmission(sendMessageContainer, 'send_message', osichatSocket);
|
|
|
|
|
|
|
|
|
|
const uploadScript = document.createElement('script');
|
|
|
|
|
uploadScript.type = 'text/javascript';
|
|
|
|
|
uploadScript.src = `${protocol}://${domain}/static/js/osichat/upload-file.js`;
|
|
|
|
|
uploadScript.src = `${protocol}://${osinaDomain}/static/js/osichat/upload-file.js`;
|
|
|
|
|
chatDiv.appendChild(uploadScript);
|
|
|
|
|
|
|
|
|
|
const endChatScript = document.createElement('script');
|
|
|
|
|
endChatScript.type = 'text/javascript';
|
|
|
|
|
endChatScript.src = `${protocol}://${domain}/static/js/osichat/end-chat.js`;
|
|
|
|
|
endChatScript.src = `${protocol}://${osinaDomain}/static/js/osichat/end-chat.js`;
|
|
|
|
|
chatDiv.appendChild(endChatScript);
|
|
|
|
|
|
|
|
|
|
const endChatButton = document.getElementById('endChat');
|
|
|
|
@ -199,7 +197,7 @@ function handleLoadChatEvent(data, osichatSocket) {
|
|
|
|
|
if (sendReviewContainer) {
|
|
|
|
|
const sendReviewScript = document.createElement('script');
|
|
|
|
|
sendReviewScript.type = 'text/javascript';
|
|
|
|
|
sendReviewScript.src = `${protocol}://${domain}/static/js/osichat/send-review.js`;
|
|
|
|
|
sendReviewScript.src = `${protocol}://${osinaDomain}/static/js/osichat/send-review.js`;
|
|
|
|
|
chatDiv.appendChild(sendReviewScript);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -208,7 +206,7 @@ function handleLoadChatEvent(data, osichatSocket) {
|
|
|
|
|
// FUNCTION TO INITIALIZE WEB SOCKET CONNECTION
|
|
|
|
|
async function initializeChatWebSocket() {
|
|
|
|
|
const session_id = await fetchSessionID();
|
|
|
|
|
let osichatSocketUrl = `${chat_ws_scheme}://${domain}/ws/osichat/${session_id}/`;
|
|
|
|
|
let osichatSocketUrl = `${wsScheme}://${osinaDomain}/ws/osichat/${session_id}/`;
|
|
|
|
|
osichatSocket = new WebSocket(osichatSocketUrl);
|
|
|
|
|
|
|
|
|
|
osichatSocket.onopen = () => {
|
|
|
|
@ -289,7 +287,7 @@ async function initializeChatWebSocket() {
|
|
|
|
|
unreadMessages.classList.remove('hidden');
|
|
|
|
|
unreadMessages.innerHTML = data.html;
|
|
|
|
|
const script = document.createElement('script');
|
|
|
|
|
script.src = `${protocol}://${domain}/static/js/osichat/chat-toggle.js`;
|
|
|
|
|
script.src = `${protocol}://${osinaDomain}/static/js/osichat/chat-toggle.js`;
|
|
|
|
|
document.body.appendChild(script);
|
|
|
|
|
} else {
|
|
|
|
|
unreadMessages.classList.add('hidden');
|
|
|
|
@ -305,7 +303,7 @@ async function initializeChatWebSocket() {
|
|
|
|
|
document.getElementById(`endChat`).classList.add('hidden');
|
|
|
|
|
const sendReviewScript = document.createElement('script');
|
|
|
|
|
sendReviewScript.type = 'text/javascript';
|
|
|
|
|
sendReviewScript.src = `${protocol}://${domain}/static/js/osichat/send-review.js`;
|
|
|
|
|
sendReviewScript.src = `${protocol}://${osinaDomain}/static/js/osichat/send-review.js`;
|
|
|
|
|
currentChat.appendChild(sendReviewScript);
|
|
|
|
|
break;
|
|
|
|
|
case 'submit_review':
|
|
|
|
@ -315,7 +313,7 @@ async function initializeChatWebSocket() {
|
|
|
|
|
}
|
|
|
|
|
const reviewScript = document.createElement('script');
|
|
|
|
|
reviewScript.type = 'text/javascript';
|
|
|
|
|
reviewScript.src = `${protocol}://${domain}/static/js/osichat/send-review.js`;
|
|
|
|
|
reviewScript.src = `${protocol}://${osinaDomain}/static/js/osichat/send-review.js`;
|
|
|
|
|
submitReview.appendChild(reviewScript);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|