changed refresh time to 16 mins

This commit is contained in:
sghsri
2019-04-30 16:10:06 -05:00
parent 2af93ef4ae
commit fd2fa61c8d
2 changed files with 309 additions and 309 deletions

View File

@@ -1,6 +1,6 @@
updateBadge(true);
/* Handle messages and their commands from content and popup scripts*/
chrome.runtime.onMessage.addListener(function (request, sender, response) {
chrome.runtime.onMessage.addListener(function(request, sender, response) {
switch (request.command) {
case "courseStorage":
if (request.action == "add") {
@@ -48,35 +48,35 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
});
/* Initially set the course data in storage */
chrome.runtime.onInstalled.addListener(function (details) {
chrome.runtime.onInstalled.addListener(function(details) {
if (details.reason == "install") {
chrome.storage.sync.get('savedCourses', function (data) {
chrome.storage.sync.get('savedCourses', function(data) {
if (!data.savedCourses) {
var arr = new Array();
chrome.storage.sync.set({
savedCourses: arr
}, function () {
}, function() {
console.log('initial course list');
});
chrome.storage.sync.set({
courseConflictHighlight: true
}, function () {
}, function() {
console.log('initial highlighting: true');
});
chrome.storage.sync.set({
loadAll: true
}, function () {
}, function() {
console.log('initial loadAll: true');
});
}
});
} else if (details.reason == "update") {
console.log("updated");
chrome.storage.sync.get('loadAll', function (data) {
chrome.storage.sync.get('loadAll', function(data) {
if (data.loadAll == undefined) {
chrome.storage.sync.set({
loadAll: true
}, function () {
}, function() {
console.log('initial loadAll: true');
});
}
@@ -86,7 +86,7 @@ chrome.runtime.onInstalled.addListener(function (details) {
function updateBadge(first) {
chrome.storage.sync.get('savedCourses', function (data) {
chrome.storage.sync.get('savedCourses', function(data) {
if (data.savedCourses) {
let text = "";
if (data.savedCourses.length > 0) {
@@ -102,7 +102,7 @@ function updateBadge(first) {
});
timeout = 200;
}
setTimeout(function () {
setTimeout(function() {
chrome.browserAction.setBadgeBackgroundColor({
color: '#bf5700'
});
@@ -114,7 +114,7 @@ function updateBadge(first) {
/* Find all the conflicts in the courses and send them out/ if there is even a conflict*/
function checkConflicts(sendResponse) {
chrome.storage.sync.get('savedCourses', function (data) {
chrome.storage.sync.get('savedCourses', function(data) {
var conflicts = [];
var courses = data.savedCourses;
for (var i = 0; i < courses.length; i++) {
@@ -141,7 +141,7 @@ function checkConflicts(sendResponse) {
/* Find if the course at unique and with currdatearr is contained in the saved courses and if it conflicts with any other courses*/
function isSingleConflict(currdatearr, unique, sendResponse) {
chrome.storage.sync.get('savedCourses', function (data) {
chrome.storage.sync.get('savedCourses', function(data) {
var courses = data.savedCourses;
var conflict = false;
for (var i = 0; i < courses.length; i++) {
@@ -185,7 +185,7 @@ function isConflict(adtarr, bdtarr) {
/* Add the requested course to the storage*/
function add(request, sender, sendResponse) {
chrome.storage.sync.get('savedCourses', function (data) {
chrome.storage.sync.get('savedCourses', function(data) {
var courses = data.savedCourses;
if (!contains(courses, request.course.unique)) {
courses.push(request.course)
@@ -203,7 +203,7 @@ function add(request, sender, sendResponse) {
}
/* Find and Remove the requested course from the storage*/
function remove(request, sender, sendResponse) {
chrome.storage.sync.get('savedCourses', function (data) {
chrome.storage.sync.get('savedCourses', function(data) {
var courses = data.savedCourses;
console.log(courses);
var index = 0;
@@ -224,7 +224,7 @@ function remove(request, sender, sendResponse) {
/* Find if the unique is already contained within the storage*/
function alreadyContains(unique, sendResponse) {
chrome.storage.sync.get('savedCourses', function (data) {
chrome.storage.sync.get('savedCourses', function(data) {
var courses = data.savedCourses;
sendResponse({
alreadyContains: contains(courses, unique)
@@ -244,7 +244,7 @@ function contains(courses, unique) {
}
function updateTabs() {
chrome.tabs.query({}, function (tabs) {
chrome.tabs.query({}, function(tabs) {
for (var i = 0; i < tabs.length; i++) {
chrome.tabs.sendMessage(tabs[i].id, {
command: "updateCourseList"
@@ -253,11 +253,11 @@ function updateTabs() {
});
}
const UPDATE_INTERVAL = 1000 * 60; // 1 mins
const UPDATE_INTERVAL = 1000 * 60 * 16; // 16 mins
setInterval(updateStatus, UPDATE_INTERVAL);
function updateStatus(sendResponse) {
chrome.storage.sync.get('savedCourses', function (data) {
chrome.storage.sync.get('savedCourses', function(data) {
var courses = data.savedCourses;
var nochange = true;
for (let i = 0; i < courses.length; i++) {

View File

@@ -10,9 +10,9 @@
<body style="position:relative;">
<div class="card" id="header">
<div id="buttons" style="padding: 5px 10px 5px 10px;display: flex;justify-content: space-between;">
<button id="clear" class="matbut" style="font-size:medium; background:#4CAF50;margin: 10px;">Clear All</button>
<button id="schedule" class="matbut" style="font-size:medium;background:#FF9800;margin: 10px;">Course List</button>
<button id="calendar" class="matbut" style="font-size:medium; background: #FF0000; margin:10px;">My Schedule</button>
<button id="clear" class="matbut" style="font-size:15px; background:#4CAF50;margin: 10px;">Clear All</button>
<button id="schedule" class="matbut" style="font-size:15px;background:#FF9800;margin: 10px;">Course List</button>
<button id="calendar" class="matbut" style="font-size:15px; background: #FF0000; margin:10px;">My Schedule</button>
</div>
</div>
<div>