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
8 changes: 8 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@
"message": "By the strictness philosophy, the only way to <em>cancel</em> a running timer is to disable the extension.",
"description": "On the options page, note below the label for the click-restarts checkbox explaining that this will not allow users to *cancel* a running timer"
},
"options_autostart_work": {
"message": "Automatically start a work timer once the break is over",
"description": "On the options page, label for the checkbox that enables/disables starting a work timer automatically once the break is over"
},
"options_autostart_break": {
"message": "Automatically start a break timer once the pomodoro is over",
"description": "On the options page, label for the checkbox that enables/disables starting a break timer automatically once the pomodoro is over"
},
"options_save_changes": {
"message": "Save changes",
"description": "On the options page, text for the submit button"
Expand Down
14 changes: 12 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function defaultPrefs() {
},
shouldRing: true,
clickRestarts: false,
autostartWork: false,
autostartBreak: true,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set this to false if you don't want to change the default behavior.

whitelist: false
}
}
Expand Down Expand Up @@ -297,8 +299,8 @@ var notification, mainPomodoro = new Pomodoro({
});
chrome.browserAction.setBadgeText({text: ''});

var nextModeName = chrome.i18n.getMessage(timer.pomodoro.nextMode);
if(PREFS.showNotifications) {
var nextModeName = chrome.i18n.getMessage(timer.pomodoro.nextMode);
notification = webkitNotifications.createNotification(
ICONS.FULL[timer.type],
chrome.i18n.getMessage("timer_end_notification_header"),
Expand All @@ -318,6 +320,14 @@ var notification, mainPomodoro = new Pomodoro({
console.log("playing ring", RING);
RING.play();
}

if(nextModeName == 'break' && PREFS.autostartBreak) {
mainPomodoro.start();
}

if(nextModeName == 'work' && PREFS.autostartWork) {
mainPomodoro.start();
}
},
onStart: function (timer) {
chrome.browserAction.setIcon({
Expand All @@ -331,7 +341,7 @@ var notification, mainPomodoro = new Pomodoro({
} else {
executeInAllBlockedTabs('unblock');
}
if(notification) notification.cancel();
if(notification) setTimeout(function(){notification.cancel();}, '10000');
var tabViews = chrome.extension.getViews({type: 'tab'}), tab;
for(var i in tabViews) {
tab = tabViews[i];
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"name": "__MSG_ext_name__",
"options_page": "options.html",
"permissions": [ "notifications", "tabs", "<all_urls>" ],
"version": "1.6.1",
"version": "1.6.2",
"web_accessible_resources": [
"icons/work_full.png",
"icons/break_full.png"
Expand Down
8 changes: 8 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ <h1 data-i18n="options_title"></h1>
<input id="should-ring" type="checkbox" />
<label for="should-ring" data-i18n="options_should_ring"></label>
</div>
<div>
<input id="autostart-work" type="checkbox" />
<label for="autostart-work" data-i18n="options_autostart_work"></label>
</div>
<div>
<input id="autostart-break" type="checkbox" />
<label for="autostart-break" data-i18n="options_autostart_break"></label>
</div>
<div>
<input id="click-restarts" type="checkbox" />
<label for="click-restarts">
Expand Down
8 changes: 8 additions & 0 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var form = document.getElementById('options-form'),
showNotificationsEl = document.getElementById('show-notifications'),
shouldRingEl = document.getElementById('should-ring'),
clickRestartsEl = document.getElementById('click-restarts'),
autostartWorkEl = document.getElementById('autostart-work'),
autostartBreakEl = document.getElementById('autostart-break'),
saveSuccessfulEl = document.getElementById('save-successful'),
timeFormatErrorEl = document.getElementById('time-format-error'),
background = chrome.extension.getBackgroundPage(),
Expand Down Expand Up @@ -63,6 +65,8 @@ form.onsubmit = function () {
showNotifications: showNotificationsEl.checked,
shouldRing: shouldRingEl.checked,
clickRestarts: clickRestartsEl.checked,
autostartWork: autostartWorkEl.checked,
autostartBreak: autostartBreakEl.checked,
whitelist: whitelistEl.selectedIndex == 1
})
saveSuccessfulEl.className = 'show';
Expand All @@ -74,6 +78,8 @@ showNotificationsEl.onchange = formAltered;
shouldRingEl.onchange = formAltered;
clickRestartsEl.onchange = formAltered;
whitelistEl.onchange = formAltered;
autostartWorkEl.onchange = formAltered;
autostartBreakEl.onchange = formAltered;

function formAltered() {
saveSuccessfulEl.removeAttribute('class');
Expand All @@ -84,6 +90,8 @@ siteListEl.value = background.PREFS.siteList.join("\n");
showNotificationsEl.checked = background.PREFS.showNotifications;
shouldRingEl.checked = background.PREFS.shouldRing;
clickRestartsEl.checked = background.PREFS.clickRestarts;
autostartWorkEl.checked = background.PREFS.autostartWork;
autostartBreakEl.checked = background.PREFS.autostartBreak;
whitelistEl.selectedIndex = background.PREFS.whitelist ? 1 : 0;

var duration, minutes, seconds;
Expand Down