diff 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
line wrap: on
line diff
--- a/src/chat.js	Thu Jul 31 22:30:26 2025 -0600
+++ b/src/chat.js	Fri Aug 01 00:33:51 2025 -0600
@@ -40,6 +40,14 @@
 	document.querySelector('[waiting-ai-icon]').style.display = 'none';
 }
 
+function playLastMessage() {
+	let audios = document.querySelectorAll('audio');
+	if( audios.length >= 1 ) {
+		let audio = audios[audios.length-1];
+		audio.play();
+	}
+}
+
 function updateAi(html) {
 	hideWaitingAiIcon();
 	document.querySelector('div[messages]').insertAdjacentHTML('beforeend',html);
@@ -52,11 +60,7 @@
 		scroll.scrollTo(0,scroll.scrollHeight);
 	});
 */
-	let audios = document.querySelectorAll('audio');
-	if( audios.length >= 1 ) {
-		let audio = audios[audios.length-1];
-		audio.play();
-	}
+	playLastMessage();
 }
 
 const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;