|
|
@ -630,7 +630,7 @@ function showMessageDetails(message_id) {
|
|
|
|
fetch(`/unread_message_count/?user_id=${userId}`)
|
|
|
|
fetch(`/unread_message_count/?user_id=${userId}`)
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
.then(data => {
|
|
|
|
console.log(data.unread_count);
|
|
|
|
console.log('unread_count:',data.unread_count);
|
|
|
|
const notificationBadge = document.getElementById('messageNotificationBadge');
|
|
|
|
const notificationBadge = document.getElementById('messageNotificationBadge');
|
|
|
|
if (data.unread_count > 0) {
|
|
|
|
if (data.unread_count > 0) {
|
|
|
|
notificationBadge.textContent = data.unread_count ;
|
|
|
|
notificationBadge.textContent = data.unread_count ;
|
|
|
@ -789,8 +789,6 @@ function HideMessageDetails() {
|
|
|
|
messageDetailsContainer.style.display = 'none';
|
|
|
|
messageDetailsContainer.style.display = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function backToInbox(event) {
|
|
|
|
function backToInbox(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.preventDefault();
|
|
|
|
const inboxContainer = document.getElementById('InboxContainer');
|
|
|
|
const inboxContainer = document.getElementById('InboxContainer');
|
|
|
@ -801,8 +799,6 @@ function backToInbox(event) {
|
|
|
|
messageDetailsContainer.style.display = 'none';
|
|
|
|
messageDetailsContainer.style.display = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function replyMessage(event, message_id, type) {
|
|
|
|
function replyMessage(event, message_id, type) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.preventDefault();
|
|
|
|
console.log(message_id);
|
|
|
|
console.log(message_id);
|
|
|
@ -904,11 +900,11 @@ emailList.forEach((email, index) => {
|
|
|
|
×
|
|
|
|
×
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
<div id="emailBars">${emailBarsHtml}</div> <!-- Dynamic email bars -->
|
|
|
|
<div id="emailBars">${emailBarsHtml}</div> <!-- Dynamic email bars -->
|
|
|
|
<textarea id="message" name="message" placeholder=""
|
|
|
|
<textarea id="message" name="message" placeholder="" style="width: 107%; height: 150px; border: none; margin-bottom: 10px; margin-left: -20px; border-top:1px solid #D3D3D3; outline: none; padding: 5px; resize: none; box-sizing: border-box;"></textarea>
|
|
|
|
style="width: 107%; height: 150px; border: none; margin-bottom: 10px; margin-left: -20px; border-top:1px solid #D3D3D3; outline: none; padding: 5px; resize: none; box-sizing: border-box;"></textarea>
|
|
|
|
|
|
|
|
<button type="button" style="border-radius: 10px; top:-800px; color:white; background:#1F51FF;font-size:17px; border: none; width:70px; height:30px; font-weight:bold;" onclick="sendReply(event, '${message.message_id}')">Send</button>
|
|
|
|
<button type="button" style="border-radius: 10px; top:-800px; color:white; background:#1F51FF;font-size:17px; border: none; width:70px; height:30px; font-weight:bold;" onclick="sendReply(event, '${message.message_id}')">Send</button>
|
|
|
|
<!-- <i class="fa-solid fa-paperclip" onclick="document.getElementById('attachment').click();" style="color: #1F51FF; margin-left:10px; font-size:23px; cursor: pointer;"></i>-->
|
|
|
|
<i class="fa-solid fa-paperclip" onclick="document.getElementById('attachment-reply').click();" style="color:#1F51FF; margin-left:10px; font-size:23px; cursor: pointer;"></i>
|
|
|
|
<input type="file" id="attachment" name="attachment" accept=".pdf,.doc,.docx,.txt">
|
|
|
|
<input type="file" id="attachment-reply" name="attachment" accept=".pdf,.doc,.docx,.txt" style="display: none;" onchange="showReplyFileName()">
|
|
|
|
|
|
|
|
<span id="file-name-reply" style="font-size: 14px; color: black; margin-left: 10px;"></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</form>
|
|
|
|
`;
|
|
|
|
`;
|
|
|
@ -928,6 +924,28 @@ document.getElementById("closeComposeBtn").addEventListener("click", function()
|
|
|
|
if (element) { element.focus();}
|
|
|
|
if (element) { element.focus();}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function showReplyFileName() {
|
|
|
|
|
|
|
|
var input = document.getElementById("attachment-reply");
|
|
|
|
|
|
|
|
var fileNameDisplay = document.getElementById("file-name-reply");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (input.files.length > 0) {
|
|
|
|
|
|
|
|
var fullFileName = input.files[0].name;
|
|
|
|
|
|
|
|
var maxLength = 40; // Maximum characters before truncating
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fullFileName.length > maxLength) {
|
|
|
|
|
|
|
|
var truncatedFileName = fullFileName.substring(0, maxLength) + "...";
|
|
|
|
|
|
|
|
fileNameDisplay.textContent = truncatedFileName;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fileNameDisplay.textContent = fullFileName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fileNameDisplay.textContent = ""; // Clear if no file is selected
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function renderReplies(replies, container) {
|
|
|
|
function renderReplies(replies, container) {
|
|
|
|
console.log(replies);
|
|
|
|
console.log(replies);
|
|
|
|
|
|
|
|
|
|
|
@ -1090,7 +1108,7 @@ console.log(recipients);
|
|
|
|
|
|
|
|
|
|
|
|
const subject = document.getElementById('subject').value; // Fetch subject
|
|
|
|
const subject = document.getElementById('subject').value; // Fetch subject
|
|
|
|
const message = document.getElementById('message').value; // Fetch message
|
|
|
|
const message = document.getElementById('message').value; // Fetch message
|
|
|
|
const attachment = document.getElementById('attachment').files[0];
|
|
|
|
const attachment = document.getElementById('attachment-reply').files[0];
|
|
|
|
console.log(attachment);
|
|
|
|
console.log(attachment);
|
|
|
|
|
|
|
|
|
|
|
|
// If both subject and message are empty, confirm whether to send the message
|
|
|
|
// If both subject and message are empty, confirm whether to send the message
|
|
|
@ -1104,6 +1122,8 @@ console.log(recipients);
|
|
|
|
const old_message_id = id;
|
|
|
|
const old_message_id = id;
|
|
|
|
console.log(old_message_id);
|
|
|
|
console.log(old_message_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const userId = document.getElementById('user_id').value;
|
|
|
|
|
|
|
|
|
|
|
|
// Append dynamic recipient information to the form data
|
|
|
|
// Append dynamic recipient information to the form data
|
|
|
|
const formData = new FormData(form);
|
|
|
|
const formData = new FormData(form);
|
|
|
|
formData.append('toField', recipients); // Use dynamically gathered recipients
|
|
|
|
formData.append('toField', recipients); // Use dynamically gathered recipients
|
|
|
@ -1148,7 +1168,6 @@ console.log(recipients);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
repliesContainer.innerHTML = ''; // Clear existing replies
|
|
|
|
repliesContainer.innerHTML = ''; // Clear existing replies
|
|
|
|
const userId = document.getElementById('user_id').value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fetch(`/fetch_replies/${parentMessageId}/?user_id=${userId}`)
|
|
|
|
fetch(`/fetch_replies/${parentMessageId}/?user_id=${userId}`)
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(response => response.json())
|
|
|
@ -1161,6 +1180,8 @@ console.log(recipients);
|
|
|
|
.catch(error => {
|
|
|
|
.catch(error => {
|
|
|
|
console.error('Error fetching replies:', error);
|
|
|
|
console.error('Error fetching replies:', error);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateMessageNotification();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
alert('Failed to send message. Please try again.');
|
|
|
|
alert('Failed to send message. Please try again.');
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1171,6 +1192,23 @@ console.log(recipients);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function updateMessageNotification() {
|
|
|
|
|
|
|
|
const userId = document.getElementById('user_id').value;
|
|
|
|
|
|
|
|
fetch(`/unread_message_count/?user_id=${userId}`)
|
|
|
|
|
|
|
|
.then(response => response.json())
|
|
|
|
|
|
|
|
.then(data => {
|
|
|
|
|
|
|
|
console.log('unread_count:',data.unread_count);
|
|
|
|
|
|
|
|
const notificationBadge = document.getElementById('messageNotificationBadge');
|
|
|
|
|
|
|
|
if (data.unread_count > 0) {
|
|
|
|
|
|
|
|
notificationBadge.textContent = data.unread_count ;
|
|
|
|
|
|
|
|
notificationBadge.style.display = 'inline-flex'; // Show badge if there are unread messages
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
notificationBadge.style.display = 'none'; // Hide badge if no unread messages
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch(error => console.error('Error fetching unread message count:', error));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function forwardMessage(index) {
|
|
|
|
function forwardMessage(index) {
|
|
|
|
const message = window.Messages[index];
|
|
|
|
const message = window.Messages[index];
|
|
|
@ -1450,6 +1488,25 @@ function renderInbox() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function showFileName() {
|
|
|
|
|
|
|
|
var input = document.getElementById("attachment-input");
|
|
|
|
|
|
|
|
var fileNameDisplay = document.getElementById("file-name");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (input.files.length > 0) {
|
|
|
|
|
|
|
|
var fullFileName = input.files[0].name;
|
|
|
|
|
|
|
|
var maxLength = 40; // Max characters before truncating
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fullFileName.length > maxLength) {
|
|
|
|
|
|
|
|
var truncatedFileName = fullFileName.substring(0, maxLength) + "...";
|
|
|
|
|
|
|
|
fileNameDisplay.textContent = truncatedFileName;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fileNameDisplay.textContent = fullFileName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fileNameDisplay.textContent = ""; // Clear if no file is selected
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sendMessage(event) {
|
|
|
|
function sendMessage(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.preventDefault();
|
|
|
@ -1458,7 +1515,8 @@ function sendMessage(event) {
|
|
|
|
const toField = document.getElementById('toField').value; // Fetch 'to' field value
|
|
|
|
const toField = document.getElementById('toField').value; // Fetch 'to' field value
|
|
|
|
const subject = document.getElementById('subject').value; // Fetch subject
|
|
|
|
const subject = document.getElementById('subject').value; // Fetch subject
|
|
|
|
const message = document.getElementById('Message').value; // Fetch message
|
|
|
|
const message = document.getElementById('Message').value; // Fetch message
|
|
|
|
const attachment = document.getElementById('attachment').value;
|
|
|
|
const attachmentInput = document.getElementById('attachment-input');
|
|
|
|
|
|
|
|
const fileNameDisplay = document.getElementById('file-name');
|
|
|
|
|
|
|
|
|
|
|
|
const recipients = toField.split(',').map(email => email.trim()).filter(email => email !== '');
|
|
|
|
const recipients = toField.split(',').map(email => email.trim()).filter(email => email !== '');
|
|
|
|
console.log(recipients);
|
|
|
|
console.log(recipients);
|
|
|
@ -1495,6 +1553,7 @@ function sendMessage(event) {
|
|
|
|
if (data.status === 'success') {
|
|
|
|
if (data.status === 'success') {
|
|
|
|
alert('Message sent successfully!');
|
|
|
|
alert('Message sent successfully!');
|
|
|
|
form.reset();
|
|
|
|
form.reset();
|
|
|
|
|
|
|
|
fileNameDisplay.innerHTML= '';
|
|
|
|
document.getElementById('ComposeContainer').style.display = 'none';
|
|
|
|
document.getElementById('ComposeContainer').style.display = 'none';
|
|
|
|
|
|
|
|
|
|
|
|
<!-- reloadMessages();-->
|
|
|
|
<!-- reloadMessages();-->
|
|
|
@ -1505,6 +1564,7 @@ function sendMessage(event) {
|
|
|
|
.catch(error => {
|
|
|
|
.catch(error => {
|
|
|
|
console.error('Error:', error);
|
|
|
|
console.error('Error:', error);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|