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.

            
              
<html>
<body>
<div class="container-fluid">  
<h1>Pomodoro Clock</h1>
  
  <div class="row">
<div class="col-md-6" id = "break">  
<div>
  <button class = "btn btn-large btn-inline btn-dark" id= "breakMinusTime">-</button>
  <h2 class = inline>break</h2>
  <button class = "btn btn-large btn-inline btn-dark" id= "breakPlusTime">+</button>
  </div>
   <div class = "square">
   <p  id="breakClock">05:00</p>
  </div>
  <div>
  <button onclick=breakTimer() class= "btn btn-larger btn-inline btn-dark btn-space " id="breakStart">start</button> 
  <button class= "btn btn-larger btn-inline btn-dark btn-space " id="breakStop">stop</button>        
  <button class="btn btn-larger btn-inline btn-dark btn-space " id="breakReset">reset</button>  
  </div>
   
  </div>
  
 <div class="col-md-6"> 
   <div>
     <button class = "btn btn-large btn-inline btn-dark" id= "mainMinusTime">-</button>
  <h2 class = inline>work</h2> 
     <button class = "btn btn-large btn-inline btn-dark" id= "mainPlusTime">+</button>
   </div>
     <div>
<div class = "square">     
<p id="clock">25:00</p>
     </div>
       <div>
<button onclick=mainTimer() class="btn btn-larger btn-inline btn-dark btn-space " id="start">start</button>     
<button class= "btn btn-larger btn-inline btn-dark btn-space " id="stop">stop</button> 
<button class="btn btn-larger btn-inline btn-dark btn-space " id="reset">reset</button> 
       </div>
  </div>
    </div>
    
    
  
  
  
  </div>
</body>
</html>
            
          
!
            
              body {
  text-align: center;
  color: black;
  background-color: white;
}

h1 {
  color: gray;
  font-size:70pt;
  margin-top: 50px;
  margin-bottom: 70px;
}

.btn-space {
  margin-left: 0px;
  margin-right: 0px;
  }
}

h2 {
  margin-top: 50px;
  margin-left: 30px;
  margin-right: 30px;
}

p {
  
  font-size:36pt;
}

#break {
  margin-bottom: 100px;
}


.btn-dark{
  background-color: gray;
  outline: gray;
  color: white;
}
.btn-dark:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  border-color: white;
}

.circle {
  border-color:rgb(200,250,150) ;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
    height: ;
  margin-bottom: 25px;
}

.square {
  border-color: rgb(38,1,38);
  border-width: 10px;
  border-style: solid;
  border-radius: ;
  margin-left: 50px;
  margin-right: 50px;
  margin-bottom: 30px;
  margin-top: 30px;
  background-color: rgb(191,191,191);
}

.breakClock {
  
}

#clock, #breakClock {
  font-size: 70pt;
}

div {display:block;
  
}
.inline {display:inline-block;}
.btn-inline{display:inline-block;
vertical-align: 50%;}
.btn-larger {
  font-size: 20pt;
}
            
          
!
            
              
var t = 25;  // default time for main timer in minutes
var z = 5; //default time for break timer in minutes

//updates main clock, is called when increasing or decreasing work time 
function updateClock(){ 
if (t<10){document.getElementById("clock").innerHTML="0"+t+":"+"00"};               if (t>=10) {document.getElementById("clock").innerHTML=t+":"+"00"};       

}

//decrease work time
document.getElementById("mainMinusTime").onclick = function(){
  t -=1;
  
updateClock(); }

//increase work time
document.getElementById("mainPlusTime").onclick = function(){
  t +=1;
 
updateClock(); }

//updates break clock, is called when increasing or decreasing break time
function updateBreakClock(){ 
if (z<10){document.getElementById("breakClock").innerHTML="0"+z+":"+"00"};               if (z>=10) {document.getElementById("breakClock").innerHTML=z+":"+"00"}; 
}

//decrease break time
document.getElementById("breakMinusTime").onclick = function(){
  z -=1;
  
  updateBreakClock();
 }
//increase break time
document.getElementById("breakPlusTime").onclick = function(){
  z +=1;
  
  updateBreakClock();
 }




//timer functions are below

//puts a zero in front of a digit smaller than ten so the clock looks good, used in main timer function
function timeFormat(x) { 
    var corrected = x;
    if (x<10) {
      corrected = "0" + x;}
      return corrected;
    
  }
//converts time in minutes to ms
function timerSet(x) {
  millesecs = x * 60 * 1000;
  return millesecs
}

function mainTimer(){
var start = new Date();
var myVar = setInterval(myTimer, 100);


function myTimer() {
    var now = new Date();
  var a = start.getTime()+timerSet(t)-now.getTime();
  var date = new Date(a);
   
var m = date.getMinutes();
var formattedM = timeFormat(m);  
var s = date.getSeconds();
var formattedS = timeFormat(s);  document.getElementById("clock").innerHTML = formattedM + ":" + formattedS;

  //on stop, the clock saves the time left, a, and stores it as t, the timer setting in minutes
document.getElementById("stop").onclick = function(){ 
t = a /60000;
  clearInterval(myVar);}  

document.getElementById("reset").onclick = function(){ 
  clearInterval(myVar);
  t =25;
  updateClock();
}

if (s==0 && m==0){
  clearInterval(myVar);
  window.alert("Time is up!"); 
  breakTimer();
 
}  
}
}

//break functions below
function breakTimer(){
var start = new Date();
var myVar2 = setInterval(myTimer, 100);

function myTimer() {
    var now = new Date();
  var a = start.getTime()+timerSet(z)-now.getTime();
  var date = new Date(a);
   
var m = date.getMinutes();
var formattedM = timeFormat(m);  
var s = date.getSeconds();
var formattedS = timeFormat(s);  document.getElementById("breakClock").innerHTML = formattedM + ":" + formattedS;

document.getElementById("breakStop").onclick = function(){ 
z= a /60000;
  clearInterval(myVar2);}  
  
document.getElementById("breakReset").onclick = function(){ 
  clearInterval(myVar2);
  z = 5;
  updateBreakClock();
}

if (s==0 && m==0){
  clearInterval(myVar2);
  window.alert("Break is up!"); 
  mainTimer();
}  
}
}
            
          
!
999px
Loading ..................

Console