css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <audio id="audio" src="http://www.jacobting.net/media/sonar.wav" preload="auto">

</audio>

<div class="container">

  <div class="col-md-12 timers">

    <div class="spacer"></div>
    <!-- Increase/decrease work time buttons. -->
    <div class="col-md-12 col-xs-12  infinityTime infinity-btn">

      <button class="btn col-xs-4" id="downInfinity">-</button>
      <p class="col-xs-4" id="infinity">25</p>
      <button class="btn col-xs-4" id="upInfinity">+</button>

    </div>

    <!-- Main timer. -->
    <div class="col-md-12 col-xs-12 infinity">
      <div class="mainTime">
        <p class="state">It only seems like forever!</p>
        <p class="quote">Touch to Start</p>
        <p class="time"></p>
      </div>
    </div>
    <!-- Increase/decrease break session buttons. -->
    <div class="col-md-12 col-xs-12 breakTime infinity-btn">
      <button class="btn col-xs-4" id="downFun">-</button>
      <p class="col-xs-4" id="fun">5</p>
      <button class="btn col-xs-4" id="upFun">+</button>
    </div>

  </div>

</div>

<!-- Description/directions. -->
<div class="col-md-12 details">
  <span class="glyphicon glyphicon-info-sign" title="The Pomodoro Technique provides a framework for committing to specific work and break periods to reduce distractions and improve time management.

The traditional Pomodoro method uses standardized 25-minute work periods accompanied by 5- and 15-minute breaks. Our Marinara variation allows you to customize the length of these periods to suit your individual needs."></span>
</div>

<!-- Footer. -->
<div class="navbar navbar-inverse navbar-fixed-bottom" role="navigation">
  <div class="container">
    <div class="navbar-text pull-left">
      Created by Jacob C. Ting using <a href="https://codepen.io" target="_blank">CodePen.io</a> for <a href="https://www.freecodecamp.com" target="_blank">freeCodeCamp.com</a> check out my other work <a href="http://www.roflcopterdown.com" target="_blank">here</a>.
    </div>
  </div>

  <div class="navbar navbar-inverse navbar-fixed-bottom" role="navigation">
    <div class="navbar-text pull-left">
      Created by Jacob C. Ting using <a href="https://codepen.io" target="_blank">CodePen.io</a> check out my other work <a href="http://www.jacobting.net" target="_blank">here</a>.
    </div>
  </div>

</div>
            
          
!
            
              html,
body {
  color: #D1D0CE;
  background-color: #101010;
  text-align: center;
  margin: 0 auto;
  font-family: 'Roboto Condensed', Georgia, sans-serif
}

.btn {
  border-radius: 0px
}

.details {
  margin-top: 0px
}

a {
  color: #D1D0CE
}

.state {
  text-align: center
}

.state {
  display: none
}

p {
  font-size: 30px
}

h1 {
  font-size: 50px
}

h3 {
  font-size: 45px
}



.btn {
  color: #101010;
  background: #D1D0CE;
  font-size: 24px
}

.btn:hover {
  color: #D1D0CE;
  background-color: #101000;
}

.col-md-4 {
  margin-top: 10px;
  margin-bottom: 5px;
}

.infinity {
  cursor: pointer;
  color: #101010;
  background: #D1D0CE;
  padding: 1%;
  margin: 1%;
  box-shadow: 0px 0px 0px 2px #101010
}

.infinity-btn {
  cursor: pointer;
  color: #101010;
  background: #D1D0CE;
  padding: 1%;
  margin: 1%;
  box-shadow: 0px 0px 0px 2px #101010
}

.mainTime {
  margin: 1%
}

.mainTime:hover {
  color: #D1D0CE;
  background-color: #101000;
}

.spacer {
  margin-top: 15%
}

            
          
!
            
              /***
Application: Infinity Work Clock - Pomodoro Technique Timer
Author: Jacob C. Ting
Use: The application contains a counting timer that rotates between two states. One state is meant for timing a work session. The other state is meant for timing a break.

Clicking the large middle timer starts and pauses the timer.

The left buttons/number represent the time for breaks, the buttons can increase/decrease this time.

The right buttons/number represent the time for breaks, the buttons can increase/decrease this time.
***/

// Quotes
var quotes = [];
quotes.push('ለጥቂት ጊዜ አረፈ');
quotes.push('пауза');
quotes.push('pause');
quotes.push('وقفة');
quotes.push('暫停');
quotes.push('一時停止する');

$(document).ready(function() {
  // Variables for the buttons that increase and decrease timers.
  var infinityTime = 25;
  var funTime = 5;
  
  // Variables for the main timer.
  var minutes = 25;
  var seconds = 0;
  
  // Variable controlling whether the clock is running or not.
  var stopped = true;
  
  // Variable holding our function that counts the timer down.
  var ticking;

  // Set the display time of the main timer.
  $('.time').html(minutes + ":0" + seconds);

  // This function controls the state of the timer (either 'break' or 'work'),
  // displays the random quote from the Quotes section, and play audio when timer is over.
  function count() {

    // Play sound as timer finishes.
    if (minutes === 0 && seconds === 1) {
      document.getElementById('audio').play();
    }

    // When the timer finishes, if the state is the 'work' state, change it to the break state.
    // Set the timer for the break timer, display a random quote, and update the timer display.
    if (minutes === 0 && seconds === 0) {
      if ($('.state').html() === 'It only seems like forever!') {
        $('.state').html('The fun never ends!');
        $('.quote').text(quotes[Math.floor(Math.random() * quotes.length)]);
        minutes = funTime;
        $('.time').html(minutes + ":0" + seconds);
      // Same as above, but change the state if it is in the 'break' state.
      } else if (minutes === 0 && seconds === 0) {
        ($('.state').html() === 'The fun never ends!')
        $('.state').html('It only seems like forever!');
        $('.quote').text(quotes[Math.floor(Math.random() * quotes.length)]);
        minutes = infinityTime;
        $('.time').html(minutes + ":0" + seconds);
      }
    } else {                                          // Controls the accurate display of the clock.
      if (seconds === 0) {                            // When seconds is equal to 0
        seconds = 60;                                 // reset them to 60,
        minutes--                                     // and reduce minutes by 1.
      }
      seconds--;                                      // Otherwise just reduce the seconds by 1.
      if (seconds < 10) {                             // When there are not double digit seconds,
        $('.time').html(minutes + ":0" + seconds);    // Only display one 0.
      } else {
        $('.time').html(minutes + ":" + seconds);     // Otherwise just display the second variable.
      }
    }
  }

  // Events for controling the buttons that reduce the work and break times.
  // They all essentially function the same. Possibly reduce repetition in future.
  
  // Reduce break time.
  $('#downFun').click(function() {                           // When button is clicked
    if (stopped === true) {                                 // if the timer has been stopped,
      if (funTime > 1) {                                     // and the timer isn't already at the minimum
        funTime--;                                           // decrease its amount by 1.
        $("#fun").html(funTime);                             // Update the break time display.
        $('.state').text('It only seems like forever!');     // Reset to the 'work' state.
        $(".time").html(infinityTime + ":00");               // Update the display timer.
        seconds = 0;                                         // Reset the second to 0, and
        minutes = infinityTime;                              // reset the minutes to the appropriate value.
      }
    }
  });
  
  // Increase break time.
  $('#upFun').click(function() {
    if (stopped === true) {
      funTime++;
      $("#fun").html(funTime);
      $('.state').text('It only seems like forever!');
      $(".time").html(infinityTime + ":00");
      seconds = 0;
      minutes = infinityTime;
    }
  });
  
  // Reduce work time.
  $('#downInfinity').click(function() {
    if (stopped === true) {
      if (infinityTime > 1) {
        infinityTime--;
        $("#infinity").html(infinityTime);
        $(".time").html(infinityTime + ":00");
        $('.state').text('It only seems like forever!');
      }
      seconds = 0;
      minutes = infinityTime;
    }
  });
  
  // Increase work time.
  $('#upInfinity').click(function() {
    if (stopped === true) {
      infinityTime++;
      $("#infinity").html(infinityTime);
      $(".time").html(infinityTime + ":00");
      $('.state').text('It only seems like forever!');
      seconds = 0;
      minutes = infinityTime;
    }
  });
  
  // Event that starts the timer when it is clicked.
  // Sets the states of the 'stopped' variable.
  $('.infinity').click(function() {
    if (stopped === true) {
      ticking = setInterval(count, 1000);
      stopped = false;
    } else if (stopped === false) {
      clearInterval(ticking);
      stopped = true;
    }
  });

});
            
          
!
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