更新 show.html.erb:ken
This commit is contained in:
parent
9cee46cd13
commit
a43523d91f
|
@ -113,8 +113,14 @@
|
|||
<% ce.column_entry_files.desc(:sort_number).each do |entry_file| %>
|
||||
<% next unless entry_file.choose_lang_display(locale) %>
|
||||
<% if entry_file.file.content_type.start_with?('audio/') %>
|
||||
<%= entry_file.get_file_title %>
|
||||
<a class="voice-player" data-content="<%= entry_file.file.url %>" href="" title="播放讀音"><i class="fa fa-play" aria-hidden="true"></i></a>
|
||||
<li class="pronunciation-wrapper">
|
||||
<%= entry_file.get_file_title %>
|
||||
<a class="voice-player" data-content="<%= entry_file.file.url %>" href="" title="播放讀音">
|
||||
<i class="fa fa-play" aria-hidden="true"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<% else %>
|
||||
<li><%= link_to entry_file.get_file_title, entry_file.file.url, target: "_blank" %></li>
|
||||
<% end %>
|
||||
|
@ -149,6 +155,35 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('.ut-table ol').each(function () {
|
||||
const $ol = $(this);
|
||||
const nodes = Array.from($ol.contents());
|
||||
let currentText = null;
|
||||
|
||||
nodes.forEach(function (node) {
|
||||
// 如果是文字節點,暫存
|
||||
if (node.nodeType === 3 && node.nodeValue.trim() !== '') {
|
||||
currentText = node.nodeValue.trim();
|
||||
node.remove(); // 移除原始文字節點
|
||||
}
|
||||
|
||||
// 如果是 .voice-player,包進 wrapper 並包在 <li>
|
||||
if (node.nodeType === 1 && node.classList.contains('voice-player')) {
|
||||
const $wrapper = $('<div class="pronunciation-wrapper"></div>');
|
||||
if (currentText) {
|
||||
$wrapper.append(document.createTextNode(currentText));
|
||||
currentText = null; // 清空暫存
|
||||
}
|
||||
$wrapper.append($(node));
|
||||
|
||||
const $li = $('<li></li>').append($wrapper);
|
||||
$ol.append($li);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$(".action").after($("#entry-status"));
|
||||
let audio;
|
||||
$(".voice-player").on("click", function(){
|
||||
|
|
Loading…
Reference in New Issue