comparison src/chat.js @ 25:3a80ddafe5a4

courses work
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 01 Aug 2025 00:33:51 -0600
parents 47b00cce8b53
children 176a182c02cf
comparison
equal deleted inserted replaced
24:87fe70201aa8 25:3a80ddafe5a4
38 38
39 function hideWaitingAiIcon() { 39 function hideWaitingAiIcon() {
40 document.querySelector('[waiting-ai-icon]').style.display = 'none'; 40 document.querySelector('[waiting-ai-icon]').style.display = 'none';
41 } 41 }
42 42
43 function playLastMessage() {
44 let audios = document.querySelectorAll('audio');
45 if( audios.length >= 1 ) {
46 let audio = audios[audios.length-1];
47 audio.play();
48 }
49 }
50
43 function updateAi(html) { 51 function updateAi(html) {
44 hideWaitingAiIcon(); 52 hideWaitingAiIcon();
45 document.querySelector('div[messages]').insertAdjacentHTML('beforeend',html); 53 document.querySelector('div[messages]').insertAdjacentHTML('beforeend',html);
46 handleMarkdown(); 54 handleMarkdown();
47 document.querySelector('textarea').focus(); 55 document.querySelector('textarea').focus();
50 let scroll = aiDialog.querySelector('[scroll]'); 58 let scroll = aiDialog.querySelector('[scroll]');
51 setTimeout(function(){ 59 setTimeout(function(){
52 scroll.scrollTo(0,scroll.scrollHeight); 60 scroll.scrollTo(0,scroll.scrollHeight);
53 }); 61 });
54 */ 62 */
55 let audios = document.querySelectorAll('audio'); 63 playLastMessage();
56 if( audios.length >= 1 ) {
57 let audio = audios[audios.length-1];
58 audio.play();
59 }
60 } 64 }
61 65
62 const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 66 const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
63 67
64 function textareaKey(event) { 68 function textareaKey(event) {