Fakultas Ilmu Komputer UI

Commit bc55e6e0 authored by Farid Wajdi's avatar Farid Wajdi
Browse files

Create grouping functionality

parent 0e45f73a
......@@ -8,21 +8,30 @@ for (var i = 0; i < courses.length; i++) {
const courseNode = courses[i];
const courseTitle = courseNode.getElementsByTagName("a")[0].title
const courseUrl = courseNode.getElementsByTagName("a")[0].href
const courseId = courseUrl.slice(courseUrl.indexOf("id=") + 3)
const courseSemester = getCourseSemester(courseId, courseGroup)
const courseId = parseInt(courseUrl.slice(courseUrl.indexOf("id=") + 3))
var courseSemester = null
try {
courseSemester = getCourseSemester(courseId, courseGroup)
} catch (error) {
continue;
}
if (!coursePerSemester.hasOwnProperty(courseSemester)) {
coursePerSemester[courseSemester] = []
}
coursePerSemester[courseSemester].push(courseNode);
};
// Creating new course list
myCoursesDiv.getElementsByClassName("unlist")[0].remove();
var newCourseList = document.createElement("ul");
newCourseList.setAttribute("class","unlist");
// for (let i = 0; i < gasal2015.length; i++) {
// const element = gasal2015[i];
// newCourseList.appendChild(element)
// }
for (var key in coursePerSemester) {
if (!courseGroup.hasOwnProperty(key)) continue;
var courseNodes = coursePerSemester[key];
newCourseList.appendChild(document.createTextNode(key))
courseNodes.forEach(element => {
newCourseList.appendChild(element)
});
}
var courseFooter = myCoursesDiv.getElementsByClassName("footer")[0];
myCoursesContent.insertBefore(newCourseList, courseFooter);
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