Mercurial Hosting > lang
comparison src/chat.html.luan @ 35:3117876debca
ai_first_message in textarea
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 05 Aug 2025 16:41:29 -0600 |
parents | 0fb3488a017d |
children | 2737eeedc1d5 |
comparison
equal
deleted
inserted
replaced
34:0fb3488a017d | 35:3117876debca |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local ipairs = Luan.ipairs or error() | 3 local ipairs = Luan.ipairs or error() |
4 local Parsers = require "luan:Parsers.luan" | 4 local Parsers = require "luan:Parsers.luan" |
5 local json_string = Parsers.json_string or error() | 5 local json_string = Parsers.json_string or error() |
6 local Html = require "luan:Html.luan" | |
7 local html_encode = Html.encode or error() | |
6 local Io = require "luan:Io.luan" | 8 local Io = require "luan:Io.luan" |
7 local Http = require "luan:http/Http.luan" | 9 local Http = require "luan:http/Http.luan" |
8 local Shared = require "site:/lib/Shared.luan" | 10 local Shared = require "site:/lib/Shared.luan" |
9 local head = Shared.head or error() | 11 local head = Shared.head or error() |
10 local header = Shared.header or error() | 12 local header = Shared.header or error() |
20 return function() | 22 return function() |
21 local user = current_user() | 23 local user = current_user() |
22 if user == nil then return end | 24 if user == nil then return end |
23 local chat_id = Http.request.parameters.chat or error() | 25 local chat_id = Http.request.parameters.chat or error() |
24 local chat = get_chat_by_id(chat_id) or error() | 26 local chat = get_chat_by_id(chat_id) or error() |
25 local added_message = chat.init_ai() | 27 local init_text = chat.init_text() |
26 Io.stdout = Http.response.text_writer() | 28 Io.stdout = Http.response.text_writer() |
27 %> | 29 %> |
28 <!doctype html> | 30 <!doctype html> |
29 <html lang="en"> | 31 <html lang="en"> |
30 <head> | 32 <head> |
50 </div> | 52 </div> |
51 <div messages> | 53 <div messages> |
52 <% chat.output_messages_html() %> | 54 <% chat.output_messages_html() %> |
53 </div> | 55 </div> |
54 <div ask> | 56 <div ask> |
55 <textarea autofocus oninput="fixTextarea(event.target)" onkeydown="textareaKey(event)"></textarea> | 57 <textarea autofocus oninput="fixTextarea(event.target)" onkeydown="textareaKey(event)"><%= html_encode(init_text) %></textarea> |
56 <div buttons> | 58 <div buttons> |
57 <audio controls preload=none></audio> | 59 <audio controls preload=none></audio> |
58 <button record onclick="toggleRecording()">Record</button> | 60 <button record onclick="toggleRecording()">Record</button> |
59 <button onclick="askAi()" title="Send"><img src="/images/send.svg"></button> | 61 <button onclick="askAi()" title="Send"><img src="/images/send.svg"></button> |
60 </div> | 62 </div> |
122 let initialized = document.querySelector('[name=initialized]'); | 124 let initialized = document.querySelector('[name=initialized]'); |
123 if( !initialized.value ) { | 125 if( !initialized.value ) { |
124 initialized.value = 'yes'; | 126 initialized.value = 'yes'; |
125 //alert('init'); | 127 //alert('init'); |
126 scrollToEnd(); | 128 scrollToEnd(); |
127 <% if added_message then %> | |
128 playLastMessage(); | |
129 <% end %> | |
130 } | 129 } |
131 },10); | 130 },10); |
132 </script> | 131 </script> |
133 </body> | 132 </body> |
134 </html> | 133 </html> |