Mercurial Hosting > lang
comparison src/chat.js @ 28:99b71a377f2c
audio for textarea
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 02 Aug 2025 20:04:35 -0600 |
parents | 176a182c02cf |
children | 505185272dd7 |
comparison
equal
deleted
inserted
replaced
27:176a182c02cf | 28:99b71a377f2c |
---|---|
68 event.preventDefault(); | 68 event.preventDefault(); |
69 askAi(); | 69 askAi(); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 let audio; | |
74 | |
73 function fixTextarea(textarea) { | 75 function fixTextarea(textarea) { |
74 textarea.style.height = 'initial'; | 76 textarea.style.height = 'initial'; |
75 textarea.style.height = (textarea.scrollHeight+2) + 'px'; | 77 textarea.style.height = (textarea.scrollHeight+2) + 'px'; |
76 textarea.parentNode.scrollIntoViewIfNeeded(false); | 78 textarea.parentNode.scrollIntoViewIfNeeded(false); |
79 if( !audio ) | |
80 audio = document.querySelector('div[buttons] audio'); | |
81 audio.src = `/tts.mp3?lang=${lang}&text=${encodeURIComponent(textarea.value)}`; | |
77 } | 82 } |
78 | 83 |
79 function askAi() { | 84 function askAi() { |
80 let input = document.querySelector('textarea'); | 85 let input = document.querySelector('textarea'); |
81 let url = `ai_ask.js?chat=${chatId}&input=${encodeURIComponent(input.value)}`; | 86 let url = `ai_ask.js?chat=${chatId}&input=${encodeURIComponent(input.value)}`; |