cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <body ng-app="app">
  <div class="main" ng-controller="TimeCtrl">
    <div class="title">
      <h1>Pomodoro Clock</h1>
    </div>

    <div class="timing">
      <!-- Break Length -->
      <div class="break">
        <h3>Break Length</h3>
        <div class="select">
          <a class="btn" ng-click="decreaseBreak()">-</a>
          <p>{{breakLength}}</p>
          <a class="btn" ng-click="increaseBreak()">+</a>
        </div>
      </div>

      <!-- Session Length -->
      <div class="session">
        <h3>Session Length</h3>
        <div class="select">
          <a class="btn" ng-click="decreaseSession()">-</a>
          <p>{{sessionLength}}</p>
          <a class="btn" ng-click="increaseSession()">+</a>
        </div>
      </div>

    </div>


    <div class="timer">
      <div class="circle" ng-click="toggleTimer()">
        <div id="filler" ng-style="{'height': fillerHeight+'%', 'background': color}">
        </div>
        <div class="countdown">
          {{minutes}}:{{seconds}}
        </div>
      </div>


      <p style="text-align: center; margin-top: 10px;">By Rashmi Malpande</p>
    </div>
  </div>


</body>
            
          
!
            
              body {
  margin: 0;
  padding: 0;
  background: #333;
  color: #fff;
  font-family: 'Josefin Sans', sans-serif;
}

.main {
  margin: 0 auto;
  width: 50%;
  height: 100vh;
}

.title {
  width: 100%;
  text-align: center;
}

.title h1 {
  font-family: 'Pacifico', cursive;
  vertical-align: middle;
  font-size: 4em;
}

.timing {
  display: flex;
  flex-direction: row;
  align-content: center;
  justify-content: space-between;
  margin: 20px;
}

.break,
.session {
  width: 50%;
  text-align: center;
}

.select {
  display: inline-flex;
  flex-direction: row;
  width: 85px;
  align-items: center;
  justify-content: space-between;
}

.select p {
  font-size: 2em;
  margin: 0;
}

.btn {
  font-size: 2em;
  cursor: pointer;
}

.timer {
  margin: 80px;
}

.circle {
  width: 300px;
  height: 300px;
  border-radius: 100%;
  border: 2px solid #99CC00;
  margin: 10px auto;
  position: relative;
  z-index: 1;
  overflow: hidden;
  cursor: pointer;
}

#filler {
  position: absolute;
  bottom: 0;
  right: 0;
  height: 0;
  width: 100%;
  background: #99CC00;
  z-index: -1;
}

.countdown {
  text-align: center;
  font-size: 2em;
  vertical-align: bottom;
  top: 50%;
  position: relative;
  cursor: pointer;
}
            
          
!
            
              var app = angular.module('app', []);

app.controller('TimeCtrl', ['$scope','$interval',
     function($scope, $interval){
         $scope.breakLength = 5;
         $scope.sessionLength = 25;
         $scope.minutes = $scope.sessionLength;
         $scope.seconds = 0;
         $scope.timeLeft = 0;
         $scope.fillerHeight = 0;
         $scope.color = "#99CC00";
         $scope.start = false;
         $scope.stop = false;

         $scope.decreaseBreak = function(){
             if($scope.breakLength > 1){
                 $scope.breakLength--;
             }
             
         };

         $scope.increaseBreak = function(){
             $scope.breakLength++;
         };

         $scope.decreaseSession = function() {
             if($scope.sessionLength > 1){
                $scope.sessionLength--;
                
             }
             $scope.minutes = $scope.sessionLength;
             $scope.seconds = 0;
             $scope.fillerHeight = 0;
             $scope.color = "#99CC00";
         };

         $scope.increaseSession = function() {
             $scope.sessionLength++;
             $scope.minutes = $scope.sessionLength;
             $scope.seconds = 0;
             $scope.fillerHeight = 0;
              $scope.color = "#99CC00";
         };


         $scope.toggleTimer = function() {
        
            if($scope.fillerHeight === 0){
                $scope.start = true;
                $scope.startTimer();

            }

            else if($scope.fillerHeight > 0 && $scope.start){
                $scope.start = false;
                $scope.stop = true;
                $scope.stopTimer();
            }

            else if($scope.fillerHeight > 0 && $scope.stop){
                $scope.start = true;
                $scope.stop = false;
                $scope.startTimer();
            }
            
             
         };

         $scope.startTimer = function(){
             var height = 0;
             if($scope.minutes === 0){
                 height = 100 / 60;
             }
             else{
                 height = 100 / ($scope.minutes * 60);
             }
                 
             $scope.timeLeft = $interval(function(){
                if($scope.seconds == 0){
                    $scope.seconds = 60;
                    $scope.minutes--;
                    $scope.fillerHeight += height;              
                }

                $scope.seconds--;
                $scope.fillerHeight += height;

                if($scope.fillerHeight >= 100 && $scope.color=="#99CC00" && $scope.seconds === 0){
                    $scope.fillerHeight = 0;
                    $scope.color = 'tomato';
                    $scope.minutes = $scope.breakLength;
                    $scope.seconds = 0;
                    height = 100 / ($scope.minutes * 60);
                }

                else if($scope.fillerHeight >= 100 && $scope.color=="tomato" && $scope.seconds === 0){
                    $scope.fillerHeight = 0;
                    $scope.color = '#99CC00';
                    $scope.minutes = $scope.sessionLength;
                    $scope.seconds = 0;
                    height = 100 / ($scope.minutes * 60);
                }

                
            },1000);
         };

         $scope.stopTimer = function(){
             $interval.cancel($scope.timeLeft);
         };

      
    }

]);
            
          
!
999px
Loading ..................

Console