Mercurial Hosting > lang
comparison src/chat.js @ 32:d34d709a7a8e
region
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 03 Aug 2025 18:43:17 -0600 |
parents | 1e7d855afde3 |
children | 0fb3488a017d |
comparison
equal
deleted
inserted
replaced
31:1e7d855afde3 | 32:d34d709a7a8e |
---|---|
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 let chat; | 3 let chat; |
4 | 4 |
5 function setChat(newChat) { | 5 function setChat(newChat) { |
6 let audioChanged = chat && chat.voice != newChat.voice; | 6 let audioChanged = chat && (chat.language_region != newChat.language_region || chat.voice != newChat.voice); |
7 chat = newChat; | 7 chat = newChat; |
8 document.querySelector('[content] [name]').textContent = chat.name; | 8 document.querySelector('[content] [name]').textContent = chat.name; |
9 if(audioChanged) { | 9 if(audioChanged) { |
10 let s = `voice=${chat.voice}&`; | 10 let lang = `lang=${chat.language_region}&`; |
11 let voice = `voice=${chat.voice}&`; | |
11 let audios = document.querySelectorAll('audio[src]'); | 12 let audios = document.querySelectorAll('audio[src]'); |
12 for( let audio of audios ) { | 13 for( let audio of audios ) { |
13 audio.src = audio.src.replace(/voice=[^&]+&/,s); | 14 let src = audio.src; |
15 src = src.replace(/lang=[^&]+&/,lang); | |
16 src = src.replace(/voice=[^&]+&/,voice); | |
17 audio.src = src; | |
14 } | 18 } |
15 } | 19 } |
16 } | 20 } |
17 | 21 |
18 function editChat(name) { | 22 function editChat(name) { |
19 let dialog = document.querySelector('dialog[edit]'); | 23 let dialog = document.querySelector('dialog[edit]'); |
20 dialog.querySelector('input[name=name]').value = chat.name; | 24 dialog.querySelector('input[name=name]').value = chat.name; |
25 dialog.querySelector('select[name=language_region]').value = chat.language_region; | |
21 dialog.querySelector('select[name=voice]').value = chat.voice; | 26 dialog.querySelector('select[name=voice]').value = chat.voice; |
22 dialog.showModal(); | 27 dialog.showModal(); |
23 } | 28 } |
24 | 29 |
25 function saveChat(form) { | 30 function saveChat(form) { |
49 function hideWaitingAiIcon() { | 54 function hideWaitingAiIcon() { |
50 document.querySelector('[waiting-ai-icon]').style.display = 'none'; | 55 document.querySelector('[waiting-ai-icon]').style.display = 'none'; |
51 } | 56 } |
52 | 57 |
53 function playLastMessage() { | 58 function playLastMessage() { |
54 let audios = document.querySelectorAll('audio'); | 59 let audios = document.querySelectorAll('[messages] audio'); |
55 if( audios.length >= 1 ) { | 60 if( audios.length >= 1 ) { |
56 let audio = audios[audios.length-1]; | 61 let audio = audios[audios.length-1]; |
57 audio.play(); | 62 audio.play(); |
58 } | 63 } |
59 } | 64 } |