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

              
                <div class="row container-fluid">
  <h1>Pomodoro Clock</h1>
  
  <h4 id="message">Set your break and session length below and click "Start"!</h4>
  
  <a id="clock">25</a>

  <div class="row">
    <div class="col-md-6 breakLength">
      <h4>Break Length</h4>
      <a id="minusBreak">-</a>
      <span id="currentBreak">5</span>
      <a id="plusBreak">+</a>
    </div>
    <div class="col-md-6 sessionLength">
      <h4>Session Length</h4>
      <a id="minusSession">-</a>
      <span id="currentSession">25</span>
      <a id="plusSession">+</a>
    </div>
  </div>

  <div class="row clockControl">
    <a id="startNow">Start</a>
    <a id="pauseNow">Pause</a>
    <a id="resetAll">Reset All</a>
  </div>

</div>
              
            
!

CSS

              
                body {
  background-color:#EEEEEE;
}

h1 {
  text-align: center;
  font-weight: bold;
  margin-top: 30px;
  margin-bottom: 0;
  font-size: 55px;
}

#message {
  text-align: center;
  color: #008CBA;
}

h4 {
  margin: auto;
  font-weight: bold;
  text-align: center;
  padding: 5px;
}

#clock {
  border: 3px solid black;
  border-radius: 280px;
  font-size: 60px;
  color: black;
  width: 250px;
  height: 250px;
  padding-top: 80px;
  text-align: center;
  display: block;
  text-decoration: none !important;
  background-color: #99CC00;
  margin: auto;
  margin-top: 10px;
}

@media all and (max-width: 680px) and (min-width: 300px) {
  h1{
    font-size: 30px;
  }
  #message {
    font-size:14px;
  }
  #clock {
    width: 200px;
    height: 200px;
    font-size: 35px;
  } 
  #currentBreak {
    font-size: 13px;
  }
  #currentSession {
    font-size: 13px;
  }
}

.breakLength, .sessionLength, .clockControl{
    text-align: center;
}

.breakLength a, .sessionLength a {
  display: inline-block;
  margin: 10px 20px;
  border: 2px solid black;
  border-radius: 20px;
  width: 30px;
  text-decoration: none !important;
  font-size: 18px;
  background-color: #99CC00;
  color: black;
  text-align: center;
}

.breakLength a:hover,
.sessionLength a:hover {
  cursor: pointer;
}

.breakLength a:active.
.sessionLength a:active {
  background-color: #006301;
}

#currentBreak,
#currentSession {
  font-size: 22px;
}

.clockControl a {
  padding: 0px 15px;
  display: inline-block;
  margin: 0px 5px;
  font-size: 16px;
  background-color: white;
  color: black;
  border: 2px solid #008CBA;
  border-radius: 8px;
  -webkit-transition-duration: 0.4s;
  /* Safari */
  transition-duration: 0.4s;
  cursor: pointer;
  text-decoration: none;
}

#startNow:hover,
#pauseNow:hover,
#resetAll:hover {
  background-color: #008CBA;
  color: white;
}
              
            
!

JS

              
                $(document).ready(function() {
  var breakLength = 5;
  var sessionLength = 25;
  var timeInterval = 0;
  var timeBreakInterval = 0;
  var pause = false;
  var breakRunning = false;
  var totalSeconds = 0;
  var totalBreakSeconds = 0;
  var s = 0;
  var m = 0;
  var seconds = "";
  var minutes = "";
  var bs = 0;
  var bm = 0;
  var bseconds = "";
  var bminutes = "";

  $("#plusBreak").click(function() {
    breakLength += 1;
    $("#currentBreak").text(breakLength);
  });

  $("#minusBreak").click(function() {
    if (breakLength > 1) {
      breakLength -= 1;
    }
    $("#currentBreak").text(breakLength);
  });

  $("#plusSession").click(function() {
    sessionLength += 1;
    $("#currentSession").text(sessionLength);
    $("#clock").text(sessionLength);
  });

  $("#minusSession").click(function() {
    if (sessionLength > 1) {
      sessionLength -= 1;
    }
    $("#currentSession").text(sessionLength);
    $("#clock").text(sessionLength);
  });

  $("#resetAll").click(function() {
    breakLength = 5;
    sessionLength = 25;
    $("#currentBreak").text(breakLength);
    $("#currentSession").text(sessionLength);
    $("#clock").text(sessionLength);
    clearInterval(timeInterval);
    clearInterval(timeBreakInterval);
    clockRunning = false;
    breakRunning = false;
    pause = false;
    $("#message").text('Set your break and session length below and click "Start"!');
  });

  function checkTime(i) {
    if (i < 10) {
      i = "0" + i;
    }
    return i;
  }

  var initiateBreak = function() {
    breakRunning = true;
    if (totalBreakSeconds >= 0) {
      bs = totalBreakSeconds % 60;
      bm = Math.floor(totalBreakSeconds / 60);
      bminutes = checkTime(bm);
      bseconds = checkTime(bs);
      bs -= 1;
      $("#clock").html(bminutes + ":" + bseconds);
      totalBreakSeconds -= 1;
      timeBreakInterval = setTimeout(function() {
        initiateBreak()
      }, 100);
    } else if (totalBreakSeconds < 0) {
      $("#message").text('Your session is over. Reset the clock, set your break and session length below and click "Start"!');
    }
  }

  var initiateClock = function() {
    if (totalSeconds >= 0) {
      s = totalSeconds % 60;
      m = Math.floor(totalSeconds / 60);
      minutes = checkTime(m)
      seconds = checkTime(s);
      s -= 1;
      $("#clock").html(minutes + ":" + seconds);
      totalSeconds -= 1;
      timeInterval = setTimeout(function() {
        initiateClock()
      }, 100);
    } else if (totalSeconds < 0) {
      totalBreakSeconds = 60 * $("#currentBreak").text();
      initiateBreak();
      $("#message").text("Timeout! Let's take a " + breakLength + " minute(s) break!");
    }
  }

  $("#startNow").click(function() {
    if (pause === false) {
      if (breakRunning === false) {
        totalSeconds = 60 * $("#clock").text();
        $("#message").text("Let's focus and work for " + sessionLength + " minute(s)!");
        initiateClock();
      }
    } else {
      if (breakRunning === false) {
        totalSeconds = m * 60 + s;
        if (s < 0) {
          $("#message").text("Here we go again! " + m + " minute(s) and " + 0 + " second(s) to go!");
          initiateClock();
        } else {
          $("#message").text("Here we go again! " + m + " minute(s) and " + s + " second(s) to go!");
          initiateClock();
        }
        pause = false;
      } else {
        totalBreakSeconds = bm * 60 + bs;
        if (bs < 0) {
          $("#message").text("Your remaining break time is " + bm + " minute(s) and " + 0 + " second(s).");
          initiateBreak();
        } else {
          $("#message").text("Your remaining break time is " + bm + " minute(s) and " + bs + " second(s).");
          initiateBreak();
        }
        pause = false;
      }
    }
  });

  $("#pauseNow").click(function() {
    $("#message").text("Pause");
    pause = true;
    clearTimeout(timeInterval);
    clearTimeout(timeBreakInterval);
  });

}); //Closing tags for document ready function
              
            
!
999px

Console