Skip to content

Commit

Permalink
auto set type for opps
Browse files Browse the repository at this point in the history
  • Loading branch information
domlet committed Jul 6, 2024
1 parent 9e37980 commit 483b0d9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
34 changes: 18 additions & 16 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,24 @@ <h3>SS</h3>

<!-- Upcoming Events -->
<a href='https://calendar.google.com/calendar/u/0/embed?src=ccpaedu.com_ftu0la54kio0crhh83m267lri8@group.calendar.google.com&ctz=America/Los_Angeles&mode=AGENDA' class="lowkey" target="_blank">
<div class="py-2 d-flex flex-column flex-sm-row container-fluid" id="events">
<div class="flex-fill col-12 col-sm-3 pl-sm-3 pt-2">
<h2>Student Holidays:</h2>
<ul id="events-student-holiday"></ul>
</div>
<div class="flex-fill col-12 col-sm-3 pt-2">
<h2>Student Activities:</h2>
<ul id="events-student-activities"></ul>
</div>
<div class="flex-fill col-12 col-sm-3 pt-2">
<h2>Dates to Note:</h2>
<ul id="events-student-non-holiday"></ul>
</div>
<div class="flex-fill col-12 col-sm-3 pt-2">
<h2>Opportunities:</h2>
<ul id="events-student-opps"></ul>
<div class="container-fluid py-2" id="events">
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-12 pt-2">
<h2>Student Holidays:</h2>
<ul id="events-student-holiday"></ul>
</div>
<div class="col-lg-3 col-md-6 col-sm-12 pt-2">
<h2>Student Activities:</h2>
<ul id="events-student-activities"></ul>
</div>
<div class="col-lg-3 col-md-6 col-sm-12 pt-2">
<h2>Dates to Note:</h2>
<ul id="events-student-non-holiday"></ul>
</div>
<div class="col-lg-3 col-md-6 col-sm-12 pt-2">
<h2>Opportunities:</h2>
<ul id="events-student-opps"></ul>
</div>
</div>
</div>
</a>
Expand Down
27 changes: 13 additions & 14 deletions script/scriptEventLists.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ $(document).ready(function () {
const gCalkey = "AIzaSyDdvMUXW8jaNxCfVZQv3vKbaL4nTzhygMI"; // https://console.cloud.google.com/apis/credentials/
// for each of the calendars, get valid events and reformat them.
for (let i = 0; i < calendarIdsList.length; i++) {
console.log(calendarIdsList.length + " calendars here");
let calendarId = calendarIdsList[i];
let url = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events?timeMin=${timeMin}&key=${gCalkey}`;
let response = await fetch(url);
Expand All @@ -26,18 +25,17 @@ $(document).ready(function () {
gCalActiveEvents = gCalevents.filter(
(item) => item.status !== "cancelled"
);
console.log(
"Cal " + i + " has " + gCalActiveEvents.length + " active events."
);

// push each event (from each calendar) into the combinedGCalEvents array
for (let i = 0; i < gCalActiveEvents.length; i++) {
if (
calendarId ==
"a71ff6b63e1709ae2bfbcada2b3b64ebeb1f7f5e30787b2bb059725fa17b7b2b@group.calendar.google.com"
) {
gCalActiveEvents[i].eventType = "opportunity";
}
combinedGCalEvents.push(gCalActiveEvents[i]);
}
console.log(
"combinedGCalEvents has " +
combinedGCalEvents.length +
" active events."
);
}
// Format the object the same way as the SY objects
return combinedGCalEvents.map((item) => {
Expand Down Expand Up @@ -65,6 +63,9 @@ $(document).ready(function () {
item.name.search("Holiday") != -1
) {
item.eventType = "studentHoliday";
} else if (item.eventType == "opportunity") {
// if it's an opportunity calendar it was already set
item.eventType = "opportunity";
} else if (
item.name.search("vs") != -1 ||
item.name.search("ball") != -1 ||
Expand All @@ -76,8 +77,6 @@ $(document).ready(function () {
item.name.search("playoffs") != -1
) {
item.eventType = "studentActivity";
} else if (item.name.search("\\(Free") != -1) {
item.eventType = "opportunity";
} else {
item.eventType = "event";
}
Expand Down Expand Up @@ -120,8 +119,8 @@ function showEvents(eventsArray) {
);
}
// truncate any long titles or desc
if (eventsArray[i].name.length > 18) {
eventsArray[i].name = eventsArray[i].name.substring(0, 18);
if (eventsArray[i].name.length > 20) {
eventsArray[i].name = eventsArray[i].name.substring(0, 20);
}
if (eventsArray[i].description.length > 100) {
eventsArray[i].description = eventsArray[i].description.substring(0, 100);
Expand All @@ -134,7 +133,7 @@ function showEvents(eventsArray) {
let eOpps = [];
for (i in eventsArray) {
// Collect only future events
if (eventsArray[i].beg > dateToday) {
if (eventsArray[i].end > dateToday) {
// Collect future holidays:
if (eventsArray[i].eventType == "studentHoliday") {
eHoliday.push(eventsArray[i]);
Expand Down

0 comments on commit 483b0d9

Please sign in to comment.