Fix(fortune): special_events_index is undefined when there are no special events today (#67)

This commit was merged in pull request #67.
This commit is contained in:
tobiichi3227
2025-03-09 17:00:44 +08:00
committed by GitHub
parent f9f0f9c1a4
commit c80c879af1

View File

@@ -353,9 +353,11 @@ async function init_page() {
} }
} }
special_events_index = ip.split(".").map(num => parseInt(num)).reduce((acc, cur) => acc + cur); if (current_day_special_events.length) {
special_events_index %= current_day_special_events.length; special_events_index = ip.split(".").map(num => parseInt(num)).reduce((acc, cur) => acc + cur);
special_events_index = current_day_special_events[special_events_index]; special_events_index %= current_day_special_events.length;
special_events_index = current_day_special_events[special_events_index];
}
// if there is upcoming event then show // if there is upcoming event then show
for (let eventIndex = 0; eventIndex < showSpecialEventCount; eventIndex++) { for (let eventIndex = 0; eventIndex < showSpecialEventCount; eventIndex++) {