From ce709cbec4d522ede039504842d919937c270421 Mon Sep 17 00:00:00 2001 From: Sriram Hariharan Date: Tue, 15 Jan 2019 13:42:21 -0600 Subject: [PATCH] flash badge --- icons/icon128.png | Bin 18991 -> 19000 bytes icons/icon16.png | Bin 17606 -> 18043 bytes icons/icon32.png | Bin 18405 -> 18842 bytes icons/icon48.png | Bin 17118 -> 17546 bytes js/background.js | 62 +++++++++++++++++++++++++--------------------- js/calendar.js | 7 ++---- js/popup.js | 14 +++-------- 7 files changed, 40 insertions(+), 43 deletions(-) diff --git a/icons/icon128.png b/icons/icon128.png index 2596067a3df3019d68395905c0f435c2503a460d..a875bcb46ef1c233a05cc1763fa7a214b05e71e9 100644 GIT binary patch delta 179 zcmZ2Kg>lCe#tD{;%^R(Xn1wBM4GeV+O+yTgtqe`93`}$l%qH()HpVLcpLv!_a#B)C zvPoi+u0@(zqON7KiKVVZvZ;}-frX`MTAD$cp^35O=DjQzS%^|OiNh3|O`E@S9yDaJ N=vo@Fd5?859{_wnGKl~H delta 171 zcmdlng>n59#tD{;RU55}m<23!4a|Wk#L(2rz*5)1bn<>?V@yF-mRY(c=1FO3<_5;P zNhxV2y5FFx6gZGmq0QCIEm^GRFV_ delta 55 zcmey}!+5Ndae@VtV~ z&2=r3O%rv~EKQ7cEse~~bd9;zrWkf@_T$)V P$WoSg=;LO7tMeQH)rl^< delta 55 zcmeC`WW3kPIKhI+^6W;dBIe1a91@ccGV6h97M7`#@35 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*/ function checkConflicts(sendResponse) { chrome.storage.sync.get('savedCourses', function (data) { @@ -172,12 +194,7 @@ function add(request, sender, sendResponse) { savedCourses: courses }); } - chrome.browserAction.setBadgeBackgroundColor({ - color: '#bf5700' - }); - chrome.browserAction.setBadgeText({ - text: "" + courses.length - }); + updateBadge(); sendResponse({ done: "Added: (" + request.course.unique + ") " + request.course.coursename, label: "Remove Course -" @@ -197,18 +214,7 @@ function remove(request, sender, sendResponse) { chrome.storage.sync.set({ savedCourses: courses }); - chrome.browserAction.setBadgeBackgroundColor({ - color: '#bf5700' - }); - if (courses.length > 0) { - chrome.browserAction.setBadgeText({ - text: "" + courses.length - }); - } else { - chrome.browserAction.setBadgeText({ - text: "" - }); - } + updateBadge(); sendResponse({ done: "Removed: (" + request.course.unique + ") " + request.course.coursename, label: "Add Course +" diff --git a/js/calendar.js b/js/calendar.js index fe33680b..7d5d8e03 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -155,11 +155,8 @@ $(function () { } }); updateCalendar(); - chrome.browserAction.setBadgeBackgroundColor({ - color: '#bf5700' - }); - chrome.browserAction.setBadgeText({ - text: "" + chrome.runtime.sendMessage({ + command: "updateBadge" }); }); diff --git a/js/popup.js b/js/popup.js index c3241c04..9af99048 100644 --- a/js/popup.js +++ b/js/popup.js @@ -306,11 +306,8 @@ $("#importOrig").change(function (e) { chrome.storage.sync.set({ savedCourses: impCourses }); - chrome.browserAction.setBadgeBackgroundColor({ - color: '#bf5700' - }); - chrome.browserAction.setBadgeText({ - text: "" + impCourses.length + chrome.runtime.sendMessage({ + command: "updateBadge" }); chrome.tabs.query({}, function (tabs) { for (var i = 0; i < tabs.length; i++) { @@ -423,11 +420,8 @@ function clear() { }); } }); - chrome.browserAction.setBadgeBackgroundColor({ - color: '#bf5700' - }); - chrome.browserAction.setBadgeText({ - text: "" + chrome.runtime.sendMessage({ + command: "updateBadge" }); $("#courseList").empty() console.log("cleared");