diff --git a/osinaweb/static/images/uploaded_chat_files/220805-domestic-cat-mjf-1540-382ba2.webp b/osinaweb/static/images/uploaded_chat_files/220805-domestic-cat-mjf-1540-382ba2.webp
new file mode 100644
index 00000000..ef1aadcb
Binary files /dev/null and b/osinaweb/static/images/uploaded_chat_files/220805-domestic-cat-mjf-1540-382ba2.webp differ
diff --git a/osinaweb/static/images/uploaded_chat_files/B6A6B86D-1FA3-44E4-B9B4-FA1B5CC58B27.jpeg b/osinaweb/static/images/uploaded_chat_files/B6A6B86D-1FA3-44E4-B9B4-FA1B5CC58B27.jpeg
new file mode 100644
index 00000000..16850ee6
Binary files /dev/null and b/osinaweb/static/images/uploaded_chat_files/B6A6B86D-1FA3-44E4-B9B4-FA1B5CC58B27.jpeg differ
diff --git a/osinaweb/static/images/uploaded_chat_files/B6A6B86D-1FA3-44E4-B9B4-FA1B5CC58B27_1.jpeg b/osinaweb/static/images/uploaded_chat_files/B6A6B86D-1FA3-44E4-B9B4-FA1B5CC58B27_1.jpeg
new file mode 100644
index 00000000..16850ee6
Binary files /dev/null and b/osinaweb/static/images/uploaded_chat_files/B6A6B86D-1FA3-44E4-B9B4-FA1B5CC58B27_1.jpeg differ
diff --git a/osinaweb/static/images/uploaded_chat_files/IMG_3213.png b/osinaweb/static/images/uploaded_chat_files/IMG_3213.png
new file mode 100644
index 00000000..32975ad8
Binary files /dev/null and b/osinaweb/static/images/uploaded_chat_files/IMG_3213.png differ
diff --git a/osinaweb/static/images/uploaded_chat_files/image_picker_1F6A2A43-B2BE-4933-AC42-062F7FE98568-22414-000000929F8DB7FB.jpg b/osinaweb/static/images/uploaded_chat_files/image_picker_1F6A2A43-B2BE-4933-AC42-062F7FE98568-22414-000000929F8DB7FB.jpg
new file mode 100644
index 00000000..355bb998
Binary files /dev/null and b/osinaweb/static/images/uploaded_chat_files/image_picker_1F6A2A43-B2BE-4933-AC42-062F7FE98568-22414-000000929F8DB7FB.jpg differ
diff --git a/osinaweb/static/images/uploaded_chat_files/image_picker_2D22E107-6CA4-4C95-A323-1D9CE83A9C26-22414-00000091EDBA1256.jpg b/osinaweb/static/images/uploaded_chat_files/image_picker_2D22E107-6CA4-4C95-A323-1D9CE83A9C26-22414-00000091EDBA1256.jpg
new file mode 100644
index 00000000..699fa16e
Binary files /dev/null and b/osinaweb/static/images/uploaded_chat_files/image_picker_2D22E107-6CA4-4C95-A323-1D9CE83A9C26-22414-00000091EDBA1256.jpg differ
diff --git a/osinaweb/static/images/uploaded_chat_files/image_picker_95D69DDF-CBDA-487E-BD4B-147383F5BABF-59273-000000A392DB1C4E.jpg b/osinaweb/static/images/uploaded_chat_files/image_picker_95D69DDF-CBDA-487E-BD4B-147383F5BABF-59273-000000A392DB1C4E.jpg
new file mode 100644
index 00000000..5303e477
Binary files /dev/null and b/osinaweb/static/images/uploaded_chat_files/image_picker_95D69DDF-CBDA-487E-BD4B-147383F5BABF-59273-000000A392DB1C4E.jpg differ
diff --git a/osinaweb/static/images/uploaded_chat_files/image_picker_9BF545E4-9707-4A80-82B1-39D622482C39-54994-00000097F33656E9.jpg b/osinaweb/static/images/uploaded_chat_files/image_picker_9BF545E4-9707-4A80-82B1-39D622482C39-54994-00000097F33656E9.jpg
new file mode 100644
index 00000000..699fa16e
Binary files /dev/null and b/osinaweb/static/images/uploaded_chat_files/image_picker_9BF545E4-9707-4A80-82B1-39D622482C39-54994-00000097F33656E9.jpg differ
diff --git a/osinaweb/static/images/uploaded_chat_files/image_picker_AB367C52-C4C0-4FD6-8E01-D4EFB7A1615C-54994-00000097D8201B03.jpg b/osinaweb/static/images/uploaded_chat_files/image_picker_AB367C52-C4C0-4FD6-8E01-D4EFB7A1615C-54994-00000097D8201B03.jpg
new file mode 100644
index 00000000..65d09a3a
Binary files /dev/null and b/osinaweb/static/images/uploaded_chat_files/image_picker_AB367C52-C4C0-4FD6-8E01-D4EFB7A1615C-54994-00000097D8201B03.jpg differ
diff --git a/osinaweb/static/images/uploaded_chat_files/image_picker_FC181E70-E643-4C8A-85CE-9411D836EC11-22414-00000091C8C11654.jpg b/osinaweb/static/images/uploaded_chat_files/image_picker_FC181E70-E643-4C8A-85CE-9411D836EC11-22414-00000091C8C11654.jpg
new file mode 100644
index 00000000..7018e1ff
Binary files /dev/null and b/osinaweb/static/images/uploaded_chat_files/image_picker_FC181E70-E643-4C8A-85CE-9411D836EC11-22414-00000091C8C11654.jpg differ
diff --git a/osinaweb/static/js/osichat-admin/rooms.js b/osinaweb/static/js/osichat-admin/rooms.js
index e92d0bdd..1ddea089 100644
--- a/osinaweb/static/js/osichat-admin/rooms.js
+++ b/osinaweb/static/js/osichat-admin/rooms.js
@@ -1,6 +1,6 @@
let admin_chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
let protocol = window.location.protocol === "https:" ? "https" : "http";
-let admin_chat_domain = "192.168.1.109:8000";
+let admin_chat_domain = "osina.ositcom.com";
let userId = document.getElementById('userId').textContent.trim();
let osichatroomsSocket;
let osichatadminroomSocket;
diff --git a/osinaweb/static/js/osichat-admin/textarea.js b/osinaweb/static/js/osichat-admin/textarea.js
index 2a41cd9c..066ed475 100644
--- a/osinaweb/static/js/osichat-admin/textarea.js
+++ b/osinaweb/static/js/osichat-admin/textarea.js
@@ -26,9 +26,9 @@
// EVENT LISTENERS
textarea.addEventListener('input', function () {
// Adjust textarea and button
- adjustTextAreaAndButton(dynamicTextarea, submitButton);
+ adjustTextAreaAndButton(textarea, submitButton);
if (!isTyping){
- chatWebSocket.send(JSON.stringify({
+ osichatadminroomSocket.send(JSON.stringify({
'event_type': 'typing',
'user_id': typingUserId,
'typing_status': 'typing'
@@ -38,7 +38,7 @@
clearTimeout(typingTimeout);
typingTimeout = setTimeout(function() {
- chatWebSocket.send(JSON.stringify({
+ osichatadminroomSocket.send(JSON.stringify({
'event_type': 'typing',
'user_id': typingUserId,
'typing_status': 'stopped_typing'
diff --git a/osinaweb/static/js/osichat/conversation.js b/osinaweb/static/js/osichat/conversation.js
index 5d79e7b2..9d1396eb 100644
--- a/osinaweb/static/js/osichat/conversation.js
+++ b/osinaweb/static/js/osichat/conversation.js
@@ -1,16 +1,45 @@
const chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
const protocol = window.location.protocol === "https:" ? "https" : "http";
-const domain = "192.168.1.109:8000";
+const domain = "osina.ositcom.com";
let osichatSocket;
let isOpen = false;
let chatLoaded = false;
let newMessageCount = 0;
+let atBottom = true;
function scrollBottom() {
const conversationContainer = document.getElementById('conversation');
+
+ if (conversationContainer) {
+ conversationContainer.scrollTo({
+ top: conversationContainer.scrollHeight,
+ behavior: 'smooth'
+ });
+ }
+}
+
+
+function isScrolledToBottom(element) {
+ return element && (element.scrollHeight - element.scrollTop <= element.clientHeight + 200);
+}
+
+
+
+function setupScrollEventListener() {
+ const conversationContainer = document.getElementById('conversation');
+
if (conversationContainer) {
- conversationContainer.scrollTop = conversationContainer.scrollHeight;
+ conversationContainer.addEventListener('scroll', () => {
+ if (isScrolledToBottom(conversationContainer)) {
+ if (!atBottom) {
+ hideNewMessageNotification();
+ atBottom = true; // Update flag when user scrolls to the bottom
+ }
+ } else {
+ atBottom = false; // Update flag if user is not at the bottom
+ }
+ });
}
}
@@ -20,7 +49,6 @@ function showNewMessageNotification(count) {
if (newMessagesPopMessage && newMessagesCounter) {
newMessagesCounter.textContent = count;
newMessagesPopMessage.classList.remove('hidden');
- console.log('popup displayed')
}
}
@@ -28,17 +56,39 @@ function hideNewMessageNotification() {
const newMessagesPopMessage = document.getElementById('newMessagesPopMessage');
if (newMessagesPopMessage) {
newMessagesPopMessage.classList.add('hidden');
+ newMessageCount = 0;
+ const newMessagesCounter = document.getElementById('newMessagesCounter');
+ if (newMessagesCounter) {
+ newMessagesCounter.textContent = newMessageCount;
+ }
+ scrollBottom()
}
}
+function newMessageNotification() {
+ const notificationSound = document.getElementById('notification-sound');
+ notificationSound.play();
+
+ const conversationContainer = document.getElementById('conversation');
+
+ if (!isScrolledToBottom(conversationContainer)) {
+ let count = newMessageCount + 1;
+ newMessageCount = count;
+ showNewMessageNotification(count);
+ } else {
+ scrollBottom();
+ }
+
+}
+
// FUNCTION TO FETCH THE SESSION ID
async function fetchSessionID() {
let session_id = 'Unknown';
while (session_id === 'Unknown') {
try {
- const response = await fetch('http://192.168.1.109:3000/get-client-session/');
+ const response = await fetch('https://ositcom.com/get-client-session/');
const data = await response.json();
if (data.session_id) {
session_id = data.session_id;
@@ -106,6 +156,7 @@ function handleLoadChatEvent(data, osichatSocket) {
chatDiv.innerHTML = data.html;
scrollBottom();
+
if (isOpen) { // If chat widget isOpen (declared in chat-toggle.js) mark all messages as read by guest else just return number of unread messages
osichatSocket.send(JSON.stringify({ 'event_type': 'update_read_messages', 'chat_state': 'open' }));
} else {
@@ -196,16 +247,16 @@ async function initializeChatWebSocket() {
osichatSocket.send(JSON.stringify({ 'event_type': 'update_read_messages', 'chat_state': 'closed' }));
}
messagesDiv.insertAdjacentHTML('beforeend', data.html);
+
+ const newMessagesPopMessage = document.getElementById('newMessagesPopMessage');
+ newMessagesPopMessage.addEventListener('click', hideNewMessageNotification);
+
if (data.user) { // If it is sent by an Osina user play a notification sound for the guest
- const notificationSound = document.getElementById('notification-sound');
- notificationSound.play();
if (typingDiv) {
typingDiv.remove();
}
-
- let count = newMessageCount + 1;
- newMessageCount = count;
- showNewMessageNotification(count);
+ newMessageNotification();
+ setupScrollEventListener();
}
break;
case 'uploaded_file':
@@ -217,15 +268,19 @@ async function initializeChatWebSocket() {
const uploadingDiv = document.getElementById(`uploading-${data.file_name}`);
if (uploadingDiv) {
uploadingDiv.outerHTML = data.html;
- scrollBottom();
+ if (!data.user) {
+ scrollBottom();
+ } else {
+ newMessageNotification();
+ }
}
else{
document.getElementById('messages').insertAdjacentHTML('beforeend', data.html);
- scrollBottom();
- }
- if (data.user) { // If it is sent by an Osina user play a notification sound for the guest
- const notificationSound = document.getElementById('notification-sound');
- notificationSound.play();
+ if (!data.user) {
+ scrollBottom();
+ } else {
+ newMessageNotification();
+ }
}
break;
case 'update_read_messages':
diff --git a/osinaweb/static/js/osichat/upload-file.js b/osinaweb/static/js/osichat/upload-file.js
index 07b6d8af..be54afb0 100644
--- a/osinaweb/static/js/osichat/upload-file.js
+++ b/osinaweb/static/js/osichat/upload-file.js
@@ -1,6 +1,4 @@
(function () {
- const imageDomain = "http://192.168.1.109:8000";
-
// TO TRIGGER TEH FILE UPLOADER WHEN CLICKING ON THE UPLOAD FILE SVG
document.getElementById('svgFileUpload').addEventListener('click', function () {
document.getElementById('fileupload').click();
@@ -22,14 +20,14 @@
}
// Perform the upload
- fetch(`${imageDomain}/chat-file-uploader/`, {
+ fetch(`${protocol}://${domain}/chat-file-uploader/`, {
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(data => {
if (data.data === 'Uploaded Successfully') {
- const fullPath = `${imageDomain}/${data.existingPath}`;
+ const fullPath = `${protocol}://${domain}/${data.existingPath}`;
updateSelectTag(fullPath, file.name);
if (file.type.startsWith('image/')) {
osichatSocket.send(JSON.stringify({ 'event_type': 'uploaded_file', 'path': data.existingPath, 'file_type': 'image', 'file_name': file.name }));
diff --git a/osinaweb/static/js/osichat/visitors.js b/osinaweb/static/js/osichat/visitors.js
index d42156df..50a278c7 100644
--- a/osinaweb/static/js/osichat/visitors.js
+++ b/osinaweb/static/js/osichat/visitors.js
@@ -1,11 +1,11 @@
const visitors_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
-const my_domain = "192.168.1.109:8000";
+const my_domain = "osina.ositcom.com";
async function fetchClientData() {
let clientData = { client_ip: 'Unknown', client_country: 'Unknown' };
while (clientData.client_ip === 'Unknown') {
try {
- const response = await fetch('http://192.168.1.109:8000/get-client-ip/');
+ const response = await fetch('https://osina.ositcom.com/get-client-ip/');
const data = await response.json();
if (data.ip) {
clientData = {
@@ -25,7 +25,7 @@ async function fetchVisitorsSession() {
let session_id = 'Unknown';
while (session_id === 'Unknown') {
try {
- const response = await fetch('http://192.168.1.109:3000/get-client-session/');
+ const response = await fetch('https://ositcom.com/get-client-session/');
const data = await response.json();
if (data.session_id) {
session_id = data.session_id;