Skip to content

Commit

Permalink
Add alert for start and end times
Browse files Browse the repository at this point in the history
  • Loading branch information
achen318 committed Nov 13, 2023
1 parent 5eaeba6 commit 227e1e6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/pages/calendar/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
import PageSite from "@layouts/PageSite.astro";
---

<PageSite title="Calendar" description="Calendar for Team 694, used for meeting schedules and competitions.">
Expand All @@ -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");
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 227e1e6

Please sign in to comment.