Spaces:
Running
Running
Update static/index.html
Browse files- static/index.html +18 -13
static/index.html
CHANGED
|
@@ -159,19 +159,24 @@
|
|
| 159 |
}
|
| 160 |
}
|
| 161 |
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
function showTypingIndicator() {
|
| 177 |
const typingElement = document.createElement("div");
|
|
|
|
| 159 |
}
|
| 160 |
}
|
| 161 |
|
| 162 |
+
function addMessage(sender, message, className) {
|
| 163 |
+
const chatHistory = document.getElementById("chat-history");
|
| 164 |
+
const messageElement = document.createElement("div");
|
| 165 |
+
messageElement.className = `message ${className}`;
|
| 166 |
+
// Check if the message contains a URL
|
| 167 |
+
const linkRegex = /(https?:\/\/[^\s]+)/g;
|
| 168 |
+
const formattedMessage = message.replace(linkRegex, function(url) {
|
| 169 |
+
return `<a href="${url}" target="_blank">click here</a>`;
|
| 170 |
+
});
|
| 171 |
+
const icon = sender === "User" ? '<i class="fas fa-user user-icon"></i>' : '<i class="fas fa-user-tie"></i>';
|
| 172 |
+
messageElement.innerHTML = `${icon}<div>${formattedMessage} <span class="timestamp">${new Date().toLocaleTimeString()}</span></div>`;
|
| 173 |
+
messageElement.onclick = function() {
|
| 174 |
+
const timestamp = messageElement.querySelector('.timestamp');
|
| 175 |
+
timestamp.style.display = timestamp.style.display === 'none' ? 'block' : 'none';
|
| 176 |
+
};
|
| 177 |
+
chatHistory.appendChild(messageElement);
|
| 178 |
+
chatHistory.scrollTop = chatHistory.scrollHeight;
|
| 179 |
+
}
|
| 180 |
|
| 181 |
function showTypingIndicator() {
|
| 182 |
const typingElement = document.createElement("div");
|