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.

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

            
              <div id="main">

  <h1 id="title">freeCodeCamp Pomodoro Clock</h1>

  <div id="leaves">
    <div id="leaf1" class="leaf"></div>
    <div id="leaf2" class="leaf"></div>
  </div>
  <form id="options">

    <fieldset class="option">
      <label for="time">Set length of pomodoro:</label>
      <input id="time" class="input" type="number" value="25">
    </fieldset>

    <fieldset class="option">
      <label for="time">Set length of break:</label>
      <input id="break" class="input" type="number" value="5">
    </fieldset>

    <fieldset class="option">
      <label for="continuous">Continuous: </label>
      <div id="continuous">
        <input id="yes" class="radio" type="radio" name="continuous" value="yes" checked>
        <label for="yes">Yes</label>
        <input id="no" class="radio" type="radio" name="continuous" value="no">
        <label for="no">No</label>
      </div>

    </fieldset>

  </form>


  <div id="buttons">
    <button id="start">Start</button>
    <button id="stop">Stop</button>
    <button id="reset">Reset</button>
  </div>

  <div id="breakMessage">Take a break!</div>
  <div id="timer"></div>

</div>

<audio id="sound" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/431676/alarm.mp3" type="audio/mpeg"></audio>
            
          
!
            
              @import 'https://fonts.googleapis.com/css?family=Pridi';

body {
  background-image: url(https://images.unsplash.com/photo-1439754389055-9f0855aa82c2?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=0ab93ab17cc09e03f171d90af0308579);
  background-size: cover;
  background-repeat: no-repeat;
  font-family: 'Pridi', serif;
  color: #0d0d0d;
}

#main {
  width: 600px;
  margin-top: 40px;
  margin-left: auto;
  margin-right: auto;
  padding: 20px;
  background-color: #fff;
  border-radius: 10%;
  border: 2px solid grey;
}

#title {
  text-align: center;
  font-size: 40px;
  margin: 10px;
}

#leaves {
  margin: 0 auto;
  width: 50px;
  height: 25px;
}

.leaf {
  float: left;
  width: 0;
  height: 0;
  border-style: solid;
  margin-top: 0px;
  margin-bottom: -7px;
}
#leaf1 {
  border-width: 25px 0 0 25px;
  border-color: transparent transparent transparent green;
}

#leaf2 {
  border-width: 0 0 25px 25px;
  border-color: transparent transparent green transparent;
}

#options {
  background-color: #e60000;
  color: white;
  text-shadow: 1px 2px black;
  width: 60%;
  height: 150px;
  margin: auto;
  padding-top: 30px;
  border-radius: 80px;
  box-shadow: 2px 2px 5px;
  font-size: 18px;
  border: 1px outset black;
}

.option {
  width: 80%;
  padding: 5px;
  margin-left: auto;
  margin-right: auto;
}

fieldset {
  border: none;
}

.input {
  width: 5em;
  float: right;
  position: relative;
  top: 3px;
  font-family: 'Pridi', serif;
  font-size: 12px;
}

#continuous {
  float: right;
}

#buttons {
  text-align: center;
}

button {
  padding: 10px;
  margin: 10px;
  box-shadow: 2px 2px 5px;
  font-size: 20px;
  font-family: 'Pridi', serif;
  background-color: #e6e6e6;
  border-radius: 10px;
}

button:focus {
  outline: 0;
}

#timer {
  margin 10px;
  margin-left: auto;
  margin-right: auto;
  font-size: 5em;
  text-align: center;
  width: 70%;
}

#breakMessage {
  text-align: center;
  padding: 7px;
  font-size: 26px;
}
            
          
!
            
              var minutes = 25;
var seconds = minutes * 60;
var breakMins = 5;
var running = false;
var status = "work";
var timer;

$("#breakMessage").hide();
$("#timer").text(seconds);

var continuous = $("input[type='radio'][name='continuous']:checked").val();

function displayTime(seconds) {
    var mins = Math.floor(seconds / 60);
    var secs = seconds % 60;
    mins = mins >= 10 ? mins : "0" + mins;
    secs = secs >= 10 ? secs : "0" + secs;
    $("#timer").text(mins + ":" + secs);
}

displayTime(seconds);

$("#start").on("click", function() {
    
    if (running === false) {
        running = true;
        timer = window.setInterval(countDown, 1000);
    }
    
    function countDown() {
        seconds -= 1;
        displayTime(seconds);
        
        if (seconds === 0) {
            
            $("#sound")[0].play();
            
            if (continuous === "no") {
                running = false;
                window.clearInterval(timer);
            }
            
            if (status === "work") {
                status = "break";
                breakMins = $("#break").val();
                seconds = breakMins * 60;
                $("#breakMessage").show();
            } else {
                status = "work";
                minutes = $("#time").val();
                seconds = minutes * 60;
                $("#breakMessage").hide();
            }
        }
    }
     
});

$("#stop").on("click", function() {
    if (running === true) {
        running = false;
        window.clearInterval(timer);
    }
});

$("#reset").on("click", function() {
    running = false;
    window.clearInterval(timer);
    seconds = minutes * 60;
    displayTime(seconds);
});

$("#time").on("input", function() {
    minutes = $(this).val();
    seconds = minutes * 60;
    if (running === false) {
        displayTime(seconds);
    }
});

$(".radio").on("click", function() {
    continuous = $(this).val();
});
            
          
!
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.
Loading ..................

Console