Mercurial Hosting > chat
diff src/chat.js @ 75:377bdda60f0b
read up to
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 09 Mar 2025 18:26:49 -0600 |
parents | a63faf49e1d7 |
children | 4dfe5af67f91 |
line wrap: on
line diff
--- a/src/chat.js Sun Mar 09 10:55:30 2025 -0600 +++ b/src/chat.js Sun Mar 09 18:26:49 2025 -0600 @@ -227,7 +227,10 @@ } function heartbeat() { - ajax(`heartbeat.js?last_update=${lastUpdate}`); + let url = `heartbeat.js?last_update=${lastUpdate}`; + if( currentChatId ) + url += `&chat=${currentChatId}`; + ajax(url); } setInterval( heartbeat, 10000 ); @@ -372,3 +375,19 @@ } openModal(dialog); } + +function readUpTo(userId,userNameHtml,unread) { + let div = document.querySelector(`div[user="${userId}"]`); + if( div ) { + if( unread == div.getAttribute('unread') ) + return; + div.outerHTML = ''; + } + console.log('readUpTo'); + let divs = document.querySelectorAll('div[post]'); + if( unread >= divs.length ) + return; + div = divs[divs.length - unread - 1]; + let html = `<div user="${userId}" unread="${unread}">read by ${userNameHtml}</div>`; + div.insertAdjacentHTML('beforeend',html); +}