comparison src/chat.js @ 27:809193524522

responsive
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 06 Nov 2024 16:01:42 -0700
parents af41be2dcdec
children f4708943f29e
comparison
equal deleted inserted replaced
26:5bdbbd0a65e1 27:809193524522
13 let userEventSource = new EventSource(`${location.origin}/user/${userId}`); 13 let userEventSource = new EventSource(`${location.origin}/user/${userId}`);
14 userEventSource.onmessage = evalEvent; 14 userEventSource.onmessage = evalEvent;
15 } 15 }
16 16
17 function selectChat(div) { 17 function selectChat(div) {
18 document.querySelector('div[content]').setAttribute('show','posts');
18 let chatId = div.getAttribute('chat'); 19 let chatId = div.getAttribute('chat');
19 if( chatId === currentChatId ) 20 if( chatId === currentChatId )
20 return; 21 return;
21 let selected = div.parentNode.querySelector('[selected]'); 22 let selected = div.parentNode.querySelector('[selected]');
22 if( selected ) selected.removeAttribute('selected'); 23 if( selected ) selected.removeAttribute('selected');
25 currentChatId = chatId; 26 currentChatId = chatId;
26 27
27 if(eventSource) eventSource.close(); 28 if(eventSource) eventSource.close();
28 eventSource = new EventSource(`${location.origin}/chat/${chatId}`); 29 eventSource = new EventSource(`${location.origin}/chat/${chatId}`);
29 eventSource.onmessage = evalEvent; 30 eventSource.onmessage = evalEvent;
31 }
32
33 function back() {
34 document.querySelector('div[content]').setAttribute('show','chats');
30 } 35 }
31 36
32 function gotChat(html) { 37 function gotChat(html) {
33 document.querySelector('div[posts]').innerHTML = html; 38 document.querySelector('div[posts]').innerHTML = html;
34 fixPosts(); 39 fixPosts();