Skip to content

Commit

Permalink
update dates + half-automatize
Browse files Browse the repository at this point in the history
  • Loading branch information
vanekm committed Aug 21, 2024
1 parent 7069058 commit 723ed8d
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 45 deletions.
84 changes: 42 additions & 42 deletions app/Modules/Fykos/DefaultModule/DefaultPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,84 +78,84 @@ 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' => [
'heading' => [
'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' => [
'heading' => [
'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' => [
'heading' => [
'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' => [
'heading' => [
'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
Expand Down
45 changes: 42 additions & 3 deletions app/Modules/Fykos/DefaultModule/templates/Default/default.latte
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,9 @@
{* Timeline data *}
{* Output JSON data in a hidden div to be parsed by JS later *}
<div id="events-data" style="display:none;" data-events='{json_encode($events)|noescape}'></div>
<div class="dummy-timeline-begin d-none"><p>{$timelineBegin|noescape}</p></div>
<div class="dummy-timeline-end d-none"><p>{$timelineEnd|noescape}</p></div>
<div class="dummy-lang d-none"><p>{$lang|noescape}</p></div>
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 723ed8d

Please sign in to comment.