From 9a02248a81e85e5a282b83f670d52804cb568649 Mon Sep 17 00:00:00 2001 From: Kevin Dao Date: Tue, 28 Aug 2018 18:07:59 -0500 Subject: [PATCH] Added condition for resetting storage on update and updated schedule margins --- js/background.js | 26 ++++++++++++++------------ js/popup.js | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/js/background.js b/js/background.js index 26e1e067..a38ffcd9 100644 --- a/js/background.js +++ b/js/background.js @@ -28,18 +28,20 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) { }); /* Initially set the course data in storage */ -chrome.runtime.onInstalled.addListener(function () { - var arr = new Array(); - chrome.storage.sync.set({ - savedCourses: arr - }, function () { - console.log('initial course list'); - }); - chrome.storage.sync.set({ - courseConflictHighlight: true - }, function () { - console.log('initial highlighting: true'); - }); +chrome.runtime.onInstalled.addListener(function (details) { + if (details.reason == "install" || details.reason == "update") { + var arr = new Array(); + chrome.storage.sync.set({ + savedCourses: arr + }, function () { + console.log('initial course list'); + }); + chrome.storage.sync.set({ + courseConflictHighlight: true + }, function () { + console.log('initial highlighting: true'); + }); + } }); /* Find all the conflicts in the courses and send them out/ if there is even a conflict*/ diff --git a/js/popup.js b/js/popup.js index 8d1aa4e2..708a9b89 100644 --- a/js/popup.js +++ b/js/popup.js @@ -41,7 +41,7 @@ chrome.storage.sync.get('savedCourses', function (data) { if (profname == "") { profname = "Undecided Professor"; } - var listhtml = "
  • " + department + " " + course_nbr + "" + " with " + profname + " (" + courses[i].unique + ")" + "

  • "; + var listhtml = "
  • " + department + " " + course_nbr + "" + " with " + profname + " (" + courses[i].unique + ")" + "

  • "; $("#courseList").append(listhtml); } });