Skip to content

Commit

Permalink
Adds pomodoro counting and differentiation between long and short
Browse files Browse the repository at this point in the history
breaks
  • Loading branch information
camilopayan committed Jul 1, 2015
1 parent 68a0f68 commit 838867f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<div id="time">{{ pom.timeLeft | timeify }}</div>
<div>Current phase: {{ pom.state ? pom.state : "STOPPED" }}</div>
<div><a ng-click="pom.start()">Start</a> <a ng-click="pom.cancel()">Cancel</a></div>
<div>
Poms done: {{ pom.count }}
</div>
</div>


Expand Down
8 changes: 4 additions & 4 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ var app = angular.module("FirePom", [])
};

$scope.pom.cancel = function(){
clearTimeout();
$scope.pom.state = "POMODORO";
$scope.pom.timeLeft = settings.pomTime * 1000;
clearTimeout();
};

var finishPhase = function(){
switch ( $scope.pom.state ){
case "POMODORO":
if ($scope.pom.count % 4 === 0) {
$scope.pom.count++;
if ($scope.pom.count % 4 === 0 && $scope.pom.count > 0) {
$scope.pom.state = "LONGBREAK";
$scope.pom.timeLeft = settings.longRestTime * 1000;
break;
Expand All @@ -52,12 +53,11 @@ var app = angular.module("FirePom", [])
finishPhase();
if($scope.pom.state === "POMODORO") {
clearTimeout();
} else {
return;
}
}

$scope.timeoutId = $timeout( tick, 1000 );
$scope.pom.timeoutId = $timeout( tick, 1000 );
};

var clearTimeout = function(){
Expand Down

0 comments on commit 838867f

Please sign in to comment.