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 @@
+