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.

            
              <h1>fCC Pomodoro Timer</h1>
      <div class="outerContainer">
          
          <div class="controls">
              <div class="breakControl">
                  <p>BREAK LENGTH</p>
                  <h3><a class="minus">-</a><span id="breakLength">5</span><a class="plus">+</a></h3>
              </div>
              <div class="sessionControl">
                  <p>SESSION LENGTH</p>
                  <h3><a class="minus">-</a><span id="sessionLength">25</span><a class="plus">+</a></h3>
              </div>
          </div>
          <div class="clock">
            <div class="bgFill">
            </div>
              <div class="timer">
                  <h3 id="timerType">IN SESSION</h3>
                  <p><i class="fa fa-play"></i><i class="fa fa-pause"></i></p>
                  <h2 id="countdown">25:00</h2>
              </div>
          </div>
          <div class="refresh">
              <p><i class="fa fa-refresh"></i></p>
          </div>
      </div>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Pacifico|Open+Sans:300);

body {
  background-color: #222;
  color: #fff;
  font-family: 'Arial', sans-serif;
  margin: 0;
  padding: 0;
  height:100%;
  text-align: center;
}
.outerContainer {
  width: 400px;
  margin: auto;
}
h1 {
  text-align: center;
  font-size: 3em;
  font-family: Pacifico;
  margin-bottom: 0em;
}
h2 {
  font-size: 3.5em;
}
h3 {
  font-size: 1.5em;
}
.controls p, a {
  font-size: 0.8em;
}
i, a, .clock {
  cursor: pointer;
}
.controls {
  width: 400px;
  margin: auto;
}
.controls>div {
  display: inline-block;
  width: 180px;
}
.controls a {
  margin: 0 20px 0 20px;
}
.controls h3 {
  margin-top:0px;
}
.clock {
  position:relative;
  border: 3px solid #007300;
  border-radius: 100%;
  height: 300px;
  width: 300px;
  margin: auto;
}
.bgFill {
  position: absolute;
  bottom:0px;
  border: 3px solid #222;
  border-radius: 100%;
  background-color: #222;
  height:294px;
  width:294px;
  background-image:
        linear-gradient(270deg, transparent 50%, #007300 50%),
        linear-gradient(270deg, #007300 50%, transparent 50%);
  /*background-image:
        linear-gradient(90deg, transparent 50%, #222 50%),
        linear-gradient(903deg, #007300 50%, transparent 50%);*/
}
.timer {
  position: absolute;
  width: 300px;
}
.timer>* {
  margin-top: 50px;
}
.fa-pause {
  display: none;
}
#footer {
  font-size:0.7em;
  text-align:right;
  margin:1em;
}
            
          
!
            
              $(document).ready(function() {
  var sessionTimer = 1500;
  var breakTimer = 300;
  var countdown;
  var currentTimer = sessionTimer;
  var type = 'session';
  var play = 'pause';
  var largeBell = new Audio('http://gez.bz/pomodoro/large-bell.mp3');
  var smallBell = new Audio('http://gez.bz/pomodoro/small-bell.mp3');

  function bgTimedFill() {
      console.log('Type at start of bgTimedFill: '+type);
    if (type === 'session') {
      var timeProp = currentTimer/sessionTimer;
      var fgColor = '#007300';
    } else if (type === 'break') {
      var timeProp = currentTimer/breakTimer;
      var fgColor = 'red';
    }
    
    if (timeProp>=0.5) {
      var bgFillCalc = 'linear-gradient('+(450-360*timeProp)+'deg, transparent 50%, '+fgColor+' 50%),linear-gradient(90deg, '+fgColor+' 50%, transparent 50%)';
    } else {
      var bgFillCalc = 'linear-gradient(90deg, transparent 50%, #222 50%),linear-gradient('+(270-360*timeProp)+'deg, '+fgColor+' 50%, transparent 50%)';
    }
    $('.bgFill').css('background-image',bgFillCalc);
  }
  
  function displayTimeRemaining() {
    console.log('Type at start of displayTime: '+type);
    Number(currentTimer);
    var minutes = Math.floor(currentTimer/60);
    if (currentTimer%60 <= 9) {
      $('#countdown').text(minutes+':0'+currentTimer%60);
      if (currentTimer <= 0) {
        clearInterval(countdown);
        if (type === 'session') {
          $('#timerType').text('BREAK');
          currentTimer = breakTimer;
          type = 'break';
          //$('.bgFill').css('background-color','red');
          $('.clock').css('border-color','red');
          largeBell.play();
          if (play === 'play') {
            startTimer();
          };
          //displayTimeRemaining();
        } else {
          $('#timerType').text('SESSION');
          currentTimer = sessionTimer;
          type = 'session';
          //$('.bgFill').css('background-color','#007300');
          $('.clock').css('border-color','#007300');
          smallBell.play();
          if (play === 'play') {
            startTimer();
          };
          //displayTimeRemaining();
        }
      }
    } else {
      $('#countdown').text(minutes+':'+currentTimer%60);
    }
    console.log('Type at end of displayTime: '+type);
    bgTimedFill();
  }

  function startTimer() {
    countdown = setInterval(function() {
      currentTimer -- ;
      displayTimeRemaining();
    },1000);

  }

  function pauseTimer() {
    clearInterval(countdown);
  }

  $('.sessionControl .minus').click(function() {
    if (sessionTimer>0) {
      if (type === 'session') {
        currentTimer -= 60;
      }
      sessionTimer -= 60;
      $('#sessionLength').text(Math.floor(sessionTimer/60));
      displayTimeRemaining();
    } else if (sessionTimer === 0 && breakTimer === 0) {
      pauseTimer();
    }
  });

  $('.sessionControl .plus').click(function() {
    if (type === 'session') {
      currentTimer += 60;
    }
    sessionTimer += 60;
    $('#sessionLength').text(Math.floor(sessionTimer/60));
    displayTimeRemaining();
  });

  $('.breakControl .minus').click(function() {
    if (breakTimer>0) {
      if (type === 'break') {
        currentTimer -= 60;
      }
      breakTimer -= 60;
      $('#breakLength').text(Math.floor(breakTimer/60));
      displayTimeRemaining();
    } else if (sessionTimer === 0 && breakTimer === 0) {
      pauseTimer();
    }
  });

  $('.breakControl .plus').click(function() {
    if (type === 'break') {
      currentTimer += 60;
    }
    breakTimer += 60;
    $('#breakLength').text(Math.floor(breakTimer/60));
    displayTimeRemaining();
  });
  
  $('.clock').click(function() {
    if (play === 'pause') {
      startTimer();
      $('.fa-play').hide();
      $('.fa-pause').show();
      play = 'play';
    } else {
      pauseTimer();
      $('.fa-pause').hide();
      $('.fa-play').show();
      play = 'pause';
    }
  });
  
  $('.fa-refresh').click(function() {
    if (type = 'break') {
      $('#timerType').text('SESSION');
      type = 'session';
      //$('.bgFill').css('background-color','#007300');
      $('.clock').css('border-color','#007300');
    };
    if (play = 'play') {
      pauseTimer();
      $('.fa-pause').hide();
      $('.fa-play').show();
      play = 'pause';
    };
    currentTimer = sessionTimer;
    displayTimeRemaining();
  });

});

            
          
!
999px
Loading ..................

Console