Mercurial Hosting > chat
comparison 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 |
comparison
equal
deleted
inserted
replaced
74:1c0336a7380f | 75:377bdda60f0b |
---|---|
225 pulldown.scrollIntoViewIfNeeded(false); | 225 pulldown.scrollIntoViewIfNeeded(false); |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 function heartbeat() { | 229 function heartbeat() { |
230 ajax(`heartbeat.js?last_update=${lastUpdate}`); | 230 let url = `heartbeat.js?last_update=${lastUpdate}`; |
231 if( currentChatId ) | |
232 url += `&chat=${currentChatId}`; | |
233 ajax(url); | |
231 } | 234 } |
232 | 235 |
233 setInterval( heartbeat, 10000 ); | 236 setInterval( heartbeat, 10000 ); |
234 heartbeat(); | 237 heartbeat(); |
235 | 238 |
370 console.log(`${id} ${s}`); | 373 console.log(`${id} ${s}`); |
371 span.textContent = s; | 374 span.textContent = s; |
372 } | 375 } |
373 openModal(dialog); | 376 openModal(dialog); |
374 } | 377 } |
378 | |
379 function readUpTo(userId,userNameHtml,unread) { | |
380 let div = document.querySelector(`div[user="${userId}"]`); | |
381 if( div ) { | |
382 if( unread == div.getAttribute('unread') ) | |
383 return; | |
384 div.outerHTML = ''; | |
385 } | |
386 console.log('readUpTo'); | |
387 let divs = document.querySelectorAll('div[post]'); | |
388 if( unread >= divs.length ) | |
389 return; | |
390 div = divs[divs.length - unread - 1]; | |
391 let html = `<div user="${userId}" unread="${unread}">read by ${userNameHtml}</div>`; | |
392 div.insertAdjacentHTML('beforeend',html); | |
393 } |