fixed some bugs

This commit is contained in:
sghsri
2018-09-06 14:46:25 -05:00
parent 9590a2037e
commit 2869d12e9b
3 changed files with 14 additions and 10 deletions

View File

@@ -18,15 +18,19 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
} else if (request.command == "updateTabs") {
updateTabs();
} else if(request.command == "updateCourseList"){
//updated;
chrome.tabs.query({}, function (tabs) {
for (var i = 0; i < tabs.length; i++) {
chrome.tabs.sendMessage(tabs[i].id, {
command: "updateCourseList"
});
}
});
} else {
const xhr = new XMLHttpRequest();
const method = request.method ? request.method.toUpperCase() : "GET";
xhr.open(method, request.url, true);
xhr.onload = () => response(xhr.responseText);
xhr.onerror = () => response(xhr.statusText);
console.log(request);
console.log(sender);
if (method == "POST") {
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
@@ -192,7 +196,7 @@ function updateTabs() {
});
}
setInterval(updateStatus, 60*1000);
setInterval(updateStatus, 2*60*1000);
function updateStatus() {
chrome.storage.sync.get('savedCourses', function (data) {
@@ -216,6 +220,6 @@ function updateStatus() {
chrome.storage.sync.set({
savedCourses: courses
});
console.log(courses);
console.log("updated status' and registerlinks");
});
}

View File

@@ -65,8 +65,8 @@ $(function () {
$("#prof").html(`with <span style='font-weight:bold;'>${uncapProf}</span>`);
let status = savedCourses[currindex].status;
if (status.includes("closed") || status.includes("cancelled")) {
$("#register").text("Class Closed").css("background-color", "#FF5722");
if (status.includes("closed") || status.includes("cancelled") || !status) {
$("#register").text("Cannot Register").css("background-color", "#FF5722");
} else if (status.includes("waitlisted")) {
$("#register").text("Join Waitlist").css("background-color", "#FF9800");
} else {

View File

@@ -90,8 +90,8 @@ $(document).ready(function () {
});
let status = courses[$(this).closest("li").attr("id")].status;
if (status.includes("closed") || status.includes("cancelled")) {
$(this).find("#register").text("Class Closed").css("background-color","#FF5722");
if (status.includes("closed") || status.includes("cancelled")|| !status) {
$(this).find("#register").text("Cannot Register").css("background-color","#FF5722");
}
else {
if(status.includes("waitlisted")){