This commit is contained in:
恍兮惚兮 2024-12-23 03:04:38 +08:00
parent 6e95678be8
commit 006c6b0f0e
3 changed files with 17 additions and 17 deletions

View File

@ -2468,17 +2468,22 @@ class mdict(cishubase):
contents = []
idx = 0
for _, foldflow, title, res in allres:
idx += 1
klass2='tab-pane_mdict_internal'
klass1='tab-button_mdict_internal'
if idx==0:
klass2+=' active'
klass1+=' active'
btns.append(
"""<button type="button" onclick="onclickbtn_mdict_internal('buttonid_mdict_internal{idx}')" id="buttonid_mdict_internal{idx}" class="tab-button_mdict_internal" data-tab="tab_mdict_internal{idx}">{title}</button>""".format(
idx=idx, title=title
"""<button type="button" onclick="onclickbtn_mdict_internal('buttonid_mdict_internal{idx}')" id="buttonid_mdict_internal{idx}" class="{klass}" data-tab="tab_mdict_internal{idx}">{title}</button>""".format(
idx=idx, title=title, klass=klass1
)
)
contents.append(
"""<div id="tab_mdict_internal{idx}" class="tab-pane_mdict_internal">{res}</div>""".format(
idx=idx, res=res
"""<div id="tab_mdict_internal{idx}" class="{klass}">{res}</div>""".format(
idx=idx, res=res, klass=klass2
)
)
idx += 1
commonstyle = """
<script>
function onclickbtn_mdict_internal(_id) {
@ -2506,11 +2511,12 @@ function onclickbtn_mdict_internal(_id) {
}
.tab-widget_mdict_internal .tab-button_mdict_internal {
padding: 10px 20px;
padding: 5px 20px;
background-color: #cccccccc;
border: none;
cursor: pointer;
display: inline-block;
line-height: 25px;
}
.tab-widget_mdict_internal .tab-button_mdict_internal.active {
@ -2541,10 +2547,6 @@ function onclickbtn_mdict_internal(_id) {
</div>
</div>
</div>
<script>
if(document.querySelectorAll('.tab-widget_mdict_internal .tab-button_mdict_internal').length)
document.querySelectorAll('.tab-widget_mdict_internal .tab-button_mdict_internal')[0].click()
</script>
""".format(
commonstyle=commonstyle, btns="".join(btns), contents="".join(contents)
)
@ -2558,7 +2560,7 @@ document.querySelectorAll('.tab-widget_mdict_internal .tab-button_mdict_internal
.collapsible-header {
background-color: #dddddd50;
padding: 10px;
padding: 8px;
cursor: pointer;
border: 1px solid #ddd;
border-bottom: none;

View File

@ -58,7 +58,7 @@
var scriptElementss = []
var scriptElementsssrc = []
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>'
htmltabbuttons += '<button type="button" onclick="onclickbtn(\'' + dictionaryInfo[iiii]['dict'] + '\')" id="luna_dict_btn_' + dictionaryInfo[iiii]['dict'] + '" class="tab-button' + (iiii == 0 ? ' active' : '') + '">' + dictionaryInfo[iiii]['name'] + '</button>'
var tempParent = document.createElement('div');
tempParent.innerHTML = decodeURIComponent(dictionaryContent[dictionaryInfo[iiii]['dict']]);
@ -68,7 +68,7 @@
fragment.appendChild(tempParent.firstChild);
}
htmlcontents += '<div id="luna_dict_tab_' + dictionaryInfo[iiii]['dict'] + '" class="tab-pane">' + fragment.innerHTML + '</div>'
htmlcontents += '<div id="luna_dict_tab_' + dictionaryInfo[iiii]['dict'] + '" class="tab-pane' + (iiii == 0 ? ' active' : '') + '">' + fragment.innerHTML + '</div>'
var scriptElements = fragment.getElementsByTagName('script');
for (var jjjj = 0; jjjj < scriptElements.length; jjjj++) {
@ -86,9 +86,6 @@
document.head.appendChild(newScript);
}
}
if (dictionaryInfo.length > 0) {
onclickbtn(dictionaryInfo[0]['dict'])
}
</script>
<script>
function playAudio(audioId) {

View File

@ -39,11 +39,12 @@
.tab-widget .tab-button {
padding: 10px 20px;
padding: 5px 20px;
background-color: #cccccccc;
border: none;
cursor: pointer;
display: inline-block;
line-height: 25px;
}
.tab-widget .tab-button.active {