This commit is contained in:
恍兮惚兮 2024-05-16 23:16:24 +08:00
parent f7ede00f4b
commit bd04bd443b
2 changed files with 12 additions and 12 deletions

View File

@ -2,25 +2,25 @@
<div id="audio">{{audio}}</div> <div id="audio">{{audio}}</div>
<div id="audio_sentence">{{audio_sentence}}</div> <div id="audio_sentence">{{audio_sentence}}</div>
</div> </div>
<div class="centerdiv"> <div class="centerdiv" onclick='playAudio("audio")'>
<div id="rubyword" class="ruby-div" onclick='playAudio("audio")'></div> <div class="ruby-div" id="word">{{ word }}</div>
<div id="rubyword" class="ruby-div"></div>
</div> </div>
<script> <script>
ruby = {{ rubytext }} ruby = {{ rubytext }}
word = '{{ word }}'
html = '' html = ''
if (ruby.length) { if (ruby.length) {
for (i = 0; i < ruby.length; i++) { for (i = 0; i < ruby.length; i++) {
html += ruby[i]['orig'] + '<rt>' + ruby[i]['hira'] + '</rt>'; html += ruby[i]['orig'] + '<rt>' + ruby[i]['hira'] + '</rt>';
} }
html = '<ruby>' + html + '</ruby>' html = '<ruby>' + html + '</ruby>'
document.getElementById('rubyword').innerHTML = html
document.getElementById('word').classList.add("hide-style");
} }
else { else {
html = word document.getElementById('rubyword').classList.add("hide-style");
} }
document.getElementById('rubyword').innerHTML = html
</script> </script>

View File

@ -2,25 +2,25 @@
<div id="audio">{{audio}}</div> <div id="audio">{{audio}}</div>
<div id="audio_sentence">{{audio_sentence}}</div> <div id="audio_sentence">{{audio_sentence}}</div>
</div> </div>
<div class="centerdiv"> <div class="centerdiv" onclick='playAudio("audio")'>
<div id="rubyword" class="ruby-div" onclick='playAudio("audio")'></div> <div class="ruby-div" id="word">{{ word }}</div>
<div id="rubyword" class="ruby-div"></div>
</div> </div>
<script> <script>
ruby = {{ rubytext }} ruby = {{ rubytext }}
word = '{{ word }}'
html = '' html = ''
if (ruby.length) { if (ruby.length) {
for (i = 0; i < ruby.length; i++) { for (i = 0; i < ruby.length; i++) {
html += ruby[i]['orig'] + '<rt>' + ruby[i]['hira'] + '</rt>'; html += ruby[i]['orig'] + '<rt>' + ruby[i]['hira'] + '</rt>';
} }
html = '<ruby>' + html + '</ruby>' html = '<ruby>' + html + '</ruby>'
document.getElementById('rubyword').innerHTML = html
document.getElementById('word').classList.add("hide-style");
} }
else { else {
html = word document.getElementById('rubyword').classList.add("hide-style");
} }
document.getElementById('rubyword').innerHTML = html
</script> </script>