From 227e1e638a32132ac913d4c52122825b48f751fe Mon Sep 17 00:00:00 2001 From: Anthony Chen <50970130+achen318@users.noreply.github.com> Date: Mon, 13 Nov 2023 17:24:55 -0500 Subject: [PATCH] Add alert for start and end times --- src/pages/calendar/index.astro | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/pages/calendar/index.astro b/src/pages/calendar/index.astro index da74ad3..2c329c5 100644 --- a/src/pages/calendar/index.astro +++ b/src/pages/calendar/index.astro @@ -1,5 +1,6 @@ --- import PageSite from "@layouts/PageSite.astro"; + --- @@ -10,6 +11,15 @@ import PageSite from "@layouts/PageSite.astro"; import googleCalendarPlugin from "@fullcalendar/google-calendar"; import dayGridPlugin from "@fullcalendar/daygrid"; import timeGridPlugin from "@fullcalendar/timegrid"; + + function timeFormat(date) { + return date.toLocaleTimeString([], { + hour: "numeric", + minute: "2-digit", + hour12: true, + }); + } + document.addEventListener("DOMContentLoaded", function () { var calendarEl = document.getElementById("calendar"); if (!calendarEl) throw new Error("Calendar element not found"); @@ -49,12 +59,11 @@ import PageSite from "@layouts/PageSite.astro"; "stuypulse.com_oqgqev21591htqsjdhhg34mh3k@group.calendar.google.com", }, ], - eventClick: function (arg) { - // opens events in a popup window - window.open(arg.event.url); + eventClick: function ({event, jsEvent}) { + alert(`${event.title} (${timeFormat(event.start)} - ${timeFormat(event.end)})`); // prevents current tab from navigating - arg.jsEvent.preventDefault(); + jsEvent.preventDefault(); }, }); calendar.render();