Mercurial Hosting > chat
comparison src/chat.js @ 18:0721dcf222e1
* alert
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 04 Nov 2024 17:08:41 -0700 |
| parents | 7230c821c368 |
| children | 435f474f07c7 |
comparison
equal
deleted
inserted
replaced
| 17:7230c821c368 | 18:0721dcf222e1 |
|---|---|
| 1 'use strict'; | 1 'use strict'; |
| 2 | 2 |
| 3 let title = document.title; | |
| 3 let currentChatId = null; | 4 let currentChatId = null; |
| 4 let eventSource; | 5 let eventSource; |
| 5 | 6 |
| 6 function evalEvent(event) { | 7 function evalEvent(event) { |
| 7 // console.log(event); | 8 // console.log(event); |
| 75 function added(html) { | 76 function added(html) { |
| 76 let input = document.querySelector('div[input]'); | 77 let input = document.querySelector('div[input]'); |
| 77 input.insertAdjacentHTML('beforebegin',html); | 78 input.insertAdjacentHTML('beforebegin',html); |
| 78 fixDates(); | 79 fixDates(); |
| 79 input.scrollIntoView({block: 'end'}); | 80 input.scrollIntoView({block: 'end'}); |
| 81 if( !document.hasFocus() ) | |
| 82 document.title = title + ' *'; | |
| 80 } | 83 } |
| 81 | 84 |
| 82 function getChats(chatId) { | 85 function getChats(chatId) { |
| 83 let first = document.querySelector('div[chat]'); | 86 let first = document.querySelector('div[chat]'); |
| 84 if( !first || first.getAttribute('chat') != chatId ) { | 87 if( !first || first.getAttribute('chat') != chatId ) { |
| 98 currentChatId = null; | 101 currentChatId = null; |
| 99 document.querySelector('div[posts]').innerHTML = ''; | 102 document.querySelector('div[posts]').innerHTML = ''; |
| 100 } | 103 } |
| 101 } | 104 } |
| 102 } | 105 } |
| 106 | |
| 107 window.onfocus = function() { | |
| 108 document.title = title; | |
| 109 }; |
