flash badge
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 19 KiB |
BIN
icons/icon16.png
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 18 KiB |
BIN
icons/icon32.png
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
BIN
icons/icon48.png
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@@ -1,13 +1,4 @@
|
|||||||
chrome.storage.sync.get('savedCourses', function (data) {
|
updateBadge(true);
|
||||||
if (data.savedCourses && data.savedCourses.length) {
|
|
||||||
chrome.browserAction.setBadgeBackgroundColor({
|
|
||||||
color: '#bf5700'
|
|
||||||
});
|
|
||||||
chrome.browserAction.setBadgeText({
|
|
||||||
text: "" + data.savedCourses.length
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/* Handle messages and their commands from content and popup scripts*/
|
/* 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) {
|
switch (request.command) {
|
||||||
@@ -25,6 +16,9 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
|
|||||||
case "checkConflicts":
|
case "checkConflicts":
|
||||||
checkConflicts(response);
|
checkConflicts(response);
|
||||||
break;
|
break;
|
||||||
|
case "updateBadge":
|
||||||
|
updateBadge();
|
||||||
|
break;
|
||||||
case "updateStatus":
|
case "updateStatus":
|
||||||
updateStatus(response);
|
updateStatus(response);
|
||||||
break;
|
break;
|
||||||
@@ -90,6 +84,34 @@ chrome.runtime.onInstalled.addListener(function (details) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function updateBadge(first) {
|
||||||
|
chrome.storage.sync.get('savedCourses', function (data) {
|
||||||
|
if (data.savedCourses) {
|
||||||
|
let text = "";
|
||||||
|
if (data.savedCourses.length > 0) {
|
||||||
|
text += data.savedCourses.length
|
||||||
|
}
|
||||||
|
chrome.browserAction.setBadgeText({
|
||||||
|
text: text
|
||||||
|
});
|
||||||
|
let timeout = 0;
|
||||||
|
if (!first) {
|
||||||
|
chrome.browserAction.setBadgeBackgroundColor({
|
||||||
|
color: '#FF5722'
|
||||||
|
});
|
||||||
|
timeout = 200;
|
||||||
|
}
|
||||||
|
setTimeout(function () {
|
||||||
|
chrome.browserAction.setBadgeBackgroundColor({
|
||||||
|
color: '#bf5700'
|
||||||
|
});
|
||||||
|
}, timeout);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/* Find all the conflicts in the courses and send them out/ if there is even a conflict*/
|
/* Find all the conflicts in the courses and send them out/ if there is even a conflict*/
|
||||||
function checkConflicts(sendResponse) {
|
function checkConflicts(sendResponse) {
|
||||||
chrome.storage.sync.get('savedCourses', function (data) {
|
chrome.storage.sync.get('savedCourses', function (data) {
|
||||||
@@ -172,12 +194,7 @@ function add(request, sender, sendResponse) {
|
|||||||
savedCourses: courses
|
savedCourses: courses
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
chrome.browserAction.setBadgeBackgroundColor({
|
updateBadge();
|
||||||
color: '#bf5700'
|
|
||||||
});
|
|
||||||
chrome.browserAction.setBadgeText({
|
|
||||||
text: "" + courses.length
|
|
||||||
});
|
|
||||||
sendResponse({
|
sendResponse({
|
||||||
done: "Added: (" + request.course.unique + ") " + request.course.coursename,
|
done: "Added: (" + request.course.unique + ") " + request.course.coursename,
|
||||||
label: "Remove Course -"
|
label: "Remove Course -"
|
||||||
@@ -197,18 +214,7 @@ function remove(request, sender, sendResponse) {
|
|||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
savedCourses: courses
|
savedCourses: courses
|
||||||
});
|
});
|
||||||
chrome.browserAction.setBadgeBackgroundColor({
|
updateBadge();
|
||||||
color: '#bf5700'
|
|
||||||
});
|
|
||||||
if (courses.length > 0) {
|
|
||||||
chrome.browserAction.setBadgeText({
|
|
||||||
text: "" + courses.length
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
chrome.browserAction.setBadgeText({
|
|
||||||
text: ""
|
|
||||||
});
|
|
||||||
}
|
|
||||||
sendResponse({
|
sendResponse({
|
||||||
done: "Removed: (" + request.course.unique + ") " + request.course.coursename,
|
done: "Removed: (" + request.course.unique + ") " + request.course.coursename,
|
||||||
label: "Add Course +"
|
label: "Add Course +"
|
||||||
|
|||||||
@@ -155,11 +155,8 @@ $(function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
updateCalendar();
|
updateCalendar();
|
||||||
chrome.browserAction.setBadgeBackgroundColor({
|
chrome.runtime.sendMessage({
|
||||||
color: '#bf5700'
|
command: "updateBadge"
|
||||||
});
|
|
||||||
chrome.browserAction.setBadgeText({
|
|
||||||
text: ""
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
14
js/popup.js
@@ -306,11 +306,8 @@ $("#importOrig").change(function (e) {
|
|||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
savedCourses: impCourses
|
savedCourses: impCourses
|
||||||
});
|
});
|
||||||
chrome.browserAction.setBadgeBackgroundColor({
|
chrome.runtime.sendMessage({
|
||||||
color: '#bf5700'
|
command: "updateBadge"
|
||||||
});
|
|
||||||
chrome.browserAction.setBadgeText({
|
|
||||||
text: "" + impCourses.length
|
|
||||||
});
|
});
|
||||||
chrome.tabs.query({}, function (tabs) {
|
chrome.tabs.query({}, function (tabs) {
|
||||||
for (var i = 0; i < tabs.length; i++) {
|
for (var i = 0; i < tabs.length; i++) {
|
||||||
@@ -423,11 +420,8 @@ function clear() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
chrome.browserAction.setBadgeBackgroundColor({
|
chrome.runtime.sendMessage({
|
||||||
color: '#bf5700'
|
command: "updateBadge"
|
||||||
});
|
|
||||||
chrome.browserAction.setBadgeText({
|
|
||||||
text: ""
|
|
||||||
});
|
});
|
||||||
$("#courseList").empty()
|
$("#courseList").empty()
|
||||||
console.log("cleared");
|
console.log("cleared");
|
||||||
|
|||||||