finished refactoring popup.js

This commit is contained in:
Sriram Hariharan
2019-08-13 14:25:30 -05:00
parent c3d243c471
commit 5c5cc48bb5
10 changed files with 288 additions and 267 deletions

View File

@@ -123,6 +123,10 @@ function updateAllTabsCourseList() {
});
}
function htmlToNode(response) {
return $('<div/>').html(response).contents();
}
function setCurrentTabUrl(link) {
chrome.tabs.query({
currentWindow: true,
@@ -208,6 +212,26 @@ function findLocation(day, timearr, datetimearr) {
}
}
function validateCourses(courses) {
for (var i = 0; i < courses.length; i++) {
if (!validateCourseObject(courses[i])) {
return false;
}
}
return true;
}
function validateCourseObject(course) {
var is_valid = true;
var props = ["coursename", "datetimearr", "link", "profname", "status", "unique"];
for (let j = 0; j < props.length; j++) {
is_valid &= course.hasOwnProperty(props[j]);
}
return is_valid;
}
function reformatDateTime(dtl1) {
let output = "";
for (let i = 0; i < dtl1.length; i++) {