This commit is contained in:
ken 2026-09-08 20:41:40 +08:00
parent 2a5643caec
commit 0eb84cdd50
1 changed files with 21 additions and 7 deletions

View File

@ -51,9 +51,7 @@
} }
function checkEventStatus() { function checkEventStatus() {
// ✅ 今天日期(時間歸零,只比較日期部分) var now = new Date(); // 直接用現在時間(含時分)
var today = new Date();
today.setHours(0, 0, 0, 0);
$('.index-eventnews-22 .i-annc__item').each(function() { $('.index-eventnews-22 .i-annc__item').each(function() {
var $item = $(this); var $item = $(this);
@ -62,13 +60,12 @@
if (endDateText.length > 0) { if (endDateText.length > 0) {
var endDate = new Date(endDateText); var endDate = new Date(endDateText);
endDate.setHours(0, 0, 0, 0);
// ✅ 結束日期 < 今天 → 才算截標 // 結束時間 < 現在時間 → 才算截標
if (endDate < today) { if (endDate < now) {
$item.find('.list-news-date').css({ $item.find('.list-news-date').css({
'background-color': '#ccc', 'background-color': '#ccc',
'background': '#ccc' 'background' : '#ccc'
}); });
var $title = $item.find('.i-annc__title'); 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() { $(document).ready(function() {
formatAnncDate(); formatAnncDate();
checkEventStatus(); checkEventStatus();
sortEventItems(); // 最後才排序
}); });
</script> </script>
<style> <style>