97 lines
2.8 KiB
ERB
Executable File
97 lines
2.8 KiB
ERB
Executable File
<style>
|
|
.universal-table-show {
|
|
border: 0;
|
|
border-collapse: collapse;
|
|
tr{
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
}
|
|
}
|
|
.universal-table-show.table td{
|
|
padding: 0;
|
|
border: 0;
|
|
}
|
|
.table-title {
|
|
border-right: 0;
|
|
font-size: 0.8em;
|
|
}
|
|
|
|
|
|
</style>
|
|
<table class="table table-striped universal-table-show">
|
|
<tbody data-level="0" data-list="entry">
|
|
<tr>
|
|
<td class="col-sm-12 table-title">{{title}}</td>
|
|
<td class="col-sm-12 table-txt">{{text}}</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<div class="col-sm-12 table-title" style="background-color: #f8f8f8;
|
|
position: relative;
|
|
width: 100%;
|
|
color: #676767;
|
|
padding-top: 1.5em;">相關詞目</div>
|
|
<div data-list="related_entries" data-level="0" class="related_entries">
|
|
<tbody data-level="1" data-list="related_entry">
|
|
<tr>
|
|
<td>{{text}}</td>
|
|
</tr>
|
|
</tbody>
|
|
</div>
|
|
<div class="view_count pull-right">
|
|
<i class="fa fa-eye">{{view_count_head}}:</i>
|
|
<span class="view-count">{{view_count}}</span>
|
|
</div>
|
|
<script>
|
|
$(document).ready(function () {
|
|
const $tableShow = $('.universal-table-show');
|
|
if ($tableShow.length > 0) {
|
|
const firstText = $tableShow.find('tr:first .table-txt:first').text().trim();
|
|
if (firstText) {
|
|
const $li = $('<li>').text(firstText);
|
|
$('.breadcrumb').append($li);
|
|
}
|
|
}
|
|
});
|
|
$(document).ready(function () {
|
|
$('.related_entries').each(function () {
|
|
const $container = $(this);
|
|
const children = $container.contents();
|
|
let wrapper = null;
|
|
|
|
children.each(function () {
|
|
const $el = $(this);
|
|
|
|
if ($el.is('a') && !$el.hasClass('tag')) {
|
|
// 開始一個新的 wrapper
|
|
wrapper = $('<div class="column_entry_files_wrapper"></div>');
|
|
$container.append(wrapper); // 先加到底部
|
|
wrapper.append($el); // 把主詞條加進 wrapper
|
|
} else if ($el.is('ul.column_entry_files')) {
|
|
if (wrapper) wrapper.append($el);
|
|
} else if (this.nodeType === Node.TEXT_NODE && this.textContent.trim() !== '') {
|
|
if (wrapper) wrapper.append(this);
|
|
} else if ($el.is('a.tag')) {
|
|
if (wrapper) wrapper.append($el);
|
|
}
|
|
});
|
|
|
|
// 第二輪:移除每個 .column_entry_files_wrapper 前的 空白節點
|
|
$container.find('.column_entry_files_wrapper').each(function () {
|
|
let prev = this.previousSibling;
|
|
while (prev && prev.nodeType === Node.TEXT_NODE) {
|
|
if (prev.textContent.trim() === '' || prev.textContent.includes('\u00a0')) {
|
|
let toRemove = prev;
|
|
prev = prev.previousSibling;
|
|
toRemove.parentNode.removeChild(toRemove);
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
</script>
|