Mercurial Hosting > chat
comparison src/chat.js @ 77:624654817f99
minor
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 09 Mar 2025 19:29:41 -0600 |
| parents | 4dfe5af67f91 |
| children | 2a602ef53eef |
comparison
equal
deleted
inserted
replaced
| 76:4dfe5af67f91 | 77:624654817f99 |
|---|---|
| 146 div.outerHTML = html; | 146 div.outerHTML = html; |
| 147 fixPosts(); | 147 fixPosts(); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 function active() { | |
| 152 let url = 'active.js'; | |
| 153 if( currentChatId ) | |
| 154 url += `?chat=${currentChatId}`; | |
| 155 ajax(url); | |
| 156 } | |
| 157 | |
| 151 function added(html) { | 158 function added(html) { |
| 152 let input = document.querySelector('div[input]'); | 159 let input = document.querySelector('div[input]'); |
| 153 input.insertAdjacentHTML('beforebegin',html); | 160 input.insertAdjacentHTML('beforebegin',html); |
| 154 fixPosts(); | 161 fixPosts(); |
| 155 input.scrollIntoView({block: 'end'}); | 162 input.scrollIntoView({block: 'end'}); |
| 156 ajax(`added.js?chat=${currentChatId}`); | |
| 157 if( document.hasFocus() ) | 163 if( document.hasFocus() ) |
| 158 ajax('active.js'); | 164 active(); |
| 159 } | 165 } |
| 160 | 166 |
| 161 function getChats(chatId,updated) { | 167 function getChats(chatId,updated) { |
| 162 let first = document.querySelector('div[chat]'); | 168 let first = document.querySelector('div[chat]'); |
| 163 if( !first || first.getAttribute('chat') !== chatId ) { | 169 if( !first || first.getAttribute('chat') !== chatId ) { |
| 189 } | 195 } |
| 190 | 196 |
| 191 window.onfocus = function() { | 197 window.onfocus = function() { |
| 192 // console.log('onfocus'); | 198 // console.log('onfocus'); |
| 193 document.title = title; | 199 document.title = title; |
| 194 ajax('active.js'); | 200 active(); |
| 195 }; | 201 }; |
| 196 | 202 |
| 197 let urlRegex = /(^|\s)(https?:\/\/\S+)/g; | 203 let urlRegex = /(^|\s)(https?:\/\/\S+)/g; |
| 198 let filebinUrlRegex = /(^|\s)(https:\/\/filebin.net\/[0-9a-f]+\/(\S+))/g; | 204 let filebinUrlRegex = /(^|\s)(https:\/\/filebin.net\/[0-9a-f]+\/(\S+))/g; |
| 199 | 205 |
