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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <body class="bg-dark">
   <div class="container">
     <div class="row clock">
         <div class="1st-box">
           <button class="btn btn-secondary break" id="break-decrement" value="-1">-</button>
          <span class="break-label border-bottom" id="break-label">Break Length:</span>
          <span class="break-length" id="break-length">5</span> 
          <button class="btn btn-secondary break" id="break-increment" value="+1" >+</button>
  </div>
  
        <div class="2nd-box ">
          <button class="btn btn-secondary session" id="session-decrement" value="-1">-</button>
          <span class="session-label border-bottom" id="session-label">Session Length:</span>
          <span class="session-length" id="session-length">25</span>
          <button class="btn btn-secondary session" id="session-increment" value="+1" >+</button>
        </div>
    <div class=" 3rd-box text-center">
        <span class="session-time text-center border-bottom" id="timer-label">Session</span>
          <span class=" text-center" id="time-left">25:00</span>
      </div>
      <div class="4th box"><button type="button" class="btn btn-default btn-sm " id="start_stop">
               Start/stop
            </button>
       <button type="button" class="btn btn-default btn-sm " id="reset">
               Reset
            </button>
      </div>
    </div>
  </div>
 <audio 
   src="https://freesound.org/data/previews/262/262859_2906614-lq.mp3" type="audio/mp3" id= "beep">
  
</audio>
    
  </div>
  <footer class="footer fixed-bottom text-center pt-4">Pomodoro Clock by Daniel Hernandez</footer>
</body>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Orbitron');

.clock {
  position:absolute;
  padding: 15px;
  top: 25%;
  left:15%;
  margin:5px;
}

.row{
  border: 5px solid red;
  border-radius: 5%;
}

body {
  font-family: Orbitron;
  color:white;
}
.border-bottom {
  
}

.break-label {
  color: white;
  font-family:Orbitron;
  
}


.break-length {
  color: red;
  font-family:Orbitron;
  
}
.session-length {
  color: red;
  font-family:Orbitron;
  
}



.session-label {
  color: white;
  font-family:Orbitron;
  
}



#break-increment {
      margin-right:10px;
  }



.footer{
  position:relative;
  top:0%;
  padding-top:
}

#timer-label{
  margin-left:10px;
  
}

#time-left {
  margin-left:10px;
   color:red;
}

#start_stop{
  margin-left: 5px;
}

@media all and (max-width:620px){
  
  
  
  .row {
    margin-bottom:50px;
  }
  
  .clock {
    left:2%;
  }
  
  
  
}
              
            
!

JS

              
                $(document).ready(function(){

// declare initial variables
  var timeleft = parseInt($("#session-length").text() ) * 60 ;
  var timeleft2 = parseInt($("#break-length").text() ) * 60 ;

  var breakNum = 5;
  var sessionNum = 25.00;
   var trigger = false;
     var audio = document.getElementById("beep");
    var Timer;
  
  
//   create session timer function 
  function timer () { 
    
       
   
     Timer= setInterval(function(){
             timeleft--;
            var  minutes = parseInt(timeleft / 60, 10);
             var seconds = parseInt(timeleft % 60, 10);
            minutes = minutes < 10 ? "0" + minutes : minutes;
               seconds = seconds < 10 ? "0" + seconds : seconds;
            document.getElementById("time-left").textContent = minutes.toString() +":" + seconds.toString();
              console.log(timeleft)
          if(minutes == "00" && seconds=="00"){
              audio.play();
              clearInterval(Timer);
              timeleft2 = eval($("#break-length").text())*60;
              BreakTimer();
              $("#timer-label").text("break");
          }
        },1000);

    
    
  

  
  
}
//     create function for break increments and decrements 
  
  $(".break").click(function(){
        var num = parseInt($("#break-length").text());
        var value = $(this).val();
    if((num  == 1 && value == "-1")|| (num == 60 && value == "+1") ){
              breakNum = breakNum;

}
    else {
      breakNum = breakNum + value;
      $("#break-length").text(eval(breakNum));
       timeleft2 = parseInt($("#break-length").text() ) * 60; 

    }
});

//   create function for session increments and decrements 
  
 $(".session").click(function(){
      var num = parseInt($("#session-length").text());
      var value = $(this).val();
     if((num  == 1 && value == "-1")|| (num == 60 && value == "+1") ){

        sessionNum= sessionNum;
    }
     else {
        sessionNum = sessionNum + value;
          if (eval(sessionNum)<10){
            $("#time-left").text("0"+eval(sessionNum)+".00");
            $("#session-length").text(eval(sessionNum));
            timeleft = parseInt($("#session-length").text() ) * 60 ;

        }
         else {
            $("#session-length").text(eval(sessionNum));

           $("#time-left").text(eval(sessionNum)+".00");
           timeleft = parseInt($("#session-length").text() ) * 60 ;
         }
     }
}); 
  
//   create reset function for button 
  
  $("#reset").click(function(){
        clearInterval(Timer);
        $("#break-length").text(5);
        $("#session-length").text(25);
        $("#time-left").text("25.00");
        $("#timer-label").text("Session");
        breakNum = 5;
        sessionNum = 25.00;
        audio.currentTime = 0;
        timeleft = $("#session-length").text()*60;
        timeleft2 = $("#break-length").text()*60;
        trigger=false;
  });
  
  
  function BreakTimer (){ 
        Timer= setInterval(function(){
             timeleft2--;
          var  minutes = parseInt(timeleft2 / 60, 10);
           var seconds = parseInt(timeleft2 % 60, 10);
        minutes = minutes < 10 ? "0" + minutes : minutes;
           seconds = seconds < 10 ? "0" + seconds : seconds;
        document.getElementById("time-left").textContent = minutes.toString() +":" + seconds.toString();

    if(minutes == "00" && seconds=="00"){
        audio.play();
        clearInterval(Timer);
        timeleft = eval($("#session-length").text())*60;
        $("#timer-label").text("Session");

        timer();
    }
    },1000);
  
}
// create action for start_stop button 
  
$("#start_stop").click(function () {
    if(!trigger){
      timer();
      trigger=true;
      console.log(trigger)

  }
    else if (trigger){
        clearInterval(Timer)
        trigger = false;
        console.log(trigger);
    }  


});

  
  
  });
              
            
!
999px

Console