diff --git a/app/Modules/Fykos/DefaultModule/DefaultPresenter.php b/app/Modules/Fykos/DefaultModule/DefaultPresenter.php index 395becf5..e2fe11ed 100644 --- a/app/Modules/Fykos/DefaultModule/DefaultPresenter.php +++ b/app/Modules/Fykos/DefaultModule/DefaultPresenter.php @@ -78,7 +78,7 @@ public function loadEventData(): void 'cs' => 'Fyzikální Náboj', 'en' => null ], - 'date' => date('Y-m-d H:i:s', strtotime('2023-11-03 09:00:00')), + 'date' => date('Y-m-d H:i:s', strtotime('2024-11-15 09:00:00')), 'show-in-en' => false ], 'DSEF' => [ @@ -86,7 +86,7 @@ public function loadEventData(): void 'cs' => 'DSEF', 'en' => null ], - 'date' => date('Y-m-d H:i:s', strtotime('2023-11-06 09:00:00')), + 'date' => date('Y-m-d H:i:s', strtotime('2024-10-21 09:00:00')), 'show-in-en' => false ], 'FOL' => [ @@ -94,7 +94,7 @@ public function loadEventData(): void 'cs' => 'Fyziklání Online', 'en' => 'Physics Brawl Online' ], - 'date' => date('Y-m-d H:i:s', strtotime('2023-11-21 17:00:00')), + 'date' => date('Y-m-d H:i:s', strtotime('2024-11-20 17:00:00')), 'show-in-en' => true ], 'FOF' => [ @@ -102,7 +102,7 @@ public function loadEventData(): void 'cs' => 'Fyziklání', 'en' => 'Fyziklani' ], - 'date' => date('Y-m-d H:i:s', strtotime('2024-02-16 10:30:00')), + 'date' => date('Y-m-d H:i:s', strtotime('2025-02-14 10:30:00')), 'show-in-en' => true ], 'serie-1' => [ @@ -110,52 +110,52 @@ public function loadEventData(): void 'cs' => 'Deadline 1. série', 'en' => 'Deadline Series 1' ], - 'date' => date('Y-m-d H:i:s', strtotime('2023-10-10 23:59:59')), + 'date' => date('Y-m-d H:i:s', strtotime('2024-10-06 23:59:59')), 'show-in-en' => true ], - 'serie-2' => [ - 'heading' => [ - 'cs' => 'Deadline 2. série', - 'en' => 'Deadline Series 2' - ], - 'date' => date('Y-m-d H:i:s', strtotime('2023-11-21 23:59:59')), - 'show-in-en' => true + 'serie-2' => [ + 'heading' => [ + 'cs' => 'Deadline 2. série', + 'en' => 'Deadline Series 2' ], - 'serie-3' => [ - 'heading' => [ - 'cs' => 'Deadline 3. série', - 'en' => 'Deadline Series 3' - ], - 'date' => date('Y-m-d H:i:s', strtotime('2024-01-02 23:59:59')), - 'show-in-en' => true + 'date' => date('Y-m-d H:i:s', strtotime('2024-11-24 23:59:59')), + 'show-in-en' => true + ], + 'serie-3' => [ + 'heading' => [ + 'cs' => 'Deadline 3. série', + 'en' => 'Deadline Series 3' ], - 'serie-4' => [ - 'heading' => [ - 'cs' => 'Deadline 4. série', - 'en' => 'Deadline Series 4' - ], - 'date' => date('Y-m-d H:i:s', strtotime('2024-02-27 23:59:59')), - 'show-in-en' => true + 'date' => date('Y-m-d H:i:s', strtotime('2025-01-12 23:59:59')), + 'show-in-en' => true + ], + 'serie-4' => [ + 'heading' => [ + 'cs' => 'Deadline 4. série', + 'en' => 'Deadline Series 4' ], - 'serie-5' => [ - 'heading' => [ - 'cs' => 'Deadline 5. série', - 'en' => 'Deadline Series 5' - ], - 'date' => date('Y-m-d H:i:s', strtotime('2024-04-09 23:59:59')), - 'show-in-en' => true + 'date' => date('Y-m-d H:i:s', strtotime('2025-02-23 23:59:59')), + 'show-in-en' => true + ], + 'serie-5' => [ + 'heading' => [ + 'cs' => 'Deadline 5. série', + 'en' => 'Deadline Series 5' ], - 'serie-6' => [ - 'heading' => [ - 'cs' => 'Deadline 6. série', - 'en' => 'Deadline Series 6' - ], - 'date' => date('Y-m-d H:i:s', strtotime('2024-05-14 23:59:59')), - 'show-in-en' => true + 'date' => date('Y-m-d H:i:s', strtotime('2025-03-30 23:59:59')), + 'show-in-en' => true + ], + 'serie-6' => [ + 'heading' => [ + 'cs' => 'Deadline 6. série', + 'en' => 'Deadline Series 6' + ], + 'date' => date('Y-m-d H:i:s', strtotime('2025-05-11 23:59:59')), + 'show-in-en' => true ] ]; - $this->template->timelineBegin = date('Y-m-d', strtotime('2023-09-01')); - $this->template->timelineEnd = date('Y-m-d', strtotime('2024-05-31')); + $this->template->timelineBegin = date('Y-m-d', strtotime('2024-09-01')); + $this->template->timelineEnd = date('Y-m-d', strtotime('2025-05-31')); } public function findCountdownEventIndices(array $events): array diff --git a/app/Modules/Fykos/DefaultModule/templates/Default/default.latte b/app/Modules/Fykos/DefaultModule/templates/Default/default.latte index 036b4f1a..548da627 100644 --- a/app/Modules/Fykos/DefaultModule/templates/Default/default.latte +++ b/app/Modules/Fykos/DefaultModule/templates/Default/default.latte @@ -649,6 +649,9 @@ {* Timeline data *} +{* Output JSON data in a hidden div to be parsed by JS later *} + +

{$timelineBegin|noescape}

{$timelineEnd|noescape}

{$lang|noescape}

@@ -813,18 +816,54 @@ }); } + // Parse the dates of events for timeline from template data + let eventsJson = document.getElementById('events-data').getAttribute('data-events'); + // console.log("Raw JSON:", eventsJson); // Log the raw JSON string + + let events; + try { + events = JSON.parse(eventsJson); + console.log("Parsed events:", events); // Log the parsed object + } catch (e) { + console.error("Error parsing JSON:", e); + console.log("Problematic JSON string:", eventsJson); + return; // Exit the function if JSON parsing fails + } + + let dates_events = []; + let dates_series = []; + let hide_event_in_en = []; + + let sortedEvents = Object.entries(events).sort((a, b) => new Date(a[1].date) - new Date(b[1].date)); + + sortedEvents.forEach(([key, event]) => { + let date = new Date(event.date); + let formattedDate = date.toISOString().split('T')[0]; // Format as YYYY-MM-DD + + if (key.startsWith('serie-')) { + dates_series.push(formattedDate); + } else { + dates_events.push(formattedDate); + hide_event_in_en.push(!event['show-in-en']); + } + }); - let dates_events = ["2023-11-03", "2023-11-06", "2023-11-22", "2024-02-16"]; + + // let dates_events = ["2023-11-03", "2023-11-06", "2023-11-22", "2024-02-16"]; let images_events_v = ["/images/logos/Naboj_pointer.svg", "/images/logos/DSEF_pointer.svg", "/images/logos/FOL_pointer.svg", "/images/logos/FOF_pointer.svg"]; let images_events_h = ["/images/logos/Naboj_pointer_h.svg", "/images/logos/DSEF_pointer_h.svg", "/images/logos/FOL_pointer_h.svg", "/images/logos/FOF_pointer_h.svg"]; - let dates_series = ["2023-10-10", "2023-11-21", "2024-01-02", "2024-02-27", "2024-04-09", "2024-05-14"]; + // let dates_series = ["2023-10-10", "2023-11-21", "2024-01-02", "2024-02-27", "2024-04-09", "2024-05-14"]; let images_series_v = ["/images/logos/1_pointer.svg", "/images/logos/2_pointer.svg", "/images/logos/3_pointer.svg", "/images/logos/4_pointer.svg", "/images/logos/5_pointer.svg", "/images/logos/6_pointer.svg"]; let images_series_h = ["/images/logos/1_pointer_h.svg", "/images/logos/2_pointer_h.svg", "/images/logos/3_pointer_h.svg", "/images/logos/4_pointer_h.svg", "/images/logos/5_pointer_h.svg", "/images/logos/6_pointer_h.svg"]; - let hide_event_in_en = [true, true, false, false]; + // let hide_event_in_en = [true, true, false, false]; + + // console.log("dates_events:", dates_events); + // console.log("dates_series:", dates_series); + // console.log("hide_event_in_en:", hide_event_in_en); let lang = document.querySelector('.dummy-lang p').innerText.trim();