diff --git a/templates/pages/chat.html b/templates/pages/chat.html
index 382947f..494de47 100644
--- a/templates/pages/chat.html
+++ b/templates/pages/chat.html
@@ -140,6 +140,33 @@
.autocomplete-item:hover {
background-color: #f3d2c1;
}
+ .reply-indicator {
+ background-color: #001858;
+ color: #fef6e4;
+ padding: 5px 10px;
+ border-radius: 5px;
+ margin-bottom: 8px;
+ display: none;
+ align-items: center;
+ justify-content: space-between;
+ }
+ .reply-indicator span {
+ font-size: 0.9em;
+ }
+ .reply-indicator button {
+ background: none;
+ border: none;
+ color: #fef6e4;
+ cursor: pointer;
+ font-size: 0.9em;
+ padding: 0 5px;
+ margin: 0;
+ width: auto;
+ }
+ .reply-indicator button:hover {
+ background: none;
+ color: #f582ae;
+ }
@media (prefers-color-scheme: dark) {
.chat-container {
background-color: #444;
@@ -173,6 +200,16 @@
background-color: #8bd3dd;
color: #001858;
}
+ .reply-indicator {
+ background-color: #222;
+ color: #fef6e4;
+ }
+ .reply-indicator button {
+ color: #fef6e4;
+ }
+ .reply-indicator button:hover {
+ color: #f582ae;
+ }
}
@@ -196,16 +233,20 @@
{{.Timestamp.Format "02/01/2006 15:04"}}
{{if gt .ReplyTo 0}}
-
Replying to message #{{.ReplyTo}}
+ Replying to {{.Username}}
{{end}}
{{.Content | html}}
{{end}}
@@ -218,6 +259,7 @@
let autocompleteActive = false;
let autocompletePrefix = '';
let replyToId = -1;
+ let replyUsername = '';
function connectWebSocket() {
ws = new WebSocket('ws://' + window.location.host + '{{.BasePath}}/chat/?ws=true', [], { credentials: 'include' });
@@ -246,8 +288,7 @@
if (ws && ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify(msg));
input.value = '';
- replyToId = -1;
- // Optionally, clear reply indicator UI here
+ cancelReply(); // Reset reply state after sending
} else {
console.error("WebSocket is not open. Current state:", ws ? ws.readyState : 'undefined');
}
@@ -259,7 +300,7 @@
msgDiv.className = 'chat-message';
msgDiv.id = 'msg-' + msg.ID;
let pfpHTML = msg.PfpURL ? `
` : ``;
- let replyHTML = msg.ReplyTo > 0 ? `Replying to message #${msg.ReplyTo}
` : '';
+ let replyHTML = msg.ReplyTo > 0 ? `Replying to ${msg.Username}
` : '';
// Process content for mentions
let content = msg.Content.replace(/@[\w]+/g, match => `${match}`);
msgDiv.innerHTML = `
@@ -271,19 +312,30 @@
${replyHTML}
${content}
`;
messages.appendChild(msgDiv);
messages.scrollTop = messages.scrollHeight;
}
- function replyToMessage(id) {
+ function replyToMessage(id, username) {
replyToId = id;
- // Optionally, show a UI indicator that a reply is set
+ replyUsername = username;
+ const replyIndicator = document.getElementById('reply-indicator');
+ const replyUsernameSpan = document.getElementById('reply-username');
+ replyUsernameSpan.textContent = `Replying to ${username}`;
+ replyIndicator.style.display = 'flex';
document.getElementById('chat-input-text').focus();
}
+ function cancelReply() {
+ replyToId = -1;
+ replyUsername = '';
+ const replyIndicator = document.getElementById('reply-indicator');
+ replyIndicator.style.display = 'none';
+ }
+
function scrollToMessage(id) {
const msgElement = document.getElementById('msg-' + id);
if (msgElement) {