Mercurial Hosting > chat
comparison src/chat.js @ 34:62d04ca486dd
UI
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 12 Nov 2024 16:08:24 -0700 |
parents | e2b7f6393dab |
children | 27c41f22d2a9 |
comparison
equal
deleted
inserted
replaced
33:e2b7f6393dab | 34:62d04ca486dd |
---|---|
24 let selected = div.parentNode.querySelector('[selected]'); | 24 let selected = div.parentNode.querySelector('[selected]'); |
25 if( selected ) selected.removeAttribute('selected'); | 25 if( selected ) selected.removeAttribute('selected'); |
26 div.setAttribute('selected',''); | 26 div.setAttribute('selected',''); |
27 ajax(`get_chat.js?chat=${chatId}`); | 27 ajax(`get_chat.js?chat=${chatId}`); |
28 currentChatId = chatId; | 28 currentChatId = chatId; |
29 let email = div.querySelector('[email]').textContent; | |
30 history.replaceState(null,null,`?with=${email}`); | |
29 | 31 |
30 if(eventSource) eventSource.close(); | 32 if(eventSource) eventSource.close(); |
31 eventSource = new EventSource(`${location.origin}/chat/${chatId}`); | 33 eventSource = new EventSource(`${location.origin}/chat/${chatId}`); |
32 eventSource.onmessage = evalEvent; | 34 eventSource.onmessage = evalEvent; |
33 } | 35 } |
210 setInterval(function(){ | 212 setInterval(function(){ |
211 showOnline(); | 213 showOnline(); |
212 ajax(`heartbeat.js?last_update=${lastUpdate}`); | 214 ajax(`heartbeat.js?last_update=${lastUpdate}`); |
213 }, 10000 ); | 215 }, 10000 ); |
214 | 216 |
215 function resync(updated) { | |
216 lastUpdate = updated; | |
217 currentChatId = null; | |
218 document.querySelector('div[posts]').innerHTML = ''; | |
219 back(); | |
220 ajax('get_chats.js'); | |
221 } | |
222 | |
223 let sound = new Audio('/images/notify.mp3'); | 217 let sound = new Audio('/images/notify.mp3'); |
224 function notify() { | 218 function notify() { |
225 sound.play(); | 219 sound.play(); |
226 } | 220 } |
227 | 221 |