116 lines
4.1 KiB
HTML
Raw Normal View History

2024-05-16 01:36:03 +08:00
<div class="hide-style">
2024-09-16 12:12:09 +08:00
<div id="audio">{{audio_for_word}}</div>
<div id="audio_sentence">{{audio_for_example_sentence}}</div>
2024-05-16 01:36:03 +08:00
</div>
2024-05-16 23:16:24 +08:00
<div class="centerdiv" onclick='playAudio("audio")'>
<div class="ruby-div" id="word">{{ word }}</div>
2024-09-16 12:12:09 +08:00
<div id="rubyword" class="ruby-div">{{ rubytextHtml }}</div>
2024-05-15 15:57:45 +08:00
</div>
<script>
2024-09-16 12:12:09 +08:00
if (document.getElementById('rubyword').innerHTML.trim().length > 0) {
2024-05-16 23:16:24 +08:00
document.getElementById('word').classList.add("hide-style");
2024-05-15 15:57:45 +08:00
}
2024-05-16 14:14:44 +08:00
else {
2024-05-16 23:16:24 +08:00
document.getElementById('rubyword').classList.add("hide-style");
2024-05-16 14:14:44 +08:00
}
2024-05-15 15:57:45 +08:00
</script>
2024-05-25 01:37:53 +08:00
<div id="example_sentence" class="example-div" onclick='playAudio("audio_sentence")'>
2024-05-15 15:57:45 +08:00
{{example_sentence}}
</div>
<div id="image" class="centerdiv">
2024-09-16 12:12:09 +08:00
{{screenshot}}
2024-05-15 15:57:45 +08:00
</div>
2024-10-26 16:15:41 +08:00
<div id="remarks" class="centerdiv centertext remark-div">
2024-05-16 12:31:15 +08:00
{{remarks}}
</div>
2024-05-15 15:57:45 +08:00
<div class="tab-widget">
2024-05-30 14:24:31 +08:00
<div class="centerdiv" id="tab_buttons">
2024-05-15 15:57:45 +08:00
</div>
<div class="centerdiv">
<div class="tab-content" id="tab_contents">
</div>
</div>
</div>
<script>
2024-05-19 00:20:36 +08:00
function onclickbtn(_id) {
2024-05-20 20:53:28 +08:00
2024-06-02 22:45:40 +08:00
var tabButtons = document.querySelectorAll('.tab-widget .tab-button');
var tabPanes = document.querySelectorAll('.tab-widget .tab-pane');
for (var i = 0; i < tabButtons.length; i++)
2024-05-19 00:20:36 +08:00
tabButtons[i].classList.remove('active');
2024-06-02 22:45:40 +08:00
for (var i = 0; i < tabPanes.length; i++)
2024-05-19 00:20:36 +08:00
tabPanes[i].classList.remove('active');
2024-09-16 12:12:09 +08:00
document.getElementById('luna_dict_btn_' + _id).classList.add('active');
document.getElementById('luna_dict_tab_' + _id).classList.add('active');
2024-05-19 00:20:36 +08:00
}
2024-09-16 12:12:09 +08:00
</script>
<script>
var dictionaryInfo = {{ dictionaryInfo }};
2024-09-16 13:52:58 +08:00
var dictionaryContent = {{ dictionaryContent }}
2024-09-16 12:12:09 +08:00
var htmltabbuttons = ''
var htmlcontents = ''
2024-06-02 22:45:40 +08:00
var scriptElementss = []
2024-10-01 22:58:41 +08:00
var scriptElementsssrc = []
2024-09-16 12:12:09 +08:00
for (var iiii = 0; iiii < dictionaryInfo.length; iiii++) {
htmltabbuttons += '<button type="button" onclick="onclickbtn(\'' + dictionaryInfo[iiii]['dict'] + '\')" id="luna_dict_btn_' + dictionaryInfo[iiii]['dict'] + '" class="tab-button">' + dictionaryInfo[iiii]['name'] + '</button>'
2024-05-15 15:57:45 +08:00
2024-06-02 22:45:40 +08:00
var tempParent = document.createElement('div');
2024-09-16 13:52:58 +08:00
tempParent.innerHTML = decodeURIComponent(dictionaryContent[dictionaryInfo[iiii]['dict']]);
2024-05-15 15:57:45 +08:00
2024-06-02 22:45:40 +08:00
var fragment = document.createElement('div');
2024-05-20 20:53:28 +08:00
while (tempParent.firstChild) {
fragment.appendChild(tempParent.firstChild);
}
2024-09-16 12:12:09 +08:00
htmlcontents += '<div id="luna_dict_tab_' + dictionaryInfo[iiii]['dict'] + '" class="tab-pane">' + fragment.innerHTML + '</div>'
2024-06-02 22:45:40 +08:00
var scriptElements = fragment.getElementsByTagName('script');
2024-05-20 20:53:28 +08:00
2024-06-02 22:45:40 +08:00
for (var jjjj = 0; jjjj < scriptElements.length; jjjj++) {
2024-05-20 20:53:28 +08:00
scriptElementss.push(scriptElements[jjjj].textContent)
2024-10-01 22:58:41 +08:00
scriptElementsssrc.push(scriptElements[jjjj].src)
2024-05-20 20:53:28 +08:00
}
}
2024-09-16 12:12:09 +08:00
document.getElementById('tab_buttons').innerHTML = htmltabbuttons
document.getElementById('tab_contents').innerHTML = htmlcontents
2024-06-02 22:45:40 +08:00
for (var iiii = 0; iiii < scriptElementss.length; iiii++) {
2024-05-20 20:53:28 +08:00
eval(scriptElementss[iiii])
2024-10-01 22:58:41 +08:00
let newScript = document.createElement('script')
if (scriptElementsssrc[iiii]) {
newScript.src = scriptElementsssrc[iiii];
document.head.appendChild(newScript);
}
2024-05-15 15:57:45 +08:00
}
2024-09-16 12:12:09 +08:00
if (dictionaryInfo.length > 0) {
onclickbtn(dictionaryInfo[0]['dict'])
}
2024-05-15 15:57:45 +08:00
</script>
<script>
2024-05-16 01:36:03 +08:00
function playAudio(audioId) {
2024-06-02 22:45:40 +08:00
var audioDiv = document.getElementById(audioId);
var audio = audioDiv.getElementsByTagName('*');
2024-05-16 01:36:03 +08:00
if (audio.length > 0) {
audio[0].click();
}
}
2024-05-15 15:57:45 +08:00
function checkhide(eid) {
2024-06-02 22:45:40 +08:00
var emptyDiv = document.getElementById(eid);
2024-05-15 15:57:45 +08:00
if (emptyDiv && emptyDiv.innerText.trim() === "") {
emptyDiv.classList.add("hide-style");
}
}
function checkhide2(eid) {
2024-06-02 22:45:40 +08:00
var emptyDiv = document.getElementById(eid);
2024-05-15 15:57:45 +08:00
if (emptyDiv && emptyDiv.children.length == 0) {
emptyDiv.classList.add("hide-style");
}
}
checkhide("example_sentence")
checkhide2("image")
checkhide("remarks")
2024-06-02 22:45:40 +08:00
</script>