diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 046461f..3ac6848 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -71,9 +71,17 @@ "description": "On the options page, label for the checkbox that enables/disables ringing sound at the end of a timer" }, "options_click_restarts": { - "message": "Clicking on a running timer restarts it", + "message": "Clicking on a running work timer restarts it", "description": "On the options page, label for the checkbox that enables/disables the feature that clicking on a running timer restarts it" }, + "options_click_skips": { + "message": "Clicking on a running break timer starts a new work period", + "description": "On the options page, label for the checkbox that enables/disables the feature that clicking on a running break timer starts a work period" + }, + "options_auto_continue": { + "message": "Automatically start a new work period when the break timer finishes", + "description": "On the options page, label for the checkbox that enables/disables the feature that the work timer starts automatically at the end of a break" + }, "options_click_restarts_note": { "message": "By the strictness philosophy, the only way to cancel 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" diff --git a/background.js b/background.js index 311a031..949e03b 100644 --- a/background.js +++ b/background.js @@ -127,6 +127,9 @@ function Pomodoro(options) { this.onTimerEnd = function (timer) { this.running = false; + if (PREFS.autoContinue && this.mostRecentMode == 'break') { + this.start(); + } } this.start = function () { @@ -144,10 +147,15 @@ function Pomodoro(options) { this.currentTimer.start(); } + this.stop = function () { + if (this.currentTimer) { + this.currentTimer.stop(); + } + } + this.restart = function () { - if(this.currentTimer) { - this.currentTimer.restart(); - } + this.stop(); + this.start(); } } @@ -162,6 +170,10 @@ Pomodoro.Timer = function Timer(pomodoro, options) { options.onStart(timer); options.onTick(timer); } + + this.stop = function () { + clearInterval(tickInterval); + } this.restart = function() { this.timeRemaining = options.duration; @@ -180,9 +192,9 @@ Pomodoro.Timer = function Timer(pomodoro, options) { timer.timeRemaining--; options.onTick(timer); if(timer.timeRemaining <= 0) { - clearInterval(tickInterval); - pomodoro.onTimerEnd(timer); + timer.stop(); options.onEnd(timer); + pomodoro.onTimerEnd(timer); } } } @@ -348,9 +360,12 @@ var notification, mainPomodoro = new Pomodoro({ chrome.browserAction.onClicked.addListener(function (tab) { if(mainPomodoro.running) { - if(PREFS.clickRestarts) { - mainPomodoro.restart(); - } + if(PREFS.clickRestarts && mainPomodoro.mostRecentMode == 'work') { + mainPomodoro.currentTimer.restart(); + } + if(PREFS.clickSkips && mainPomodoro.mostRecentMode == 'break') { + mainPomodoro.restart(); + } } else { mainPomodoro.start(); } diff --git a/options.html b/options.html index d97ca87..a92105e 100644 --- a/options.html +++ b/options.html @@ -142,6 +142,14 @@

+
+ + +
+
+ + +
diff --git a/options.js b/options.js index 32dada8..6748f1f 100644 --- a/options.js +++ b/options.js @@ -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'), + clickSkipsEl = document.getElementById('click-skips'), + autoContinueEl = document.getElementById('auto-continue'), saveSuccessfulEl = document.getElementById('save-successful'), timeFormatErrorEl = document.getElementById('time-format-error'), background = chrome.extension.getBackgroundPage(), @@ -63,6 +65,8 @@ form.onsubmit = function () { showNotifications: showNotificationsEl.checked, shouldRing: shouldRingEl.checked, clickRestarts: clickRestartsEl.checked, + clickSkips: clickSkipsEl.checked, + autoContinue: autoContinueEl.checked, whitelist: whitelistEl.selectedIndex == 1 }) saveSuccessfulEl.className = 'show'; @@ -73,6 +77,8 @@ siteListEl.onfocus = formAltered; showNotificationsEl.onchange = formAltered; shouldRingEl.onchange = formAltered; clickRestartsEl.onchange = formAltered; +clickSkipsEl.onchange = formAltered; +autoContinueEl.onchange = formAltered; whitelistEl.onchange = formAltered; function formAltered() { @@ -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; +clickSkipsEl.checked = background.PREFS.clickSkips; +autoContinueEl.checked = background.PREFS.autoContinue; whitelistEl.selectedIndex = background.PREFS.whitelist ? 1 : 0; var duration, minutes, seconds;