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="container">
  <div class="break"><div class='title'>BREAK LENGTH</div>
<a href="#" id='breakDown'>-</a><div id="breakValue"> 5 </div><a href="#" id='breakUp'>+</a>
  </div>
  <div class="session"><div class='title'>SESSION LENGTH</div>
    <a href="#" id='sessionDown'>-</a><div id="sessionValue"> 25 </div><a href="#" id='sessionUp'>+</a>
  </div>
  <div class="clock">
    <div class="clockName">SESSION</div><div class="time">25:00
    </div>
  </div>
  <div class="reset">
    RESET  
  </div>
</div>
              
            
!

CSS

              
                * 
  margin: 0
  padding: 0
  font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif

a
  text-decoration: none
  color: black
  
html, body
  background: #333
  height: 100%
  
.container
  display: flex
  flex-flow: row wrap
  align-items: center
  width: 600px
  margin: 0 auto
  margin-top: 200px

.break
  flex: 1 50%
  background: lightgreen
  text-align: center
  
.session
  flex: 1 50%
  background: lightgreen
  text-align: center
  
.clock 
  flex: 1
  height: 300px
  padding-top: 100px
  background: #ff6156
  color: white
  text-align: center
  // line-height: 20px
  font-size: 48px
  transition: all 0.2s ease
  background-image: url('https://i.imgur.com/WEswQNE.png')
  background-size: 60%
  background-repeat: no-repeat
  background-position: center center
  
  .clockName
    padding-top: 60px
    
  .time
    padding-top: 20px
.reset
  background: peru
  flex: 1 100%
  color: white
  text-align: center
  font-size: 20px
  transition: all 0.2s ease
  
.title
  width: 100%
  display: block

#breakValue, #sessionValue
  display: inline-block
  width: 50px
  font-size: 32px
  transition: all 0.5s ease

a, span 
  font-size: 30px


.clock:active, #breakValue:active, #sessionValue:active, .reset:active
  opacity: 0.25
  
@media only screen and (max-device-width: 667px)  
  .container
    min-height: 100%
    flex-direction: column
    width: 100%
    margin: 0
    padding: 0
    
  .break, .session, .clock, .reset
    flex: 1
    width: 100%
  
  .clock
    background-size: 80%



    
              
            
!

JS

              
                function createTimer() {
  var counter = 1500;
  var startingValue = 1500;
  
  function increment() {
    if (counter == 0) {
      reset();
      return
    }
    counter -= 1;
    timerDiv.innerHTML = parseSeconds(counter);
  }
  
  function parseSeconds(time) {
    minutes = "0" + Math.floor(time / 60);
    seconds = "0" + (time - minutes * 60);
    return minutes.substr(-2) + ":" + seconds.substr(-2);
  }
  
  function reset() {
    counter = startingValue;
  }
  
  function setTimer(value) {
    counter = value * 60;
    startingValue = value * 60;
  }
  
  function print() {
    return [ counter, parseSeconds(counter) ];
  }
  
  return {
          increment: increment,
          reset: reset,
          setTimer: setTimer,
          print: print,
          }
}

// DOM Elements
var clock = document.querySelector('.clock');
var clockName = document.querySelector('.clockName');
var timerDiv = document.querySelector('.time');
var breakDown = document.querySelector('#breakDown');
var breakUp = document.querySelector('#breakUp');
var breakValue = document.querySelector('#breakValue');
var sessionDown = document.querySelector('#sessionDown');
var sessionUp = document.querySelector('#sessionUp');
var sessionValue = document.querySelector('#sessionValue');
var resetButton = document.querySelector('.reset');


// Countdown Timers
var sessionTimer = createTimer();
var breakTimer = createTimer();

// Active Timer Pointer
var activeTimer = { value: sessionTimer };

// Set countdown default values
sessionTimer.setTimer(25);
breakTimer.setTimer(5);

// Master Clock 
masterClockPause = true;
clock.onclick = function() {
    if (masterClockPause === false) {
      window.clearInterval(masterClock)
    } 
    if (masterClockPause === true) {
      masterClock = window.setInterval(bang, 1000);
    }
    masterClockPause = !masterClockPause;
}

// Decide which countdown timer to increment and increment it
function bang() {
  if (activeTimer.value === sessionTimer & activeTimer.value.print()[0] === 0) {
    activeTimer.value.reset();
    activeTimer.value = breakTimer;
    clockName.innerHTML = 'BREAK!';
    
  } 
  if (activeTimer.value === breakTimer & activeTimer.value.print()[0] === 0) {
    activeTimer.value.reset();
    activeTimer.value = sessionTimer;
    clockName.innerHTML = 'SESSION';
  }
  // Increment active timer
  activeTimer.value.increment();
}

breakDown.onclick = function() {
  breakValue.innerHTML = parseInt(breakValue.innerHTML) - 1
  breakTimer.setTimer(breakValue.innerHTML);
  if (activeTimer.value === breakTimer) {
    timerDiv.innerHTML = breakTimer.print()[1];
  }
}

// Timer Controls
breakUp.onclick = function() {
  breakValue.innerHTML = parseInt(breakValue.innerHTML) + 1
  breakTimer.setTimer(breakValue.innerHTML);
  if (activeTimer.value === breakTimer) {
    timerDiv.innerHTML = breakTimer.print()[1];
  }
}

sessionDown.onclick = function() {
  sessionValue.innerHTML = parseInt(sessionValue.innerHTML) - 1
  sessionTimer.setTimer(sessionValue.innerHTML);
  if (activeTimer.value === sessionTimer) {
    timerDiv.innerHTML = sessionTimer.print()[1];
  }  
}

sessionUp.onclick = function() {
  sessionValue.innerHTML = parseInt(sessionValue.innerHTML) + 1
  sessionTimer.setTimer(sessionValue.innerHTML);sessionTimer.print()[1]
  if (activeTimer.value === sessionTimer) {
    timerDiv.innerHTML = sessionTimer.print()[1];
  }  
}

// Reset Button
resetButton.onclick = function() {  
  if (masterClockPause === false) {
    window.clearInterval(masterClock)
  }   
  activeTimer.value = sessionTimer;
  sessionTimer.reset();
  breakTimer.reset();
  timerDiv.innerHTML = sessionTimer.print()[1];
  masterClockPause = true;
}

              
            
!
999px

Console