Mercurial Hosting > lang
comparison src/chat.js @ 5:a970b7a01a74
start ai
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 16 Jul 2025 15:08:14 -0600 |
parents | b1adec083e44 |
children | 025bb19b65b1 |
comparison
equal
deleted
inserted
replaced
4:b1adec083e44 | 5:a970b7a01a74 |
---|---|
29 | 29 |
30 function showWaitingAiIcon() { | 30 function showWaitingAiIcon() { |
31 document.querySelector('[waiting-ai-icon]').style.display = 'block'; | 31 document.querySelector('[waiting-ai-icon]').style.display = 'block'; |
32 } | 32 } |
33 | 33 |
34 function hideWaitingAiIcon() { | |
35 document.querySelector('[waiting-ai-icon]').style.display = 'none'; | |
36 } | |
37 | |
38 function updateAi(html) { | |
39 hideWaitingAiIcon(); | |
40 document.querySelector('div[messages]').innerHTML = html; | |
41 //handleMarkdown(); | |
42 document.querySelector('textarea').focus(); | |
43 /* | |
44 let scroll = aiDialog.querySelector('[scroll]'); | |
45 setTimeout(function(){ | |
46 scroll.scrollTo(0,scroll.scrollHeight); | |
47 }); | |
48 */ | |
49 } | |
50 | |
34 const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; | 51 const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; |
35 | 52 |
36 function textareaKey(event) { | 53 function textareaKey(event) { |
37 if( event.keyCode===13 && !event.shiftKey && !event.ctrlKey && !isMobile ) { | 54 if( event.keyCode===13 && !event.shiftKey && !event.ctrlKey && !isMobile ) { |
38 event.preventDefault(); | 55 event.preventDefault(); |
47 textarea.scrollIntoViewIfNeeded(false); | 64 textarea.scrollIntoViewIfNeeded(false); |
48 } | 65 } |
49 | 66 |
50 function askAi() { | 67 function askAi() { |
51 let input = document.querySelector('textarea'); | 68 let input = document.querySelector('textarea'); |
52 let url = `ai_ask.js?key=${chatId}&input=${encodeURIComponent(input.value)}`; | 69 let url = `ai_ask.js?chat=${chatId}&input=${encodeURIComponent(input.value)}`; |
53 ajax(url); | 70 ajax(url); |
54 input.value = ''; | 71 input.value = ''; |
55 showWaitingAiIcon(); | 72 showWaitingAiIcon(); |
56 } | 73 } |