From 2869d12e9bf1fe2beddbc007a1505412a68dd16e Mon Sep 17 00:00:00 2001 From: sghsri Date: Thu, 6 Sep 2018 14:46:25 -0500 Subject: [PATCH] fixed some bugs --- js/background.js | 16 ++++++++++------ js/calendar.js | 4 ++-- js/popup.js | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/js/background.js b/js/background.js index e7d65697..cd3e7188 100644 --- a/js/background.js +++ b/js/background.js @@ -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) { @@ -214,8 +218,8 @@ function updateStatus() { c.status = newstatus; } chrome.storage.sync.set({ - savedCourses: courses + savedCourses: courses }); - console.log(courses); + console.log("updated status' and registerlinks"); }); } \ No newline at end of file diff --git a/js/calendar.js b/js/calendar.js index adb2772a..739f996e 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -65,8 +65,8 @@ $(function () { $("#prof").html(`with ${uncapProf}`); 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 { diff --git a/js/popup.js b/js/popup.js index d6103977..4af61a4a 100644 --- a/js/popup.js +++ b/js/popup.js @@ -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")){