123

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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 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.

            
              <body>
 
  <div id="clock">
    <h class="title"> Work Clock </h>

    <div id="settingWheel">

      <div id="timer1"> <h> Work</h>
      <button type="button" class="smallBut" id="plus">+</button>  
        <div id="set1"> </div><button type="button" class="smallBut" id="minus">-</button>
        </div>


      <div id="timer2"> <h> Break </h> <button type="button" class="smallBut" id="plus1">+</button>
        <div id="set2"> </div>
        <button class="smallBut" type="button" id="minus1">-</button>
      </div>


      <div id="face">

      </div>

 <button type="button" class="action" id="action">ActionTime!</button>  
      <button type="button" class="action" id="break">BreakTime!</button>
            <button type="button" class="action" id="pause">Pause</button>
 <button type="button" class="action" id="clear">Clear</button>

        </div>
            
          
!
            
              body{
  background-color:black;
}

#clock{
  background-color:#663300;
  height:550px;
  width:380px;
  margin:5% 29%;
  border-radius:15px;
}
#settingWheel{
   display: inline-block;
    border: 3px solid black;
    text-align: center;
  border-radius:160px;
  height:290px;
  width: 305px;
    margin: 7% 11%; 
  background-color:#663522;
        box-shadow: 7px 7px 9px  #211;

} 

#timer1 {      
    margin-top:15%;
  margin-left:15%;
 float:left;
  height:100px;
  width:100px;
  
}
#timer2 {
    margin-right:15%;

  margin-top:15%;
 float:right;
  height:100px;
  width:100px;
  
  }

#set1{
  font-weight:bold;
  font-size:20px;
    color:black;
  text-shadow:1px 0px #311;

}
#set2{
 text-shadow:1px 0px #311;

  font-weight:bold;
  font-size:20px;
    color:black;
}


#face {
  height:60px;
  width:300px;
  background-color:grey;
    margin-bottom:08%;
border:3px solid black;
      box-shadow: 3px 3px  #111;
  margin-top:100%;
  align:center;
  border-radius:10px;
 color:black;
  font-size:40px;
  box-shadow:5px black; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}

button{
  background-color:grey;
  border:1px solid black;
  border-radius:2px;
  font-weight:bold;
 text-align:center;
}
h{color:black;
font-size:23px;
font-weight:bold;
text-shadow:1px 0px #311;}

.action{
  margin:auto;
  align:center;
  font-weight:bold;
  color:black;
  font-size:20px;
  border-radius:7px;
  border:3px solid black;
  box-shadow: 3px 3px  #111;

}
.smallBut {
 width: 40px;
    margin:auto;
    display: block;
  font-size:16px;;
  font-color:black;
  color:black;
}
.title{
  font-weight:bold;
  text-decoration:underline;
  font-size:29px;
      text-shadow: 1px 1px  #111;
  margin-left:30%;
    margin-top:20%;
}
            
          
!
            
              var time = 1250;
var time2 = 300;
var tickAudio = new Audio('http://soundbible.com/grab.php?id=2148&type=mp3');

$("#set1").text(Math.floor(time/60) + " m");
$("#set2").text(Math.floor(time2/60) + " m"); // Displays var time 
$("#face").text(Math.floor(time/60) + " m");

$("#plus").click (function() { //Plus
  time += 60;
  $("#face").text(getTime(time));
  $("#set1").text(getTime(time));
}); //Plus Minus Buttons functions

$("#minus").click(function() { //Minus
  time -= 60;
  $("#face").text(getTime(time));
  $("#set1").text(getTime(time));
});

$("#plus1").click(function() { //Plus (break)
  time2+=60;
     $("#set2").text(getTime(time2));
}); //Plus Minus for BreakTime

var timeoutId=0;
function increment(){
  time2+=60;
 $("#set2").text(getTime(time2));
};

 $("#plus1").mousedown(function() { 
   timeoutId= setTimeout(increment, 100);
}).bind('mouseup mouseleave', function() {
    clearTimeout(timeoutId);
});

$("#minus1").click(function() { //Minus (break)
  time2 -= 60;
  $("#set2").text(getTime(time2));
});

var countdownID;

$("#action").click(function() {
  countdownID = setInterval(countdown, 1000);

}); //COuntdown Button


function countdown() {
  $("#face").text(getTime(time)); //show time 
  $("#set1").text(getTime(time));
  $('#action').prop('disabled', true);
  $('#break').prop('disabled', false);

  if (time <= 0) { //if time gets to 0
    $('#action').prop('disabled', false);
        tickAudio.play();
        


    clearInterval(countdownID);
    time = 60;
    $("#face").text(getTime(time)); 
    $("#set1").text(getTime(time));
    
  }
  //stop that function with variable
  time -= 1;
}; //Countdown Button Function

var countdownID2;
$("#break").click(function() {
  clearInterval(countdownID);
  countdownID2 = setInterval(countdown2, 1000);
});

function countdown2() {
  $('#break').prop('disabled', true);
  $('#action').prop('disabled', false);

  $("#face").text(getTime(time2)); //show BREAK time 
  $("#set2").text(getTime(time2));

  if (time2 <= 0) {
            tickAudio.play();

    $('#break').prop('disabled', false);
    clearInterval(countdownID2);
    time2 = 60;
    console.log(time2);
    $("#face").text(getTime(time2)); 
    $("#set2").text(getTime(time2));
  }
  time2 -= 1;
};

$("#pause").click(function() {
  clearInterval(countdownID);
  clearInterval(countdownID2);
  
  $('#action').prop('disabled', false);
  $('#break').prop('disabled', false);

});
$("#clear").click(function() {
  clearInterval(countdownID);
  clearInterval(countdownID2);
  
  $('#action').prop('disabled', false);
  $('#break').prop('disabled', false);
$("#face").text(0); //show time 
 $("#set1").text(0);
   $("#set2").text(0);
  time=0;

});

//TIME CONVERTER
function getTime(seconds) { //Function to CONVERT TIME
  var hours = Math.floor(seconds / 3600);
  var minutes = Math.floor(seconds / 60);
  seconds = seconds - (minutes * 60);

  if (minutes >= 1 && minutes <= 59) {
    return (minutes + " m" + ':' + seconds + " s");
  }
   else
    return (seconds + " s");
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console