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

              
                <Body>
  <div class="container-fluid">
    <div class="row">
      <h1> POMODOROMANIA</H1>
    </div>
    <div class="row"> 
      <div class="col-xs-12 col-md-6 bub">
        <h3> Work </h3>
        <p id="work">
          <button id="workPlus" class="btn timeChange" val='+w'>+</button> 
          <span id="workDisplay"></span> 
          <button id="workMinus" class="btn timeChange" val='-w'>-    </button>
        </p>
      </div>
      
      <div class="col-xs-12 col-md-6 bub">
        <h3> Break </h3>
        <p id="break">
          <button id="breakPlus" class="btn timeChange" val='+b'>+</button> 
          <span id="breakDisplay">
          </span>
          <button id="breakMinus" class="btn timeChange" val='-b'>-</button>
        </p>
      </div>
    </div>
    <div class='row'>
      <div class='col-xs-2 col-md-4'></div>
      <div  id= 'timerdiv' class="col-xs-8 col-md-4">
        <h3> Timer </h3>
        <p id="timer">
          <button id="timerGo"class="btn" >
            GO
          </button>
          <span id="timerDisplay">
          </span>
        </p>
       
        <p>GET TO WORK</p> 
         <p> <button id="reset"class="btn" >
            reset
          </button>
        </p>
        
      </div>
    </div>
</body>

              
            
!

CSS

              
                h1,h3,p{
  text-align:center;
}
body{
  background-color: #faa6ff;
  oolor: red;
  font-family: 'Pacifico', cursive;
}

#timerdiv{
  background-color: #7353ba;
  Border-radius: 1000px;
}

.bub{
  
}
h1{
  color: #0f1020;
}
h3{
  color: #0f1020;
}
p {
  color: #0f1020;
}

#reset{
  text-align:center;
}
              
            
!

JS

              
                /*to do
4c. create alert and play a sound.
*/
//base timer object
var timerOb={
  'work': 25,
  'break':5,
};
//sound 

  var sound= new Audio('https://s3.amazonaws.com/freecodecamp/simonSound3.mp3');
//global that will be assigned to the interval function
var int='';
//function to input times in p tags (will trigger on ready and when setup values change)
function update(){
  //update work span
  $("#workDisplay")[0].innerHTML=timerOb.work+':00';
  //update break span
  $("#breakDisplay")  [0].innerHTML=timerOb.break+':00';
  //update timer span
  $("#timerDisplay")[0].innerHTML=timerOb.work+':00';
  
}
$( document ).ready(update());
//listener function on + and Minus butons

$('.timeChange').click(function(event){
  //determine what button got pressed and then update the UI with new values
  var val = event.target.attributes.val.value;
  if (val=='+w'){
    timerOb.work++;
  }
  if (val=='-w'){
    //prevent negative values
    if(timerOb.work!=0){
      timerOb.work--;
    }
  }
  if (val=='+b'){
    timerOb.break++;
  }
  if (val=='-b'){
    //prevent negative values
    if(timerOb.break!=0){
      timerOb.break--;
    }
  }
  update();
});
//click listener on GO
$('#timerGo').click(function(){
  //setup
  var timerMin=timerOb.work;
  var timerSec=':00';
  var onBreak=false;
  //begin Work countdown
  int= window.setInterval(function(){
    //normal case for non zero seconds
    if (timerSec!=':00'){
        //get the  number of seconds
      var tmp=Number(timerSec.substr(1,2));
        //subtract one and put it back into a string
      tmp--;
      tmp=String(tmp);
        //if there's only one digit, tack on a zero
        if(tmp.length==1){
          tmp='0'+tmp;
        }
      //put the seconds back together
      timerSec=':'+(String(tmp));      
    }
    //case if seconds are in zeroes, set the seconds to 59 and remove a minute
    else{
      //case if the timer has hit zero minutes, zero seconds
      if(timerMin===0){
        if(onBreak===false){
          sound.play();
          alert('take a break!');
          timerMin=timerOb.break;
          timerSec=':00';
          onBreak = !onBreak;
        }
        else{
          sound.play();
          alert('back to work!')
          timerMin = timerOb.work;
          timerSec=':00';
          onBreak= !onBreak;
        }
      }
      //case if seconds are in zeroes and there are more minutes, set the seconds to 59 and remove a minute
      timerSec=':59';
      timerMin--;
    }
    console.log(timerMin+timerSec);
    $("#timerDisplay")[0].innerHTML=timerMin+timerSec;  
     
  },1000);
});
//reset function
 $('#reset').click(function(){
   clearInterval(int);
   update();
 })
     
    
              
            
!
999px

Console