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

              
                <html>
  <head>
    <meta charset="utf-8">
    <title>Pomodoro Clock</title>
    <link href="styles.css" rel="stylesheet">
  </head>
  <body>

      <h1>Pomodoro Clock</h1>

      <div id="container">
        <div id="break">
          <span>Break Length</span>
          <br>
          <div class="timerContents">
            <span id="subtractBreakMinute">-</span>
            <span id="breakDisplay">5</span>
            <span id="addBreakMinute">+</span>
          </div>
        </div>

        <div id="session">
          <span>Session Length</span>
          <br>
          <div class="timerContents">
            <span id="subtractSessionMinute">-</span>
            <span id="sessionDisplay">25</span>
            <span id="addSessionMinute">+</span>
          </div>
        </div>
      </div>

      <div id="circle">
        <span>
          <h3>Time Remaining :</h3>
        </span>
        <span id="clock">
          <div class="minutes"></div>
          <div class="seconds"></div>
        </span>
      </div>

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


    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="app.js"></script>
  </body>
</html>

              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Orbitron");
body {
  background: #333333;
  color: ghostwhite; }

h1 {
  font-family: 'Orbitron', sans-serif;
  color: #83D0F2;
  text-align: center;
  margin-top: 0;
  margin-bottom: 1em;
  font-size: 3em;
  font-weight: lighter; }

#container {
  width: 100%;
  text-align: center; }

span {
  text-transform: uppercase; }

#circle {
  height: 20em;
  width: 25%;
  margin-left: auto;
  margin-right: auto;
  margin-top: 2em;
  border-radius: 50%;
  background: #333333;
  border: 1px solid #83D0F2;
  text-align: center;
  position: relative; }
  #circle h3 {
    margin-top: 80px;
    margin-left: 52px;
    position: absolute; }
  #circle #clock {
    position: absolute;
    margin-top: 140px;
    margin-left: -70px;
    font-size: 3em; }

#break {
  height: 5em;
  width: 10em;
  display: inline-block; }

#session {
  height: 5em;
  width: 10em;
  display: inline-block; }

.timerContents {
  font-size: 2em;
  padding-top: .3em; }
  .timerContents span {
    margin-right: .2em; }

#buttons {
  width: 40%;
  text-align: center;
  margin-left: auto;
  margin-right: auto;
  margin-top: 1em;
  margin-bottom: 1em;
  padding: 1em; }
  #buttons :nth-child(1), #buttons :nth-child(2), #buttons :nth-child(3) {
    font-size: 1em;
    margin-right: 1.2em;
    margin-left: 1.2em;
    border: 2px solid #83D0F2;
    background-color: #333333;
    color: ghostwhite;
    width: 5em;
    height: 2em;
    text-transform: uppercase; }
  #buttons :hover {
    background-color: ghostwhite;
    color: #333333; }

/*# sourceMappingURL=styles.css.map */

              
            
!

JS

              
                var timerInt;
var minutes;
var seconds;

var pomodoro = {
  wTime: 1.00,
  bTime: 1.00,
  cElem: $('#clock'),
  cWork: true,
  cTicking: false,
  wElem: $('#sessionDisplay'),
  bElem: $('#breakDisplay'),
};

var working = true;
var totalSecondsWork = pomodoro.wTime * 60;
var totalSecondsBreak = pomodoro.bTime * 60;

$(document).ready(function(){

  clockInit();

  function clockInit(){
    // Displays initial time on clock and break/session buttons
    pomodoro.wElem.text(pomodoro.wTime);
    pomodoro.bElem.text(pomodoro.bTime);
	  pomodoro.cElem.text(pomodoro.wTime + ':00');

    $('#start').on('click', function(){
      startClock();
    })
  }


  function tick() {
    if(working) {
      totalSecondsWork--;
      // Converts total seconds of work left to minutes/seconds
      minutes = Math.floor(totalSecondsWork % 3600 / 60);
      seconds = totalSecondsWork % 60;
      // Adds a 0 in front of single digit minutes/seconds
      minutes = ('0' + minutes).slice(-2);
      seconds = ('0' + seconds).slice(-2);
      // Displays minutes/seconds of work left
      pomodoro.cElem.text(minutes + ':' + seconds).css( { color: 'green' } );
    }
    else {
      totalSecondsBreak--;
      // Converts total seconds of break left to minutes/seconds
      minutes = Math.floor(totalSecondsBreak % 3600 / 60);
      seconds = totalSecondsBreak % 60;
      // Adds a 0 in front of single digit minutes/seconds
      minutes = ('0' + minutes).slice(-2);
      seconds = ('0' + seconds).slice(-2);
      // Displays minutes/seconds of break left
      pomodoro.cElem.text(minutes + ':' + seconds).css( { color: 'red' } );
      if(pomodoro.cElem.text() == '00:00'){
        done();
        stopClock();
      }
    }

    if(pomodoro.cElem.text() == '00:00'){
      bell();
      changeStatus();
    }
  }

  function done(){
    bell();
    pomodoro.cElem.text('DONE').css( { color: 'white' } );
  }


  function startClock(){
    timerInt = window.setInterval(tick, 1000);
  }

  function stopClock(){
    window.clearInterval(timerInt);
  }

  function changeStatus() {
  	stopClock();
  	working = !working;
  	if(working) {
  		pomodoro.cElem.text('0' + pomodoro.wTime + ':00').slice(-2);
  	}
    else {
  		pomodoro.cElem.text('0' + pomodoro.bTime + ':00').slice(-2).css( { color: 'red' } );
  	}
  	startClock();
  }

  function bell(){
    var audio = new Audio();
    audio.src = "bell.mp3";
    audio.play();
  }



   // Add/subtract time to break
  $('#subtractBreakMinute').click(function(){
    if(pomodoro.bTime > 0) {
        pomodoro.bTime -= 1;
        $('#breakDisplay').text(pomodoro.bTime);
        totalSecondsBreak -= 60;
        clockInit();
    }
  })

  $('#addBreakMinute').click(function(){
    if(pomodoro.bTime < 60) {
        pomodoro.bTime += 1;
        $('#breakDisplay').text(pomodoro.bTime);
        totalSecondsBreak += 60;
        clockInit();
    }
  })

  $('#subtractSessionMinute').click(function(){
    if(pomodoro.wTime > 0){
      pomodoro.wTime -= 1;
      $('#sessionDisplay').text(pomodoro.wTime);
      totalSecondsWork -= 60;
       clockInit();
    }
  })

  $('#addSessionMinute').click(function(){
    if(pomodoro.wTime < 60){
      pomodoro.wTime += 1;
      $('#sessionDisplay').text(pomodoro.wTime);
      //Changes clock to new amount but also decrements by that amount per second instead of 1 seconds per second
      totalSecondsWork += 60;
      clockInit();
    }
  })

  $('#stop').click(function(){
    stopClock();
    if(working) {
      pomodoro.cElem.text(minutes + ':' + seconds);
      stopClock();
    }
    else {
      pomodoro.cElem.text(minutes + ':' + seconds);
      stopClock();
    }
  })

  $('#reset').click(function(){
    stopClock();
    pomodoro.cElem.text(pomodoro.wTime);
  })



});

              
            
!
999px

Console