Mercurial Hosting > chat
comparison src/chat.js @ 76:4dfe5af67f91
fix
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 09 Mar 2025 18:45:39 -0600 |
| parents | 377bdda60f0b |
| children | 624654817f99 |
comparison
equal
deleted
inserted
replaced
| 75:377bdda60f0b | 76:4dfe5af67f91 |
|---|---|
| 375 } | 375 } |
| 376 openModal(dialog); | 376 openModal(dialog); |
| 377 } | 377 } |
| 378 | 378 |
| 379 function readUpTo(userId,userNameHtml,unread) { | 379 function readUpTo(userId,userNameHtml,unread) { |
| 380 let div = document.querySelector(`div[user="${userId}"]`); | 380 //console.log(`readUpTo ${unread}`); |
| 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]'); | 381 let divs = document.querySelectorAll('div[post]'); |
| 388 if( unread >= divs.length ) | 382 if( unread >= divs.length ) |
| 389 return; | 383 return; |
| 390 div = divs[divs.length - unread - 1]; | 384 let div = divs[divs.length - unread - 1]; |
| 385 let old = document.querySelector(`div[unread][user="${userId}"]`); | |
| 386 if( old ) { | |
| 387 //console.log(`was ${div.getAttribute('unread')}`); | |
| 388 if( div == old.parentNode ) | |
| 389 return; | |
| 390 old.outerHTML = ''; | |
| 391 } | |
| 392 //console.log('readUpTo'); | |
| 391 let html = `<div user="${userId}" unread="${unread}">read by ${userNameHtml}</div>`; | 393 let html = `<div user="${userId}" unread="${unread}">read by ${userNameHtml}</div>`; |
| 392 div.insertAdjacentHTML('beforeend',html); | 394 div.insertAdjacentHTML('beforeend',html); |
| 393 } | 395 } |
