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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <div class="container-fluid">
<link href="https://fonts.googleapis.com/css?family=Modak|Roboto+Slab" rel="stylesheet">
  
  <h1> Tomato Timer </h1>
  
  <div class="block">
  
  <div class="row">
  
  <button class="btn btn-primary btn3" id="pomoBtn"><h5>Pomodoro</h5>
       </button>
  
  <button class="btn btn-primary btn3" id="breakBtn"><h5>Break</h5>
       </button>
  </div>
  
  <div class="row">
    
    <button class="btn btn-primary btn2" id="plusBtn"><h5>+</h5>
       </button>
    
  <h2 id="display">
  25:00
</h2>
 
  
  <button class="btn btn-primary btn2" id="minusBtn"><h5>-</h5>
       </button>
    
     </div>
  
   <button class="btn btn-primary btn3" id="startBtn"><h5>Start </h5>
       </button>
  
   <button class="btn btn-primary btn3" id="pauseBtn"><h5>Pause</h5>
       </button>
  
  <button class="btn btn-primary btn3" id="resetBtn"><h5>Reset</h5>
       </button>
  
  <audio id="sound" src="http://www.freesfx.co.uk/rx2/mp3s/2/13637_1459784036.mp3" preload="auto"></audio>
   
</div>
  
   
     <footer class="page-footer">
    Project by <a href="https://codablejoy.com/" >CodableJoy</a>
    </footer>
  
</div>






              
            
!

CSS

              
                h1{
  margin-top: 60px;
  text-align: center;
  font-family: 'Modak', cursive;
  font-size: 100px;
}

h2{
 
  margin-top: 40px;
  margin-left: -100px;
  margin-right: -100px;
  margin-bottom: 30px;
  font-family: 'Roboto Slab', serif;
}

.btn{

  background-color: #FAEBD7;
  border: none;
  color: black;
  font-family: 'Roboto Slab', serif;
  padding-top:20px;
  padding-bottom:20px;
}

#pomoBtn{
  background-color: orange;
}


#startBtn{
  background-color: green;
  margin-right: 20px;
}

#pauseBtn{
  background-color: red;
  margin-right: 20px;
}



.row{
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 50px;
 
}

.btn3{
    margin: 20px auto;
  width:200px;
}

#display{
  padding: 5px -50px;
  font-size: 50px;
}

.btn2{
  margin: 20px auto;
  width: 100px;
  height: 50px;
  margin-top: 30px;
  font-family: 'Roboto Slab', serif;
  padding-top: 5px; 

}

h5{
  font-size: 30px;
}

#breakBtn{
  background-color: #FAEBD7;
}

#breakBtn:hover{
  background-color: blue;
}


.block{
  background-color: #FF6347;
  width: 1000px;
  padding-top: 100px;
  padding-bottom: 100px;
  margin-right: auto;
  margin-left: auto;
  margin-top: 100px;
  margin-bottom: 0px;
  text-align:center;
  font-family: 'Lato', sans-serif;
  opacity: 1;
  border-radius: 100px;
}

body{
  background-color: 
}

.page-footer{
  margin-top: 150px;
  font-size: 20px;
  text-align: center;
}


              
            
!

JS

              
                $(document).ready(function() {
  
  var durationPause = 0;
  var state = "pomo";
  var durationPomo= 25*60*1000;
  var durationBreak = 5*60*1000;
 
  
    $('#breakBtn').click(function () {
    $('#breakBtn').css({'background':'orange'});
       $('#pomoBtn').css({'background':'#FAEBD7'});
  state = "break";  
  document.getElementById("display").innerHTML = durationBreak/(60*1000) + ":" + "00"; 
  
                                                            });
  
   $('#pomoBtn').click(function () {
      $('#pomoBtn').css({'background':'orange'});
       $('#breakBtn').css({'background':'#FAEBD7'});
  state = "pomo";  
 document.getElementById("display").innerHTML = durationPomo/(60*1000) + ":" + "00" ; 
                                                            });
  
  
  $('#plusBtn').click(function () {
  if(state=="pomo"){
   durationPomo = durationPomo + 1*60*1000;
    document.getElementById("display").innerHTML = Math.floor(durationPomo/(60*1000)) + ":" + "00" ;  
  }
    
    else if(state == "break"){
      durationBreak = durationBreak + 1*60*1000;
        document.getElementById("display").innerHTML = Math.floor(durationBreak/(60*1000)) + ":" + "00" ;  
      
    }
    
    
                                                            });
  
  $('#minusBtn').click(function () {
      if(state=="pomo"){
   durationPomo = durationPomo - 1*60*1000;
    document.getElementById("display").innerHTML = Math.floor(durationPomo/(60*1000)) + ":" + "00" ;  
  }
    
    else if(state == "break"){
      durationBreak = durationBreak - 1*60*1000;
        document.getElementById("display").innerHTML = Math.floor(durationBreak/(60*1000)) + ":" + "00" ;  
      
    }

                                                            });
  
 
  
  
  //reset Button function
   $('#resetBtn').click(function () {
    
    if(state=="pomo"){
      durationPomo = 25*60*1000;
      document.getElementById("display").innerHTML = durationPomo/(60*1000) + ":" + "00" ;                                                        
    }
   else if(state == "break"){
       durationBreak = 5*60*1000;
        document.getElementById("display").innerHTML = durationBreak/(60*1000) + ":" + "00" ; 
     }
     
  
   });
  
  // end of reset Button function 
  function setTimer(timer){
    
   var target = new Date().getTime() + timer;
   var startFunction = setInterval (function(){
     
     var distance = target - new Date().getTime();
    
    var minutes = Math.floor((distance % (1000*60*60)) / (1000*60));
     
    minutes = minutes<10? "0" + minutes : minutes;
    
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);
      seconds = seconds < 10 ? "0" + seconds : seconds;
     
      $('#pomoBtn').click(function () {
    
   clearInterval(startFunction);
        if(state=="pomo")
       { durationPomo = 25*60*1000;
       document.getElementById("display").innerHTML = durationPomo/(60*1000) + ":" + "00" ;}
        
        if(state == "break"){
          durationBreak = 5*60*1000;
          document.getElementById("display").innerHTML = durationBreak/(60*1000) + ":" + "00" ;
        }
               
  });
     
    
     
      $('#breakBtn').click(function () {
       
    
   clearInterval(startFunction);
        if(state=="pomo")
       { durationPomo = 25*60*1000;
       document.getElementById("display").innerHTML = durationPomo/(60*1000) + ":" + "00" ;}
        
        if(state == "break"){
          durationBreak = 5*60*1000;
          document.getElementById("display").innerHTML = durationBreak/(60*1000) + ":" + "00" ;
        }
               
  });
     
      $('#pauseBtn').click(function () {
    
   clearInterval(startFunction);
        if(state=="pomo")
       { durationPomo = target - new Date().getTime();}
        
        if(state == "break"){
          durationBreak = target - new Date().getTime();
        }
               
  });
     
      $('#resetBtn').click(function () {
    
   clearInterval(startFunction);
       if(state == "pomo"){
         durationPomo = 25*60*1000;
        document.getElementById("display").innerHTML = durationPomo/(60*1000) + ":" + "00" ; }
        
         else if(state == "break"){
         durationBreak = 5*60*1000;
        document.getElementById("display").innerHTML = durationBreak/(60*1000) + ":" + "00" ; }
               
  });
    
     
 
   

document.getElementById("display").innerHTML = minutes + ":" + seconds ; 
   
    if (distance < 0) {
    clearInterval(startFunction);
    document.getElementById("display").innerHTML = "Time is Up!";
      document.getElementById('sound').play();
     alert("Time is Up!");
     
    
};
  }, 1000);
     
  };
  
  $('#startBtn').click(function () {
    
    if(state == "pomo"){
      
    setTimer(durationPomo);}
    
   else if(state == "break"){
     setTimer(durationBreak);
   };
   
  });
  
 
 
  });
  
 
              
            
!
999px

Console