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="row">
  <div class="container-fluid">
    
      <div class="col-md-4  col-xs-4 col-md-offset-2 col-xs-offset-2" id="break">
      <p>Break Length</p>
      <a style="display:inline" id="minus1" href="#">-</a>
      <p style="display:inline" id="breakl"> 5 </p>
      <a style="display:inline" id="plus1" href="#">+</a>
    </div> 
    
    <div class="col-md-4  col-xs-4 " id= "length" >
      <p>Duration</p>
      <a style="display:inline" id="minus" href="#">-</a>
      <p style="display:inline" id="pomodoro"> 25 </p>
      <a style="display:inline" id="plus" href="#">+</a>
    </div>
    <div class="col-md-4 col-md-offset-4 col-xs-4 col-xs-offset-4" id="clock">
      <p id="session">Session</p>
      <p style="display:inline" id="pomodoro1">25 </p>
      <p style="display:inline" id="seconds"> </p>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body{
  background-color:#83AF9B;
}
#clock {
  
  width: 400px;
  height: 400px;
  background-color: #ccc;
  border-radius: 200px;
  text-align: center;
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin-top: 175px;
background-color:#FE4365;
}

#clock p {
  padding-top: 100px;
  font-size: 30px;
  color:#F9CDAD;
}

#length {
  text-align: center;
  font-size: 30px;
 color:#F9CDAD
}

#length a {
  color: #C8C8A9;
  font-size: 30px;
  text-decoration: none;

}
#break{
  text-align: center;
  font-size: 30px;
 color:#F9CDAD
}

#break a {
  color: #C8C8A9;
  font-size: 30px;
  text-decoration: none;

}

#session {
  margin-top: 50px;
}
              
            
!

JS

              
                $(document).ready(function() {
  
  
  $("#plus").on('click', function() {
    var str = $("#pomodoro").html();
    var result = parseInt(str);

    $("#pomodoro1").html(eval(result + 1));
    $("#pomodoro").html(eval(result + 1));
  }); //plus

  $("#minus").on('click', function() {
    var str = $("#pomodoro").html();
    var result = parseInt(str);

    if (result > 1) {

      $("#pomodoro1").html(eval(result - 1));
      $("#pomodoro").html(eval(result - 1));
    } else if (result < 1) {

      console.log("Timer cant go to negative integers");
    }
  });
  
  $("#plus1").on('click', function() {
    var str1 = $("#breakl").html();
    var res = parseInt(str1);

    $("#breakl").html(eval(res + 1));
  }); //plus

  $("#minus1").on('click', function() {
    var str1 = $("#breakl").html();
    var res = parseInt(str1);

    if (res > 1) {

     
      $("#breakl").html(eval(res - 1));
    } else if (res < 1) {

      console.log("Timer cant go to negative integers");
    }
  });

 var clockActive = false;
  var intervalID;
  var sessionTime;
  var seconds;
  var breakTime ; 


  function displayFormat(seconds) {
    var formattedTime = '';
    var hour = Math.floor(seconds / 3600);
    var mins = Math.floor(seconds / 60);
    var sec =seconds%60;
    formattedTime += (hour < 10) ? '0' + hour : hour;
    formattedTime += ':' + ((mins < 10) ? '0' + mins : mins);
    formattedTime += ':' + ((sec < 10) ? '0' + sec : sec);

    return formattedTime;
  }
 
 
   function startBreakCountDown() {
    $("#pomodoro1").text(displayFormat(breakTime)); //format time left before displaying it
    if (breakTime === 0) {
      clearInterval(intervalID); 
     $("#session").html("Session");
      var str = $("#pomodoro").text();
        sessionTime = parseInt(str) * 60;                         
      intervalID = setInterval(startCountDown, 1000);
    }
    breakTime--;
  }
  
  function startCountDown() {
    $("#pomodoro1").text(displayFormat(sessionTime)); //format time left before displaying it
    if (sessionTime === 0) {
      clearInterval(intervalID); //clear the interval for session time

      $("#session").html("Break!");
      var str = $("#breakl").text();
      breakTime = parseInt(str) * 60; //converts to seconds
      console.log(breakTime);                              
      intervalID = setInterval(startBreakCountDown, 1000); // start another interval for break time using startBreakCountDown as callback, here we can just re-use intervalID
    }
    sessionTime--;
  }

  
  $("#clock").on('click', function() {
  if (clockActive){ 
    console.log("Clock active ignore click");
    // Or you could pause the clock
  }
  else {
    clockActive = true;
    var time = +$("#pomodoro1").html();
    sessionTime = time * 60;
    intervalID = setInterval(startCountDown, 1000);
  }
  });
});
              
            
!
999px

Console