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

              
                <div id="content">
  <div id="pomodoroClock">
    <div id="heading"></div>
    <div id="timerLengths">
      <div id="break">
        <div id="breakTitle">
          <div class="title">BREAK LENGTH</div>
        </div>
        <div class="settings" id="breakSettings">
          <div class="settingControl" id="breakMinus">-</div>
          <div class="settingLength" id="breakLength"></div>
          <div class="settingControl" id="breakPlus">+</div>
        </div>
      </div>
      <div id="session">
        <div id="sessionTitle">
          <div class="title">SESSION LENGTH</div>
        </div>
        <div class="settings" id="sessionSettings">
          <div class="settingControl" id="sessionMinus">-</div>
          <div class="settingLength" id="sessionLength"></div>
          <div class="settingControl" id="sessionPlus">+</div>
        </div>
      </div>
    </div>
    <div id="clock">
      <div id="breakOrSession">

      </div>
      <div id="countdown">
        " "
      </div>
      <div id="progressCircle">

      </div>
    </div>
    <div id="signature">
      Designed & Coded by
      <a href="https://www.linkedin.com/in/homer-allen-iii-95361610" target="_blank">Homer Allen, III</a>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  background-color: #0E0E0E;
  color: #76C2C9;
  font-family: 'Oswald', sans-serif;
}

#content {
  -webkit-user-select: none;
  /* Chrome/Safari */
  -moz-user-select: none;
  /* Firefox */
  -ms-user-select: none;
  /* IE10+ */
  user-select: none;
}

#pomodoroClock {
  margin-top: 125px;
}

#heading,
#timerLengths,
#clock,
#signature {
  margin: auto;
  width: 500px;
  text-align: center;
}

#timerLengths>div {
  display: inline-block;
  margin: 25px;
}

.settings>div {
  display: inline-block;
  margin: auto;
}

#progressCircle {
  height: 150px;
  width: 150px;
  margin: 10px auto;
}

.settingControl {
  width: 25px;
  margin: 0px 15px;
  font-size: 30px;
  font-family: 'Nunito Sans', sans-serif;
  cursor: pointer;
  cursor: hand;
  text-align: center;
}

.settingLength {
  width: 25px;
  font-size: 20px;
}

#signature {
  font-size: 12px;
  margin-top: 20px;
}

#signature a {
  text-decoration: none;
}
              
            
!

JS

              
                $(document).ready(function() {
  var breakLength = 5;
  var sessionLength = 25;
  var sessionMin = 1;
  var sessionMax = 1000;
  var breakMin = 1;
  var breakMax = 1000;
  var breakOrSession = "Session";

  var pomodoroCountdown = new Timer({
    tick: 1,
    ontick: function() {
      updateCountdown();
      updateProgressCircle()
    },
    onend: function() {
      playSound();
      switchMode();
      updateCountdown();
      startClock();
    }
  });

  var circle = new ProgressBar.Circle(progressCircle, {
    strokeWidth: 6,
    easing: 'easeInOut',
    duration: 2000,
    color: '#EC0000',
    trailColor: '#aaa',
    trailWidth: 6,
    svgStyle: null
  });

  $("#breakMinus").click(function() {
    if (breakLength - 1 >= breakMin && (pomodoroCountdown.getStatus() !== "started" || breakOrSession !== "Break")) {
      breakLength--;
      $("#breakLength").text(breakLength);
      updateCountdown();
    }
  });

  $("#breakPlus").click(function() {
    if (breakLength + 1 <= breakMax && (pomodoroCountdown.getStatus() !== "started" || breakOrSession !== "Break")) {
      breakLength++;
      $("#breakLength").text(breakLength);
      updateCountdown();
    }
  });

  $("#sessionMinus").click(function() {
    if (sessionLength - 1 >= sessionMin && (pomodoroCountdown.getStatus() !== "started" || breakOrSession !== "Session")) {
      sessionLength--;
      $("#sessionLength").text(sessionLength);
      updateCountdown();
    }
  });

  $("#sessionPlus").click(function() {
    if (sessionLength + 1 <= sessionMax && (pomodoroCountdown.getStatus() !== "started" || breakOrSession !== "Session")) {
      sessionLength++;
      $("#sessionLength").text(sessionLength);
      updateCountdown();
    }
  });

  $("#clock").click(function() {
    if (pomodoroCountdown.getStatus() === "started") {
      pomodoroCountdown.pause();
    } else {
      startClock();
    }
  });

  function startClock() {
    if (breakOrSession === "Session") {
      pomodoroCountdown.start(toSeconds(sessionLength));
    } else if (breakOrSession === "Break") {
      pomodoroCountdown.start(toSeconds(breakLength));
    }
  }

  function toSeconds(minutes) {
    return minutes * 60;
  }

  function toMilliseconds(minutes) {
    return minutes * 60 * 1000;
  }

  function toMinutes(milliseconds) {
    return ((milliseconds / 1000) / 60);
  }

  function toHMSText(milliseconds) {
    var totalInHours = ((milliseconds / 1000) / 60) / 60;
    var hours = Math.floor(totalInHours);
    totalInHours -= hours;
    var minutes = Math.floor(totalInHours * 60);
    totalInHours -= minutes / 60;
    var seconds = Math.floor(totalInHours * 60 * 60);

    return pad(hours) + ":" + pad(minutes) + ":" + pad(seconds);

    function pad(d) {
      return (d < 10) ? '0' + d.toString() : d.toString();
    }

  }

  function updateCountdown() {
    if (pomodoroCountdown.getStatus() === "started") {
      $("#countdown").text(toHMSText(pomodoroCountdown.getDuration()));
    } else if (breakOrSession === "Session") {
      $("#countdown").text(toHMSText(toMilliseconds(sessionLength)));
    } else if (breakOrSession === "Break") {
      $("#countdown").text(toHMSText(toMilliseconds(breakLength)));
    }
  }

  function updateProgressCircle() {
    var percentComplete;

    if (breakOrSession === "Session") {
      percentComplete = toMinutes(pomodoroCountdown.getDuration()) / sessionLength;
    } else if (breakOrSession === "Break") {
      percentComplete = toMinutes(pomodoroCountdown.getDuration()) / breakLength;
    }

    circle.set(1 - percentComplete);
  }

  function switchMode() {
    if (breakOrSession === "Session") {
      breakOrSession = "Break";
    } else if (breakOrSession === "Break") {
      breakOrSession = "Session";
    }

    $("#breakOrSession").text(breakOrSession);
  }

  function playSound() {
    var audio = new Audio('http://www.homerallen.com/sounds/pomodoro-ding.wav');
    audio.play();
  }

  $("#breakLength").text(breakLength);
  $("#sessionLength").text(sessionLength);
  $("#breakOrSession").text(breakOrSession);
  updateCountdown();

});
              
            
!
999px

Console