Skip to content

Commit

Permalink
Fix calendar parsing for new MyUW Vue schedule cards
Browse files Browse the repository at this point in the history
  • Loading branch information
timtim17 committed Apr 7, 2022
1 parent 31658d6 commit a44c423
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
20 changes: 11 additions & 9 deletions js/insertButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ function addButton(schedule) {
}

function grabSchedule () {
console.log("Test");
window.postMessage({ type: "schedule", schedule: JSON.stringify(WSData.course_data_for_term(VisualScheduleCard.term))}, "*");
window.postMessage({ type: "newTab", newSchedule: JSON.stringify(WSData.course_data_for_term(VisualScheduleCard.term))}, "*");
const schedule = document.getElementById('myuw-visual-schedule').__vue__.$store.state.visual_schedule.value.current;
schedule.sections = schedule.periods[0].sections;
window.postMessage({ type: "schedule", schedule: JSON.stringify(schedule)}, "*");
window.postMessage({ type: "newTab", newSchedule: JSON.stringify(schedule)}, "*");
}

let oldHandler = VisualScheduleCard.render_handler;
VisualScheduleCard.render_handler = function() {
oldHandler();
addButton(VisualScheduleCard.dom_target[0])
}
VisualScheduleCard.render_init()
const buttonTimer = setInterval(() => {
const ele = document.getElementById('myuw-visual-schedule');
if (ele) {
addButton(ele.children[0]);
clearInterval(buttonTimer);
}
}, 500);
7 changes: 3 additions & 4 deletions js/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ function Schedule(newSchedule) {
location = "Room TBD";
}

let dateSplit = response.term.first_day_quarter.split('-');
let first_day = new Date(dateSplit[0], dateSplit[1] - 1, dateSplit[2]);
let first_day = new Date(response.term.first_day_quarter);
if (days.length > 0) {
while (!days.includes(this.WEEKDAYS[first_day.getDay()])) {
first_day.setDate(first_day.getDate() + 1);
Expand Down Expand Up @@ -65,8 +64,8 @@ function Schedule(newSchedule) {
"title": section.curriculum_abbr + " " + section.course_number + " (" + type + ")",
"description": section.curriculum_abbr + " " + section.course_number + " - " + section.course_title,
"location": location,
"start_time": (section.meetings[j].start_time) ? (first_day.toISOString().substring(0, 10) + " " + section.meetings[j].start_time) : null,
"end_time": (section.meetings[j].start_time) ? (first_day.toISOString().substring(0, 10) + " " + section.meetings[j].end_time) : null,
"start_time": (section.meetings[j].start_time) ? (first_day.toISOString().substring(0, 10) + "T" + section.meetings[j].start_time.substring(11)) : null,
"end_time": (section.meetings[j].start_time) ? (first_day.toISOString().substring(0, 10) + "T" + section.meetings[j].end_time.substring(11)) : null,
"freq": "WEEKLY",
"until": end_date.toString(),
"byday": days
Expand Down

0 comments on commit a44c423

Please sign in to comment.