Fakultas Ilmu Komputer UI

Commit 6f6f1177 authored by wajdifarid's avatar wajdifarid
Browse files

Differentiate assignments based on their dates

parent 9c02c94a
......@@ -28,8 +28,8 @@ for (var key in coursePerSemester) {
if (!courseGroup.hasOwnProperty(key)) continue;
var courseNodes = coursePerSemester[key];
newCourseList.appendChild(document.createTextNode(key))
var courseListCurrentSemester = document.createElement("ul")
newCourseList.appendChild(document.createTextNode(key));
var courseListCurrentSemester = document.createElement("ul");
courseNodes.forEach(element => {
courseListCurrentSemester.appendChild(element)
});
......@@ -38,23 +38,50 @@ for (var key in coursePerSemester) {
var courseFooter = myCoursesDiv.getElementsByClassName("footer")[0];
myCoursesContent.insertBefore(newCourseList, courseFooter);
// This month assignments
const assignmentsThisMonth = document.getElementsByClassName("day hasevent calendar_event_course calendar_event_course");
var d = new Date();
const today = d.getDate();
var assignmentsYesterdayUrls = null
var assignmentsTodayUrls = null
var assignmentsNextWeekUrls = []
// put assignments to their timelines
for (let index = 0; index < assignmentsThisMonth.length; index++) {
const element = assignmentsThisMonth[index];
assignmentDate = parseInt(element.children[0].textContent);
if ( assignmentDate === (today - 1)) {
assignmentsYesterdayUrls = element.children[0].href;
} else if (assignmentDate === today) {
assignmentsTodayUrls = element.children[0].href;
} else if (assignmentDate > today && assignmentDate < (today+7)) {
assignmentsNextWeekUrls.push(element.children[0].href);
}
}
// get assignment urls
var xhr = new XMLHttpRequest();
// get today's assignments
var assignment_urls = null
var assignments = null
var assignmentsTodayHTMLElement = document.createElement("ul");
xhr.onload = function() {
assignment_urls = this.response.getElementsByClassName("referer");
assignments = this.response.getElementsByClassName("box card-header clearfix");
assignments.forEach(element => {
assignmentsTodayHTMLElement.appendChild(htmlToAssignment(element));
});
};
var today_assignment_url = document.getElementsByClassName("today")[0].children[1].href;
xhr.open('GET', today_assignment_url);
xhr.open('GET', today);
xhr.responseType = "document";
xhr.send();
// add listener to send assignments data to popup
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
sendResponse({
message: assignment_urls[0].innerHTML
message: assignments[0].outerHTML,
assignmentsToday: assignmentsTodayHTMLElement.outerHTML,
assignmentsYesterday: "Kemaren",
assignmentsNextWeek: "Mingdep",
});
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment