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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <div class="vert-align">
  <div class="row">
      <div class="col s12 m4 offset-m4">
        <div class="card-panel center-align">
          <div class="row">
            <div class="col s12">
              <div class="description">Work for another</div>
            </div>
          </div>
          <div class="row">
            <div class="col s12">
              <div class="time">25:00</div>
            </div>
          </div>
          <div class="row">
            <div class="col s12">
              <a class="waves-effect waves-light btn" onclick="startTimer();">Start</a>
              <a class="waves-effect waves-light btn red" onclick="resetTimer();">Reset</a>
            </div>
          </div>
          <div class="row">
            <div class="col s6">
              <div class="worktime">25:00</div>
              <a onclick="increaseTime('worktime');"><i class="fa fa-chevron-up" aria-hidden="true"></i></a>
              <a onclick="decreaseTime('worktime');"><i class="fa fa-chevron-down" aria-hidden="true"></i></a>
            </div>
            <div class="col s6">
              <div class="breaktime">5:00</div>
              <a onclick="increaseTime('breaktime');"><i class="fa fa-chevron-up" aria-hidden="true"></i></a>
              <a onclick="decreaseTime('breaktime');"><i class="fa fa-chevron-down" aria-hidden="true"></i></a>
            </div>
          </div>
          <div class="buttons"></div>
        </div>
      </div>
    </div>
</div>

<audio id="ding" preload="auto" src="https://matthewsmith.id.au/projects/pomodoro/ding.mp3">
  Your browser does not support the audio element. Dingings will not be audible.
</audio>
            
          
!
            
              body {
  background: url("https://matthewsmith.id.au/projects/pomodoro/food-wood-tomatoes.jpg") no-repeat;
  background-size: cover;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.time {
  font-size: 250%;
}

.vert-align {
  position:absolute;
  top:50%;
  left:50%;
  width:100%;
  -ms-transform: translateX(-50%) translateY(-50%);
  -webkit-transform: translate(-50%,-50%);
  transform: translate(-50%,-50%);
}
            
          
!
            
              var timer = 0;

function increaseTime(whichtime) {
  var currentTime = parseInt($('.'+whichtime).text());
  console.log(currentTime);
  currentTime+=1;
  $('.'+whichtime).text(currentTime+":00");
}

function decreaseTime(whichtime) {
  var currentTime = parseInt($('.'+whichtime).text());
  console.log(currentTime);
  currentTime-=1;
  if (currentTime<1) {
    currentTime=1;
  }
  $('.'+whichtime).text(currentTime+":00");
}

function startTimer() {
  
  var end = new Date().getTime() + parseInt($('.worktime').text())*60000 ;
  var working = true;

  timer = setInterval(function() {
    var timeRemaining = (end - new Date()) / 1000;
    var minutesRemaining = Math.floor(timeRemaining/60);
    var secondsRemaining = Math.floor(timeRemaining%60);
    var pad = ":";
    if (secondsRemaining<10) {
      pad = ":0";
    }
    $('.time').text(minutesRemaining + pad + secondsRemaining);
    
    if (secondsRemaining<0 && minutesRemaining<0) {
      document.getElementById('ding').play();
      if (working===true) {
        end = new Date().getTime() + parseInt($('.breaktime').text())*60000 ;
        working = false;
        $('.description').text("Break for another");
        $('.time').text($('.breaktime').text());
      } else {
        end = new Date().getTime() + parseInt($('.worktime').text())*60000 ;
        working = true;
        $('.description').text("Work for another");
        $('.time').text($('.worktime').text());
      }
      
    }
  }, 1000);
}

function resetTimer() {
  clearInterval(timer);
  $('.time').text($('.worktime').text());
  $('.description').text("Work for another");
  
}
            
          
!
999px
Loading ..................

Console