From 259cc5bbd5050d09322b0a067bcf50e4074a8d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torben=20B=C3=B6hnke?= <torben.boehnke-makerspace@ruhr-uni-bochum.de> Date: Thu, 7 Sep 2023 17:46:10 +0200 Subject: [PATCH] build --- public/en/designlabor/index.html | 2 +- public/en/dha/index.html | 2 +- public/en/fkb/index.html | 2 +- public/en/javascripts/colorswitchcalendar2.js | 2 +- public/en/javascripts/ics_calendar2.js | 144 ++++++++++++++---- public/en/medienlabor/index.html | 2 +- public/en/team/index.html | 2 +- public/feed_rss_created.xml | 2 +- public/feed_rss_updated.xml | 2 +- public/javascripts/colorswitchcalendar2.js | 2 +- public/javascripts/ics_calendar2.js | 144 ++++++++++++++---- public/medienlabor/index.html | 2 +- public/sitemap.xml.gz | Bin 4473 -> 4473 bytes public/th/index.html | 2 +- 14 files changed, 239 insertions(+), 71 deletions(-) diff --git a/public/en/designlabor/index.html b/public/en/designlabor/index.html index 050900408..9007c601d 100644 --- a/public/en/designlabor/index.html +++ b/public/en/designlabor/index.html @@ -3359,7 +3359,7 @@ https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/source-fil <!-- mkdocs-git-revision-date-localized-plugin --> Last update: - <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-08-25</span> + <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-09-07</span> / Created: diff --git a/public/en/dha/index.html b/public/en/dha/index.html index 49d9ffa23..4128ae51c 100644 --- a/public/en/dha/index.html +++ b/public/en/dha/index.html @@ -3074,7 +3074,7 @@ https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/source-fil <!-- mkdocs-git-revision-date-localized-plugin --> Last update: - <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-08-25</span> + <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-09-07</span> / Created: diff --git a/public/en/fkb/index.html b/public/en/fkb/index.html index 89ac03828..065006975 100644 --- a/public/en/fkb/index.html +++ b/public/en/fkb/index.html @@ -3071,7 +3071,7 @@ https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/source-fil <!-- mkdocs-git-revision-date-localized-plugin --> Last update: - <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-08-25</span> + <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-09-07</span> / Created: diff --git a/public/en/javascripts/colorswitchcalendar2.js b/public/en/javascripts/colorswitchcalendar2.js index 9866f72bb..9b24ac92c 100644 --- a/public/en/javascripts/colorswitchcalendar2.js +++ b/public/en/javascripts/colorswitchcalendar2.js @@ -7,7 +7,7 @@ window.addEventListener('load', function() { if (palette && palette.index === 1) { iframe.src = "../calendar_dark2.html"; } else { - iframe.src = "../calendar.html2"; + iframe.src = "../calendar2.html"; } }, 100); // delay of 100 milliseconds }; diff --git a/public/en/javascripts/ics_calendar2.js b/public/en/javascripts/ics_calendar2.js index 9cba8521d..a1c49d40f 100644 --- a/public/en/javascripts/ics_calendar2.js +++ b/public/en/javascripts/ics_calendar2.js @@ -1,13 +1,6 @@ -let showPastEvents = false; +var showPastEvents = false; // Load iCalendar data -function adjustHeight() { - setTimeout(function() { - var calendarHeight = document.getElementById('calendar').offsetHeight; - window.parent.postMessage({ height: calendarHeight }, '*'); - }, 200); // wait for x milliseconds before measuring -} - window.addEventListener('message', function(event) { adjustHeight(); }, false); @@ -57,35 +50,24 @@ fetchAndParseICS() initialView: initialViewType, customButtons: { togglePastEvents: { - text: 'Toggle Past Events', - click: function() { - showPastEvents = !showPastEvents; - var view = calendar.view; - var displayStyle = view.type.includes('list') ? 'table-row' : 'block'; - var pastEvents = document.querySelectorAll('.past-event'); - pastEvents.forEach(function(eventEl) { - eventEl.style.display = showPastEvents ? displayStyle : 'none'; - }); - if (view.type.includes('list')) { - var pastDays = document.querySelectorAll('.fc-day-past'); - pastDays.forEach(function(dayEl) { - dayEl.style.display = showPastEvents ? 'table-row' : 'none'; - }); - } - adjustHeight(); + text: 'Zeige/Verstecke vergangene Termine', + click: function() { + showPastEvents = !showPastEvents; + handlePastEventsVisibility(); + } } - } }, headerToolbar: { - start: 'prev,next,today,togglePastEvents', + start: 'prev,next,today', center: 'title', - end: 'dayGridMonth,timeGridWeek,timeGridDay,listYear' + end: 'dayGridMonth,listYear' + }, + footerToolbar: { + start: 'togglePastEvents' }, views: { - dayGridMonth: { buttonText: 'Monat'}, + dayGridMonth: { buttonText: 'Kalender'}, listYear: { buttonText: 'Liste' }, - timeGridDay: { buttonText: 'Tag' }, - timeGridWeek: { buttonText: 'Woche' }, }, contentHeight: "auto", events: calendarEvents, @@ -110,6 +92,7 @@ fetchAndParseICS() eventDidMount: function(info) { clearTimeout(debounceTimer); debounceTimer = setTimeout(adjustHeight, 200); + handlePastEventsVisibility(); }, eventWillUnmount: function() { @@ -132,5 +115,106 @@ fetchAndParseICS() calendar.render(); + + function getWeekNumber(d) { + // Copy date so we don't modify the original + d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate())); + // Set to nearest Thursday: current date + 4 - current day number + d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7)); + // Get first day of the year + var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1)); + // Calculate full weeks to nearest Thursday + var weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7); + return weekNo; + } + + function weeks(startDate, endDate) { + var startWeek = getWeekNumber(startDate); + var endWeek = getWeekNumber(endDate); + return (endWeek - startWeek) + 1; + } + + function getVisibleMultiDayEvents(calendarInstance, showPastEvents) { + var view = calendarInstance.view; + var visibleRangeStart = view.activeStart; + var visibleRangeEnd = view.activeEnd; + var currentDate = new Date(); // Current date + + var allEvents = calendarInstance.getEvents(); + var trulyVisibleEvents = allEvents.filter(function(event) { + // If showing past events, or the event end date is in the future + var isEventRelevant = showPastEvents || (event.end || event.start) >= currentDate; + + // Check if the event is within the visible range and is relevant + return event.start < visibleRangeEnd && (event.end || event.start) > visibleRangeStart && isEventRelevant; + }); + + var multiDayEvents = trulyVisibleEvents.filter(function(event) { + var start = event.start; + var end = event.end || start; + return (end.getTime() - start.getTime()) > 86400000; + }); + + return multiDayEvents; + } + + function getMultiDayEventsAdditionalHeight(calendarInstance) { + var additionalHeight = 0; + var multiDayEventHeight = 24.6; // As given by you + + var multiDayEvents = getVisibleMultiDayEvents(calendar, showPastEvents); // You'll need to implement this function + + for (var event of multiDayEvents) { + var startDate = event.start; + var endDate = event.end; + + // Calculate the number of weeks this event spans + var weeksSpanned = weeks(startDate, endDate); // Convert difference to weeks + + additionalHeight += weeksSpanned * multiDayEventHeight; + } + console.log("additionalHeight: ", additionalHeight); + return additionalHeight; + } + + function adjustHeight() { + setTimeout(function() { + var calendarHeight = document.getElementById('calendar').offsetHeight; + var additionalHeight = getMultiDayEventsAdditionalHeight(calendar); + + calendarHeight += additionalHeight; + + window.parent.postMessage({ height: calendarHeight }, '*'); + }, 200); // wait for x milliseconds before measuring + } + + // Show/Hide past events + function handlePastEventsVisibility() { + var view = calendar.view; + var displayStyle = view.type.includes('list') ? 'table-row' : 'block'; + var pastEvents = document.querySelectorAll('.past-event'); + pastEvents.forEach(function(eventEl) { + eventEl.style.display = showPastEvents ? displayStyle : 'none'; + }); + if (view.type.includes('list')) { + var pastDays = document.querySelectorAll('.fc-day-past'); + pastDays.forEach(function(dayEl) { + dayEl.style.display = showPastEvents ? 'table-row' : 'none'; + }); + } + adjustHeight(); + var visibleEvents = calendar.getEvents(); + console.log("All visible events:", visibleEvents); + var multiDayEvents = visibleEvents.filter(function(event) { + var start = event.start; + var end = event.end || start; + return (end.getTime() - start.getTime()) > 86400000; + }); + console.log("Filtered multi-day events:", multiDayEvents); + + } + adjustHeight(); }); + + diff --git a/public/en/medienlabor/index.html b/public/en/medienlabor/index.html index a3c414b9b..8ac908d46 100644 --- a/public/en/medienlabor/index.html +++ b/public/en/medienlabor/index.html @@ -3577,7 +3577,7 @@ https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/source-fil <!-- mkdocs-git-revision-date-localized-plugin --> Last update: - <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-09-01</span> + <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-09-07</span> / Created: diff --git a/public/en/team/index.html b/public/en/team/index.html index 55150c211..e6adafce3 100644 --- a/public/en/team/index.html +++ b/public/en/team/index.html @@ -3482,7 +3482,7 @@ https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/source-fil <!-- mkdocs-git-revision-date-localized-plugin --> Last update: - <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-08-25</span> + <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-09-07</span> / Created: diff --git a/public/feed_rss_created.xml b/public/feed_rss_created.xml index ef70871af..1c5eaff55 100644 --- a/public/feed_rss_created.xml +++ b/public/feed_rss_created.xml @@ -1 +1 @@ -<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel><title>RUB-Makerspace</title><description>Die offene Werkstatt an der RUB</description><link>https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/</link><atom:link href="https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/feed_rss_created.xml" rel="self" type="application/rss+xml" /><docs>https://git.noc.ruhr-uni-bochum.de/makerspace/homepage</docs><language>en</language> <pubDate>Thu, 07 Sep 2023 11:08:53 -0000</pubDate> <lastBuildDate>Thu, 07 Sep 2023 11:08:53 -0000</lastBuildDate> <ttl>1440</ttl> <generator>MkDocs RSS plugin - v1.5.0</generator> <image> <url>https://git.noc.ruhr-uni-bochum.de/makerspace/homepage/-/raw/main/docs/medien/rub-makerspace-logo.svg</url> <title>RUB-Makerspace</title><link>https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/</link> </image> </channel></rss> \ No newline at end of file +<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel><title>RUB-Makerspace</title><description>Die offene Werkstatt an der RUB</description><link>https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/</link><atom:link href="https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/feed_rss_created.xml" rel="self" type="application/rss+xml" /><docs>https://git.noc.ruhr-uni-bochum.de/makerspace/homepage</docs><language>en</language> <pubDate>Thu, 07 Sep 2023 15:43:22 -0000</pubDate> <lastBuildDate>Thu, 07 Sep 2023 15:43:22 -0000</lastBuildDate> <ttl>1440</ttl> <generator>MkDocs RSS plugin - v1.5.0</generator> <image> <url>https://git.noc.ruhr-uni-bochum.de/makerspace/homepage/-/raw/main/docs/medien/rub-makerspace-logo.svg</url> <title>RUB-Makerspace</title><link>https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/</link> </image> </channel></rss> \ No newline at end of file diff --git a/public/feed_rss_updated.xml b/public/feed_rss_updated.xml index c2bd7446c..b5d84786b 100644 --- a/public/feed_rss_updated.xml +++ b/public/feed_rss_updated.xml @@ -1 +1 @@ -<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel><title>RUB-Makerspace</title><description>Die offene Werkstatt an der RUB</description><link>https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/</link><atom:link href="https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/feed_rss_updated.xml" rel="self" type="application/rss+xml" /><docs>https://git.noc.ruhr-uni-bochum.de/makerspace/homepage</docs><language>en</language> <pubDate>Thu, 07 Sep 2023 11:08:53 -0000</pubDate> <lastBuildDate>Thu, 07 Sep 2023 11:08:53 -0000</lastBuildDate> <ttl>1440</ttl> <generator>MkDocs RSS plugin - v1.5.0</generator> <image> <url>https://git.noc.ruhr-uni-bochum.de/makerspace/homepage/-/raw/main/docs/medien/rub-makerspace-logo.svg</url> <title>RUB-Makerspace</title><link>https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/</link> </image> </channel></rss> \ No newline at end of file +<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel><title>RUB-Makerspace</title><description>Die offene Werkstatt an der RUB</description><link>https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/</link><atom:link href="https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/feed_rss_updated.xml" rel="self" type="application/rss+xml" /><docs>https://git.noc.ruhr-uni-bochum.de/makerspace/homepage</docs><language>en</language> <pubDate>Thu, 07 Sep 2023 15:43:22 -0000</pubDate> <lastBuildDate>Thu, 07 Sep 2023 15:43:22 -0000</lastBuildDate> <ttl>1440</ttl> <generator>MkDocs RSS plugin - v1.5.0</generator> <image> <url>https://git.noc.ruhr-uni-bochum.de/makerspace/homepage/-/raw/main/docs/medien/rub-makerspace-logo.svg</url> <title>RUB-Makerspace</title><link>https://makerspace.io.noc.ruhr-uni-bochum.de/homepage/</link> </image> </channel></rss> \ No newline at end of file diff --git a/public/javascripts/colorswitchcalendar2.js b/public/javascripts/colorswitchcalendar2.js index 9866f72bb..9b24ac92c 100644 --- a/public/javascripts/colorswitchcalendar2.js +++ b/public/javascripts/colorswitchcalendar2.js @@ -7,7 +7,7 @@ window.addEventListener('load', function() { if (palette && palette.index === 1) { iframe.src = "../calendar_dark2.html"; } else { - iframe.src = "../calendar.html2"; + iframe.src = "../calendar2.html"; } }, 100); // delay of 100 milliseconds }; diff --git a/public/javascripts/ics_calendar2.js b/public/javascripts/ics_calendar2.js index 9cba8521d..a1c49d40f 100644 --- a/public/javascripts/ics_calendar2.js +++ b/public/javascripts/ics_calendar2.js @@ -1,13 +1,6 @@ -let showPastEvents = false; +var showPastEvents = false; // Load iCalendar data -function adjustHeight() { - setTimeout(function() { - var calendarHeight = document.getElementById('calendar').offsetHeight; - window.parent.postMessage({ height: calendarHeight }, '*'); - }, 200); // wait for x milliseconds before measuring -} - window.addEventListener('message', function(event) { adjustHeight(); }, false); @@ -57,35 +50,24 @@ fetchAndParseICS() initialView: initialViewType, customButtons: { togglePastEvents: { - text: 'Toggle Past Events', - click: function() { - showPastEvents = !showPastEvents; - var view = calendar.view; - var displayStyle = view.type.includes('list') ? 'table-row' : 'block'; - var pastEvents = document.querySelectorAll('.past-event'); - pastEvents.forEach(function(eventEl) { - eventEl.style.display = showPastEvents ? displayStyle : 'none'; - }); - if (view.type.includes('list')) { - var pastDays = document.querySelectorAll('.fc-day-past'); - pastDays.forEach(function(dayEl) { - dayEl.style.display = showPastEvents ? 'table-row' : 'none'; - }); - } - adjustHeight(); + text: 'Zeige/Verstecke vergangene Termine', + click: function() { + showPastEvents = !showPastEvents; + handlePastEventsVisibility(); + } } - } }, headerToolbar: { - start: 'prev,next,today,togglePastEvents', + start: 'prev,next,today', center: 'title', - end: 'dayGridMonth,timeGridWeek,timeGridDay,listYear' + end: 'dayGridMonth,listYear' + }, + footerToolbar: { + start: 'togglePastEvents' }, views: { - dayGridMonth: { buttonText: 'Monat'}, + dayGridMonth: { buttonText: 'Kalender'}, listYear: { buttonText: 'Liste' }, - timeGridDay: { buttonText: 'Tag' }, - timeGridWeek: { buttonText: 'Woche' }, }, contentHeight: "auto", events: calendarEvents, @@ -110,6 +92,7 @@ fetchAndParseICS() eventDidMount: function(info) { clearTimeout(debounceTimer); debounceTimer = setTimeout(adjustHeight, 200); + handlePastEventsVisibility(); }, eventWillUnmount: function() { @@ -132,5 +115,106 @@ fetchAndParseICS() calendar.render(); + + function getWeekNumber(d) { + // Copy date so we don't modify the original + d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate())); + // Set to nearest Thursday: current date + 4 - current day number + d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7)); + // Get first day of the year + var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1)); + // Calculate full weeks to nearest Thursday + var weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7); + return weekNo; + } + + function weeks(startDate, endDate) { + var startWeek = getWeekNumber(startDate); + var endWeek = getWeekNumber(endDate); + return (endWeek - startWeek) + 1; + } + + function getVisibleMultiDayEvents(calendarInstance, showPastEvents) { + var view = calendarInstance.view; + var visibleRangeStart = view.activeStart; + var visibleRangeEnd = view.activeEnd; + var currentDate = new Date(); // Current date + + var allEvents = calendarInstance.getEvents(); + var trulyVisibleEvents = allEvents.filter(function(event) { + // If showing past events, or the event end date is in the future + var isEventRelevant = showPastEvents || (event.end || event.start) >= currentDate; + + // Check if the event is within the visible range and is relevant + return event.start < visibleRangeEnd && (event.end || event.start) > visibleRangeStart && isEventRelevant; + }); + + var multiDayEvents = trulyVisibleEvents.filter(function(event) { + var start = event.start; + var end = event.end || start; + return (end.getTime() - start.getTime()) > 86400000; + }); + + return multiDayEvents; + } + + function getMultiDayEventsAdditionalHeight(calendarInstance) { + var additionalHeight = 0; + var multiDayEventHeight = 24.6; // As given by you + + var multiDayEvents = getVisibleMultiDayEvents(calendar, showPastEvents); // You'll need to implement this function + + for (var event of multiDayEvents) { + var startDate = event.start; + var endDate = event.end; + + // Calculate the number of weeks this event spans + var weeksSpanned = weeks(startDate, endDate); // Convert difference to weeks + + additionalHeight += weeksSpanned * multiDayEventHeight; + } + console.log("additionalHeight: ", additionalHeight); + return additionalHeight; + } + + function adjustHeight() { + setTimeout(function() { + var calendarHeight = document.getElementById('calendar').offsetHeight; + var additionalHeight = getMultiDayEventsAdditionalHeight(calendar); + + calendarHeight += additionalHeight; + + window.parent.postMessage({ height: calendarHeight }, '*'); + }, 200); // wait for x milliseconds before measuring + } + + // Show/Hide past events + function handlePastEventsVisibility() { + var view = calendar.view; + var displayStyle = view.type.includes('list') ? 'table-row' : 'block'; + var pastEvents = document.querySelectorAll('.past-event'); + pastEvents.forEach(function(eventEl) { + eventEl.style.display = showPastEvents ? displayStyle : 'none'; + }); + if (view.type.includes('list')) { + var pastDays = document.querySelectorAll('.fc-day-past'); + pastDays.forEach(function(dayEl) { + dayEl.style.display = showPastEvents ? 'table-row' : 'none'; + }); + } + adjustHeight(); + var visibleEvents = calendar.getEvents(); + console.log("All visible events:", visibleEvents); + var multiDayEvents = visibleEvents.filter(function(event) { + var start = event.start; + var end = event.end || start; + return (end.getTime() - start.getTime()) > 86400000; + }); + console.log("Filtered multi-day events:", multiDayEvents); + + } + adjustHeight(); }); + + diff --git a/public/medienlabor/index.html b/public/medienlabor/index.html index fe2bd5106..f9b542aef 100644 --- a/public/medienlabor/index.html +++ b/public/medienlabor/index.html @@ -3573,7 +3573,7 @@ https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/source-fil <!-- mkdocs-git-revision-date-localized-plugin --> Letztes Update: - <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-09-01</span> + <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-09-07</span> / Erstellt: diff --git a/public/sitemap.xml.gz b/public/sitemap.xml.gz index 615354afc1ce7a84dfa958ae424da6226584fe6a..efe29310a2627683adefcd31744f443490d13e13 100644 GIT binary patch delta 15 WcmeyV^izpVzMF$%|ND(>#ex7bgazOL delta 15 WcmeyV^izpVzMF$1bNxoPVnF~eKm|$w diff --git a/public/th/index.html b/public/th/index.html index c59199850..9d5f0b658 100644 --- a/public/th/index.html +++ b/public/th/index.html @@ -3070,7 +3070,7 @@ https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/source-fil <!-- mkdocs-git-revision-date-localized-plugin --> Letztes Update: - <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-08-31</span> + <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-iso_date">2023-09-07</span> / Erstellt: -- GitLab