Mercurial Hosting > lang
comparison src/site.js @ 74:64e35a92d163 default tip
add translation
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 28 Aug 2025 13:31:46 -0600 |
parents | 60ebb333b40c |
children |
comparison
equal
deleted
inserted
replaced
73:60ebb333b40c | 74:64e35a92d163 |
---|---|
149 node.remove(); | 149 node.remove(); |
150 } | 150 } |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 function textContent(div) { | |
155 mdDiv.innerHTML = div.innerHTML; | |
156 let rts = mdDiv.querySelectorAll('rt'); | |
157 for( let rt of rts ) { | |
158 rt.remove(); | |
159 } | |
160 return mdDiv.textContent; | |
161 } | |
162 | |
154 function handleMarkdown(voice,instructions) { | 163 function handleMarkdown(voice,instructions) { |
155 let converter = window.markdownit(); | 164 let converter = window.markdownit(); |
156 let divs = document.querySelectorAll('[markdown]'); | 165 let divs = document.querySelectorAll('[markdown]'); |
157 for( let div of divs ) { | 166 for( let div of divs ) { |
158 div.innerHTML = converter.render(div.textContent); | 167 div.innerHTML = converter.render(div.textContent); |
159 toRuby(div); | 168 toRuby(div); |
160 div.removeAttribute('markdown'); | 169 div.removeAttribute('markdown'); |
161 let parent = div.parentNode; | 170 let parent = div.parentNode; |
162 if( parent.getAttribute('role')==='assistant' ) { | 171 if( parent.getAttribute('role')==='assistant' ) { |
163 mdDiv.innerHTML = div.innerHTML; | 172 parent.querySelector('audio').src = `/tts.wav?voice=${voice}&instructions=${encodeURIComponent(instructions)}&text=${encodeURIComponent(textContent(div))}`; |
164 let rts = mdDiv.querySelectorAll('rt'); | |
165 for( let rt of rts ) { | |
166 rt.remove(); | |
167 } | |
168 //console.log(mdDiv.textContent); | |
169 parent.querySelector('audio').src = `/tts.wav?voice=${voice}&instructions=${encodeURIComponent(instructions)}&text=${encodeURIComponent(mdDiv.textContent)}`; | |
170 } | 173 } |
171 } | 174 } |
172 } | 175 } |