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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                <html>
  <body>
    <div class="main">
      <h3 class="header">Pomodoro Clock</h3>
      <div class="left">
        <p id="break-length">BREAK LENGTH</p>
        <div class="minus-left">-</div>
        <div class="break-value">1</div>
        <div class="plus-left">+</div>
      </div>
      <div class="right">
        <p id="session-length">SESSION LENGTH</p>
        <div class="minus-right">-</div>
        <div class="session-value">0</div>
        <div class="plus-right">+</div>
      </div>
      <div class="clock-face">
        <p id="clock-session">Session</p>
        <p id="clock-break">Break</p>
        <div class="stop">Stop</div>
        <div class="resume">Resume</div>
        <div class="timer">
          <div class="min"><p id="min-time"></p></div>
          <div class="colon">:</div>
          <div class="sec"><p id="sec-time"></p></div>
        </div>
      </div>
    </div>
  </body>
</html>
              
            
!

CSS

              
                body{
  background-color:#DD6A22;
}
.main{
  width:600px;
  margin:0px auto;
  height:500px;
}
.header{
  margin:50px auto 0px auto;
  text-align:center;
  font-family:Monaco;
  font-size:4em;
  color:white;
}
.left{
  height:120px;
  width:120px;
  margin:40px auto 0px 100px;
  display:inline-block;
}
.right{
  height:120px;
  width:120px;
  margin:40px 100px 0px auto;
  float:right;
}
.clock-face{
  display:block;
  height:275px;
  width:275px;
  border-radius:50%;
  margin:0px auto;
  border:4px solid green;
}
#break-length{
  text-align:center;
  margin-top:5px;
}
.minus-left{
  float:left;
  margin-left:10px;
  line-height:40px;
  display:inline-block;
  font-size:2em;
  cursor:pointer;
}
.plus-left{
  float:right;
  margin-right:10px;
  line-height:40px;
  display:inline-block;
  font-size:2em;
  cursor:pointer;
}
.minus-right{
  float:left;
  margin-left:10px;
  line-height:40px;
  display:inline-block;
  font-size:2em;
  cursor:pointer;
}
.plus-right{
  float:right;
  margin-right:10px;
  line-height:40px;
  display:inline-block;
  font-size:2em;
  cursor:pointer;
}
.break-value{
  margin:0px auto 0px 30px;
  display:inline-block;
  font-size:2em;
}
#session-length{
  text-align:center;
  margin-top:5px;
}
.session-value{
  margin:0px auto 0px 30px;
  display:inline-block;
  font-size:2em;
}
#clock-session{
  display:inline-block;
  margin:20px auto 0px 2.5px;
  padding:40px;
}
#clock-break{
  display:inline-block;
}
.clock-face p{
  font-size:1.5em;
}
.stop{
  position:absolute;
  margin:-20px 115px;
  cursor:pointer;
}
.resume{
  position:absolute;
  margin:-20px 100px;
  cursor:pointer;
  display:none;
}
.timer{
  height:100px;
  width:150px;
  margin:0px auto;
  position:relative;
}
.min{
  height:100%;
  width:45%;
  display:inline-block;
}
.colon{
  display:inline-block;
  height:100px;
  position:absolute;
  top:25%;
  font-size:2em;
  margin-left:3px;
}
.sec{
  height:100%;
  width:45%;
  display:inline-block;
  float:right;
}
#min-time{
  text-align:center;
  margin-top:25px;
  font-size:2em;
}
#sec-time{
  text-align:center;
  margin-top:25px;
  font-size:2em;
}
              
            
!

JS

              
                var countdown_timer; //for session length
var break_timer; //for break length
var sec; //seconds for session
var min; //minutes for session
var sec_break; //seconds for break
var min_break; //minutes for break
var total_time; //total time that needs to elapse for session
var total_time_break; //total time that needs to elapse for break
var time_arr; //time array
//var session_flag = false; //boolean for session code
//var break_flag = false; //boolean for flag code 
$(document).ready(function() {

  $(".plus-left").click(function() {
    var temp = $(".break-value").text();
    temp = parseInt(temp);
    temp++;
    $(".break-value").text(temp);
  });

  $(".minus-left").click(function() {
    var temp = $(".break-value").text();
    temp = parseInt(temp);
    temp--;
    if (temp > -1) {
      $(".break-value").text(temp);
    }
  });

  $(".minus-right").click(function() {
    var temp = $(".session-value").text();
    temp = parseInt(temp);
    temp--;
    if (temp > -1) {
      $(".session-value").text(temp);
    }

  });

  $(".plus-right").click(function() {
    var temp = $(".session-value").text();
    temp = parseInt(temp);
    temp++;
    $(".session-value").text(temp);
  });
  
  $("#sec-time").text(60);//setting the second value
  
  getValues();
  
  $(".stop").click(function(){
    $(".resume").fadeIn(500);
    $(".stop").fadeOut(500);
    if(session_flag){
      clearInterval(countdown_timer);
    }
    else if(break_flag){
      clearInterval(break_timer);
    }
  });
  
  $(".resume").click(function(){
    $(".resume").fadeOut(500);
    $(".stop").fadeIn(500);
    if(session_flag){
      getValues();
    }
    else if(break_flag){
      break_session();
    }
  });
  
});

//This is where the regular session starts
function getValues() {
  session_flag=true;
  break_flag=false;
  $("#min-time").text($(".session-value").text());
  time_arr = new Array();
  time_arr[0] = $("#min-time").text();
  time_arr[1] = $("#sec-time").text();
  startCountDown(time_arr);
}

function startCountDown(time_arr) {
    sec = parseInt(time_arr[1]);
    min = parseInt(time_arr[0]);
    total_time = min * 60 + sec; //the total time that needs to elapse
    countdown_timer = setInterval(function() {
      sec = sec - 1;
      total_time--;
      changeValue(min, sec);
    }, 1000);
}


function changeValue(min_1, sec_1) {
  $("#clock-session").css("color","green").css("transition","linear 0.2s");
  $("#clock-break").css("color","black").css("transition","linear 0.2s");
  $(".clock-face").css("border","4px solid green");
  $("#sec-time").text(sec_1);
  if (total_time == 0) {
    clearInterval(countdown_timer);
    sec_break=60;
    break_session();
  }

  if (sec_1 < 10) {
    $("#sec-time").text("0" + sec_1);

    if (sec_1 == 0 && min_1 != 0) {
      min = min_1 = min_1 - 1;
      $("#min-time").text(min_1);
      sec = 60;
    }
  }
}
//This is where the break session code starts

function break_session(){
  session_flag=false;
  break_flag=true;
  $("#clock-session").css("color","black").css("transition","linear 0.2s");
  $("#clock-break").css("color","red").css("transition","linear 0.2s");
  $(".clock-face").css("border","4px solid red");
  $("#min-time").text($(".break-value").text());
  min_break=$("#min-time").text();
  total_time_break = min_break*60+sec_break;
  break_timer = setInterval(function(){
    sec_break=sec_break-1;
    total_time_break--;
    changeValue_break(min_break,sec_break);
  },1000);
}

function changeValue_break(min_1,sec_1){
  $("#sec-time").text(sec_1);
  if (total_time_break == 0) {
    $("#sec-time").text(60);
    clearInterval(break_timer);
    getValues();
  }

  if (sec_1 < 10) {
    $("#sec-time").text("0" + sec_1);

    if (sec_1 == 0 && min_1 != 0) {
      min_break = min_1 = min_1 - 1;
      $("#min-time").text(min_1);
      sec_break = 60;
    }
  }
}
              
            
!
999px

Console