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.

            
              <div id = "container">
  <h1>Simple Pomodoro Clock</h1>
</div>
<div id = "container">
<h4>Pomodoro Length: </h4>
<input id = "clock" value = 25>
<h4>Break Length: </h4>
<input id = "break" value = 5>
</div>
<div id = "container">
<button id = "start">Start my clock!</button>
<div id = "continue">
</div>
</div>
<h2 id = "demo"></h2>
<div id="myProgress">
  <div id="myBar"></div>
</div>
<div id = "timeType">
</div>
            
          
!
            
              h3 {
  text-align: center;
}
h2 {
  text-align: center;
  margin-bottom: -30px;
}
#container {
  display: flex;
  justify-content: center;
}
h4 {
  margin-right: 20px;
}
input {
  margin-right: 20px;
}
button {
  margin: 20px;
}
#myProgress {
  width: 75%;
  background-color: #ddd;
  margin: auto;
}

#myBar {
  width: 0%;
  height: 30px;
  background-color: red;
}
            
          
!
            
              
$(document).ready(function(){
  var minutes;
  var seconds;
  var startMinutes;
  var startSeconds;
  var barSeconds;
  var started = false;
  var active = true;
  var width = 0.00;
  
  $("#start").click(function(){
    active = true;
    if (started == false) {
    started = true;
    $("#start").html("Pause my clock!");
    $("#continue").html("");
    startMinutes = $("#clock").val();
    startSeconds = startMinutes*60;
      barSeconds = startSeconds;
      width = 0.00;
    document.getElementById("myBar").style.backgroundColor = "red";
      document.getElementById("myBar").style.width = 0;
      $("#timeType").html("<h3>Work time!</h3>");
      $("h3").css("color", "red");
  
	 interval = setInterval(function() {
      // Time calculations for days, hours, minutes and seconds
      minutes = Math.floor(startMinutes % (60));
      seconds = Math.floor(startSeconds % (60));
    
     //Make seconds look good
    if(parseInt(seconds) < 10) {
      seconds = "0" + seconds;
    }

      // Output the result in an element with id="demo"
      document.getElementById("demo").innerHTML = minutes + ":" + seconds;
     
     //Progress bar
     if(startSeconds != barSeconds) {
     width += 100/barSeconds;
    document.getElementById("myBar").style.width = width + '%';
     }
    
      if(seconds == 0)
      {
          startMinutes = startMinutes - 1;
      }
      startSeconds = startSeconds - 1;
      if(startSeconds < 0) {
        
        if(active) {
          startMinutes = $("#break").val();
          startSeconds = startMinutes*60;
          active = false;
          width = 0.00;
    document.getElementById("myBar").style.backgroundColor = "#4CAF50";
          $("#timeType").html("<h3>Break time!</h3>");          $("h3").css("color", "#4CAF50");
          barSeconds = startSeconds;
        }
        else {
          startMinutes = $("#clock").val();
          startSeconds = startMinutes*60;
          active = true;
          width = 0.00;
    document.getElementById("myBar").style.backgroundColor = "red";
          $("#timeType").html("<h3>Work time!</h3>");
          $("h3").css("color", "red");
          barSeconds = startSeconds;
        }
      }
    
	}, 1000);
    }
    else {
      started = false;
      clearInterval(interval);
      $("#start").html("Restart my clock!");
      $("#continue").html("<button id = 'cont'>Continue my clock!</button>");
    }
  });
  $("#continue").click(function(){
    if (started == false) {
    started = true;
    $("#start").html("Pause my clock!");
    $("#continue").html("");
  
	 interval = setInterval(function() {
      // Time calculations for days, hours, minutes and seconds
      minutes = Math.floor(startMinutes % (60));
      seconds = Math.floor(startSeconds % (60));
    
     //Make seconds look good
    if(parseInt(seconds) < 10) {
      seconds = "0" + seconds;
    }

      // Output the result in an element with id="demo"
      document.getElementById("demo").innerHTML = minutes + ":" + seconds;
     //Progress bar
     width += 100/barSeconds;
    document.getElementById("myBar").style.width = width + '%';
    
      if(seconds == 0)
      {
          startMinutes = startMinutes - 1;
      }
      startSeconds = startSeconds - 1;
      if(startSeconds < 0) {
        
        if(active) {
          startMinutes = $("#break").val();
          startSeconds = startMinutes*60;
          active = false;
          width = 0.00;
          document.getElementById("myBar").style.backgroundColor = "#4CAF50";
          $("#timeType").html("<h3>Break time!</h3>");
          $("h3").css("color", "#4CAF50");
          barSeconds = startSeconds;
        }
        else {
          startMinutes = $("#clock").val();
          startSeconds = startMinutes*60;
          active = true;
          width = 0.00;
          document.getElementById("myBar").style.backgroundColor = "red";
          $("#timeType").html("<h3>Work time!</h3>");
          $("timeType").css("color", "red");
          barSeconds = startSeconds;
        }
      }
	}, 1000);
    }
    else {
      started = false;
      clearInterval(interval);
      $("#start").html("Restart my clock!");
      $("#continue").html("<button id = 'cont'>Continue my clock!</button>");
    }
  });
});
            
          
!
999px
Loading ..................

Console