From e66e0e15c25a2eda3703cae9be977d50721a8bd3 Mon Sep 17 00:00:00 2001 From: karthickpdy Date: Sun, 15 Jan 2017 00:26:24 +0530 Subject: [PATCH] Adding session count and goal --- _locales/en/messages.json | 2 +- background.js | 32 +++++++++++++++++++++++++++++--- manifest.json | 3 ++- options.html | 8 +++++++- options.js | 9 ++++++--- popup.html | 18 ++++++++++++++++++ popup.js | 9 +++++++++ 7 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 popup.html create mode 100644 popup.js diff --git a/_locales/en/messages.json b/_locales/en/messages.json index d244cdd..735b564 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1,6 +1,6 @@ { "ext_name": { - "message": "Strict Workflow", + "message": "SWorkflow", "description": "Name of the extension" }, "ext_description": { diff --git a/background.js b/background.js index 75062fe..3e759e2 100644 --- a/background.js +++ b/background.js @@ -37,7 +37,9 @@ function defaultPrefs() { }, shouldRing: true, clickRestarts: false, - whitelist: false + whitelist: false, + sessions:{}, + goal: 3 } } @@ -292,6 +294,17 @@ var notification, mainPomodoro = new Pomodoro({ getDurations: function () { return PREFS.durations }, timer: { onEnd: function (timer) { + console.log("here") + key = new Date().toDateString() + if(timer.type == "work"){ + if(PREFS.sessions[key]) { + PREFS.sessions[key] += 1 + } else { + PREFS.sessions[key] = 1 + } + savePrefs(PREFS) + } + chrome.browserAction.setIcon({ path: ICONS.ACTION.PENDING[timer.pomodoro.nextMode] }); @@ -341,7 +354,8 @@ var notification, mainPomodoro = new Pomodoro({ } }); -chrome.browserAction.onClicked.addListener(function (tab) { +// chrome.browserAction.onClicked.addListener(function (tab) { +function clicked() { if(mainPomodoro.running) { if(PREFS.clickRestarts) { mainPomodoro.restart(); @@ -349,7 +363,19 @@ chrome.browserAction.onClicked.addListener(function (tab) { } else { mainPomodoro.start(); } -}); +} + +function session_count() { + key = new Date().toDateString() + if(PREFS.sessions[key]) + return PREFS.sessions[key] + else + return 0; +} + +function goal() { + return PREFS.goal +} chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) { if(mainPomodoro.mostRecentMode == 'work') { diff --git a/manifest.json b/manifest.json index a14614e..d10288d 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,8 @@ "scripts": ["background.js"] }, "browser_action": { - "default_icon": "icons/work_pending.png" + "default_icon": "icons/work_pending.png", + "default_popup": "popup.html" }, "default_locale": "en", "description": "__MSG_ext_description__", diff --git a/options.html b/options.html index d97ca87..89cfb47 100644 --- a/options.html +++ b/options.html @@ -3,7 +3,7 @@ - +