Chat: Highlight user mentions even after page reload
parent
d3db9723ec
commit
b1db26af16
|
@ -453,6 +453,14 @@
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
connectWebSocket();
|
connectWebSocket();
|
||||||
|
|
||||||
|
// Highlight mentions in pre-loaded messages
|
||||||
|
document.querySelectorAll('.chat-message-content').forEach(function(el) {
|
||||||
|
const text = el.innerHTML; // The Go template already escaped it for security
|
||||||
|
const newHTML = text.replace(/@(\w+)/g, '<span class="chat-message-mention">@$1</span>');
|
||||||
|
el.innerHTML = newHTML;
|
||||||
|
});
|
||||||
|
|
||||||
document.getElementById('chat-messages').scrollTop = document.getElementById('chat-messages').scrollHeight;
|
document.getElementById('chat-messages').scrollTop = document.getElementById('chat-messages').scrollHeight;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue