diff --git a/modules/event_news_mod/event_news_index22.html.erb b/modules/event_news_mod/event_news_index22.html.erb index 4ef5b2c..9c8b093 100644 --- a/modules/event_news_mod/event_news_index22.html.erb +++ b/modules/event_news_mod/event_news_index22.html.erb @@ -51,9 +51,7 @@ } function checkEventStatus() { - // ✅ 今天日期(時間歸零,只比較日期部分) - var today = new Date(); - today.setHours(0, 0, 0, 0); + var now = new Date(); // 直接用現在時間(含時分) $('.index-eventnews-22 .i-annc__item').each(function() { var $item = $(this); @@ -62,13 +60,12 @@ if (endDateText.length > 0) { var endDate = new Date(endDateText); - endDate.setHours(0, 0, 0, 0); - // ✅ 結束日期 < 今天 → 才算截標 - if (endDate < today) { + // 結束時間 < 現在時間 → 才算截標 + if (endDate < now) { $item.find('.list-news-date').css({ 'background-color': '#ccc', - 'background': '#ccc' + 'background' : '#ccc' }); var $title = $item.find('.i-annc__title'); @@ -79,10 +76,27 @@ } }); } + function sortEventItems() { + var $list = $('.index-eventnews-22 .i-annc__list'); + + $list.each(function() { + var $items = $(this).find('> .i-annc__item'); + var $active = $items.filter(function() { + return $(this).find('.closed-title').length === 0; + }); + var $closed = $items.filter(function() { + return $(this).find('.closed-title').length > 0; + }); + + // 未結束的排前面,已結束的排後面 + $(this).append($active).append($closed); + }); + } $(document).ready(function() { formatAnncDate(); checkEventStatus(); + sortEventItems(); // 最後才排序 });