Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ext_name": {
"message": "Strict Workflow",
"message": "SWorkflow",
"description": "Name of the extension"
},
"ext_description": {
Expand Down
32 changes: 29 additions & 3 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ function defaultPrefs() {
},
shouldRing: true,
clickRestarts: false,
whitelist: false
whitelist: false,
sessions:{},
goal: 3
}
}

Expand Down Expand Up @@ -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]
});
Expand Down Expand Up @@ -341,15 +354,28 @@ 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();
}
} 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') {
Expand Down
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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__",
Expand Down
8 changes: 7 additions & 1 deletion options.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<title data-i18n="options_title"></title>

<link rel="stylesheet" href="chrome://resources/css/widgets.css">
<!-- <link rel="stylesheet" href="chrome://resources/css/widgets.css"> -->
<style type="text/css">
body {
background: url(icons/work_full.png) no-repeat fixed right bottom;
Expand Down Expand Up @@ -142,6 +142,12 @@ <h1 data-i18n="options_title"></h1>
<p class="note" data-i18n="options_click_restarts_note"></p>
</label>
</div>
<div>
<label for="goal">
Goal :
</label>
<input id="goal" type="text" size="2" />
</div>
<button type="submit" id="save-button" data-i18n="options_save_changes"></button>
<span id="save-successful" data-i18n="options_save_successful"></span>
</form>
Expand Down
9 changes: 6 additions & 3 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ var form = document.getElementById('options-form'),
clickRestartsEl = document.getElementById('click-restarts'),
saveSuccessfulEl = document.getElementById('save-successful'),
timeFormatErrorEl = document.getElementById('time-format-error'),
goalEl = document.getElementById('goal');
background = chrome.extension.getBackgroundPage(),
startCallbacks = {}, durationEls = {};

durationEls['work'] = document.getElementById('work-duration');
durationEls['break'] = document.getElementById('break-duration');

var TIME_REGEX = /^([0-9]+)(:([0-9]{2}))?$/;

form.onsubmit = function () {
Expand All @@ -54,7 +54,6 @@ form.onsubmit = function () {
return false;
}
}

console.log(durations);

background.setPrefs({
Expand All @@ -63,13 +62,16 @@ form.onsubmit = function () {
showNotifications: showNotificationsEl.checked,
shouldRing: shouldRingEl.checked,
clickRestarts: clickRestartsEl.checked,
whitelist: whitelistEl.selectedIndex == 1
whitelist: whitelistEl.selectedIndex == 1,
sessions: background.PREFS.sessions,
goal: goalEl.value
})
saveSuccessfulEl.className = 'show';
return false;
}

siteListEl.onfocus = formAltered;
goalEl.onfocus = formAltered;
showNotificationsEl.onchange = formAltered;
shouldRingEl.onchange = formAltered;
clickRestartsEl.onchange = formAltered;
Expand All @@ -81,6 +83,7 @@ function formAltered() {
}

siteListEl.value = background.PREFS.siteList.join("\n");
goalEl.value = background.PREFS.goal;
showNotificationsEl.checked = background.PREFS.showNotifications;
shouldRingEl.checked = background.PREFS.shouldRing;
clickRestartsEl.checked = background.PREFS.clickRestarts;
Expand Down
18 changes: 18 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html>
<head>
<title>SWorkflow</title>
</head>
<body style="width:100px;text-align: center;">
<div>
<span>Sessions : </span>
<span id="today_session_count"></span>
</div>
<div>
<span>Goal : </span>
<span id="daily_goal"></span>
</div>
<script src="popup.js"></script>
</body>
</html>

9 changes: 9 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var bgPage = chrome.extension.getBackgroundPage();
bgPage.clicked();
// console.log(bgPage.session_count())

var session_count = document.getElementById("today_session_count")
var daily_goal = document.getElementById("daily_goal")
console.log("c",session_count)
session_count.innerHTML = bgPage.session_count()
daily_goal.innerHTML = bgPage.goal()