From 49c7134ae8077f1df1433af18e91d524d12e65c0 Mon Sep 17 00:00:00 2001 From: ken Date: Tue, 8 Sep 2026 12:58:31 +0800 Subject: [PATCH] update --- assets/javascripts/app.js | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/assets/javascripts/app.js b/assets/javascripts/app.js index ec23187..4e05a5a 100644 --- a/assets/javascripts/app.js +++ b/assets/javascripts/app.js @@ -3420,10 +3420,10 @@ $(function() { // ✅ 計算目前搜尋結果數量並通知 function announceResultCount() { - var $rows = $('.universal-table-show tbody tr:visible'); + // ✅ 改用 .kentbody tr 而不是 tbody tr + var $rows = $('.universal-table-show .kentbody tr'); var count = $rows.length; - // ✅ 只取有值的欄位,且去除重複 var keywords = []; $('input[name^="q["]').each(function() { var val = $(this).val().trim(); @@ -3444,7 +3444,6 @@ $(function() { : '共找到 ' + count + ' 筆資料。'; } - // ✅ 清空再設定,確保 aria-live 每次都觸發 $('#search-result-status').text(''); setTimeout(function() { $('#search-result-status').text(message); @@ -3484,13 +3483,33 @@ $(function() { setTimeout(function() { $('.tdken').each(function() { var $tr = $(this); - var href = $tr.find('a').first().attr('href'); - var title = $tr.find('a').first().attr('title') || ''; + var $firstA = $tr.find('a').first(); + var href = $firstA.attr('href'); + var title = $firstA.attr('title') || ''; if (href) { + // ✅ 去掉 title 裡的開窗字串,避免與 linkText 重複 + var titleWithoutWindow = title + .replace(/\(在本視窗開啟\)/g, '') + .replace(/\(在新視窗開啟\)/g, '') + .replace(/在本視窗開啟/g, '') + .replace(/在新視窗開啟/g, '') + .replace(/Open in this window/g, '') + .replace(/Open in new window/g, '') + .trim(); + + var isNewWindow = $firstA.attr('target') === '_blank'; + var windowText = isNewWindow ? '(在新視窗開啟)' : '(在本視窗開啟)'; + var linkText = $firstA.text().trim(); + + // ✅ titleWithoutWindow 若與 linkText 相同或為空,只用 linkText + 開窗提示 + var ariaLabel = (titleWithoutWindow && titleWithoutWindow !== linkText) + ? titleWithoutWindow + ' ' + windowText + : linkText + ' ' + windowText; + $tr.css('cursor', 'pointer') .attr('role', 'link') - .attr('aria-label', $tr.find('a').first().text().trim() + ' ' + title); + .attr('aria-label', ariaLabel); $tr.on('click', function(e) { if (!$(e.target).is('a')) {