Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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.

+ add another resource

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
  <div class="row">
    <div class="col-xs-12">
    <header>Pomodoro Clock</header>
  <h2>BREAK LENGTH
  
    </br><span class="clickable button hvr-bounce-in">-</span><span class="time" id="rest">5</span><span class="clickable button hvr-bounce-in">+</span>
</h2>
  <h2>SESSION LENGTH

</br><span class="clickable button hvr-bounce-in">-</span><span class="time" id="work">25</span><span class="clickable button hvr-bounce-in">+</span>

  </h2>

<h1><span id="title">Session</span></br><span id="timer">25</span></h1>

      <span id="start" class="clickable fa fa-play hvr-bounce-in"></span>

      <span id="reset" class="clickable fa fa-repeat hvr-bounce-in"></span>
    <p>To start the countdown click start!</p>
    <p>Pause and unpause by tapping the start button!</p>
    <p>To reset the clock, click the reset button!</p>    
</div>
</div>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Montserrat|Pacifico');

$padding: 30px;
$font-size: 25px;

body {
  font-family: Montserrat;
  margin-top: 35px;
  text-align: center;
  font-size: $font-size;
  background: url("https://hd.unsplash.com/photo-1444952483853-7c36e902e722") no-repeat fixed center;
  background-size: cover;
  color: white;
  text-shadow: black 0.3em 0.3em 0.3em;
  header {
    font-family: Pacifico;
    font-size: $font-size + 20;
  }
  h2 {
    padding: $padding;
    display: inline-block;
  }
  .clickable {
    cursor: pointer;
    padding: $padding - 10;
  }
}
              
            
!

JS

              
                var audio = $("#buzzer")[0],
  workTime = parseInt($("#work").text()),
  restTime = parseInt($("#rest").text()),
  workTimeInSec = workTime *= 60,
  restTimeInSec = restTime *= 60,
  playing = false,
  toWork = true,
  firstPeriod,
  secondPeriod;

//Increment and decrement buttons
$(".button").click(function() {

  if (playing == false) {

    var value = parseInt($(this).parent().find('.time').text());

    if ($(this).text() === "+") { // If it's a plus sign, increment the value

      $(this).parent().find(".time").text(value + 1);

    } else { // If it's a plus sign, decrement the value
      // Don't allow decrementing below one
      if (value > 1) {
        $(this).parent().find(".time").text(value - 1);

      } else {
        // Set it to one
        $(this).parent().find(".time").text("1");

      }
    }

    workTime = parseInt($("#work").text());
    restTime = parseInt($("#rest").text());
    workTimeInSec = workTime *= 60;
    restTimeInSec = restTime *= 60;
  }

});

$('#start').click(function() {
  // if the play button's value is 'play', call the play function
  // otherwise call the pause function

  if (playing === false) {

    $("#start").attr('class', "clickable fa fa-pause hvr-bounce-in");
    if (toWork) {
      $("#title").text('Session');

      firstPeriod = setInterval(work_int, 1000);

    } else {

      secondPeriod = setInterval(rest_int, 1000);
    }
    playing = true;
  } else {

    $("#start").attr('class', "clickable fa fa-play hvr-bounce-in");
    if (toWork) {

      clearInterval(firstPeriod);
    } else {

      clearInterval(secondPeriod);
    }
    playing = false;
  }

});

function countDown(val) {
  if (val % 60 >= 10) {
    $("#timer").html(Math.floor(val / 60) + ":" + val % 60);
  } else {
    $("#timer").html(Math.floor(val / 60) + ":" + "0" + val % 60);
  }
}

function work_int() {
  workTimeInSec -= 1;
  countDown(workTimeInSec);
  if (workTimeInSec === 0) {
    audio.play();
    clearInterval(firstPeriod);
    toWork = false;
    secondPeriod = setInterval(rest_int, 1000);
    $('#title').text('Break');
  }
}

function rest_int() {

  restTimeInSec -= 1;
  countDown(restTimeInSec);
  if (restTimeInSec === 0) {
    audio.play();
    clearInterval(secondPeriod);

    $("#start").attr('class', "clickable fa fa-play hvr-bounce-in");

    workTime = parseInt($("#work").text());
    restTime = parseInt($("#rest").text());
    workTimeInSec = workTime *= 60;
    restTimeInSec = restTime *= 60;
    counting = false;
    toWork = true;
  }
}

$("#reset").click(function() {
  clearInterval(firstPeriod || secondPeriod);
  $("#rest").html(5);
  $("#work").html(25);
  workTime = parseInt($("#work").text());
  restTime = parseInt($("#rest").text());
  workTimeInSec = workTime *= 60;
  restTimeInSec = restTime *= 60;
  $("#start").attr('class', "clickable fa fa-play hvr-bounce-in");
  counting = false;

})
              
            
!
999px

Console