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.

            
              <!DOCTYPE html>
<html lang="en">
  <head>
    <title>Pomodoro Clock - Study Harder</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href='https://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Montserrat+Alternates' rel='stylesheet' type='text/css'>
  </head>
  <body>
    <div class="container-fluid">
		<section id="appWindow" class="row">
			<div id="app" class="col-sm-6 col-lg-4 centerMe">
				<div class="row">
					<div class="col-sm-12">
						<h1 id="pomTitle" class="title">Pomodoro</h1>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="row">
							<div class="col-xs-12">
								<h3>Break</h3>
							</div>
							<div class="col-xs-3">
								<h3 id="breakDec" class="btn">-</h3>
							</div>
							<div class="col-xs-6">
								<h2 id="breakSet">00</h2>
							</div>
							<div class="col-xs-3">
								<h3 id="breakInc" class="btn">+</h3>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="row">
							<div class="col-xs-12">
								<h3>Study</h3>
							</div>
							<div class="col-xs-3">
								<h3 id="studyDec" class="btn">-</h3>
							</div>
							<div class="col-xs-6">
								<h2 id="studySet">00</h2>
							</div>
							<div class="col-xs-3">
								<h3 id="studyInc" class="btn">+</h3>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
							<div class="col-xs-8 centerMe">
                <h1 id="pomMin" class="minutes">--</h1>
                <h3 id="pomSec" class="seconds">--</h3>
							</div>
              <div class="col-xs-12">
                <div class="row">
                  <div class="col-xs-6">
                    <h3 id="pomStart" class="btn btn-success strtStp">Start</h3>
                  </div>
                  <div class="col-xs-6">
                    <h3 id="pomStop" class="btn btn-danger strtStp">Stop</h3>
                  </div>
                </div>
              </div>
				</div>
			</div>
		</section>
    </div>
  </body>
</html>
            
          
!
            
              body{
font-family: 'Montserrat Alternates', sans-serif;
}
h3.btn{
padding: 0px;
font-size: 2.5em;
}
h3.btn.strtStp{
padding: .25em 1em;
}
h2{
font-size: 3em;
}
h1.title{
font-family: 'Pacifico', cursive;
font-size: 4.25em;
}
h1.minutes{
font-size: 6em;
}
h3.seconds{
  font-size: 2.5em;
}
#appWindow{
text-align: center;
}
#app{
background-color: #AD5CC1;
padding-bottom: 12px;
border-radius: 6px;
}
#counter{
background: #F4C6FF;
}
.centerMe{
display: inline-block;
float: none;
}
.redAlert{
  color: red;
}

            
          
!
            
              // ######  pomodoro clock v0.5  ######
// ## written by: rob j loranger    ##
// ## november 2015                 ##
// ## project for freecodecamp      ##
// ###################################
// ## *requires jquery*             ##
// ###################################


// initialize base globals
var rest = 4, focus = 25, clock, clockSw = 'study', uiSw = true;

// initialize full circle
// can't figure out circles yet

// set up jquery event listeners etc.
$(document).ready(function(){
  // initialize some numbers
  console.log("Setting default break/study times.");
  $("#breakSet").html(rest);
  $("#studySet").html(focus);
  
  // handle click events
  // for timers
  // break time increase
  $("#breakInc").click(function(){
    // do no increase past our limit of 
    if (rest < 5 && uiSw){
      console.log("Increase break length.");
      rest += 1;
      $("#breakSet").html(rest);
    }
  });
  // break time decrease
  $("#breakDec").click(function(){
    // do no decrease below our limit of 3
    if (rest > 3 && uiSw){
      console.log("Decrease break length.");
      rest -= 1;
      $("#breakSet").html(rest);
    }
  });
  // study time increase
  $("#studyInc").click(function(){
    // do not increase past our limit of 30
    if (focus < 30 && uiSw){
      console.log("Increase study length.");
      focus += 1;
      $("#studySet").html(focus);
    }
  });
  // study time decrease
  $("#studyDec").click(function(){
    // do not decrease below our limit of 15
    if (focus > 15 && uiSw){
      console.log("Decrease study length.");
      focus -= 1;
      $("#studySet").html(focus);
    }
  });
  // start and stop/reset click
  // event handlers
  $("#pomStart").click(function(){
    pomtroller('run');
  });
  $("#pomStop").click(function(){
    pomtroller('stop');
  });
});
// function to display time and
// update circular representation
function drawClock(min,sec){
  $("#pomMin").html(min);
  $("#pomSec").html(sec);
}
// the time function itself
function startTimer(time){
  // get current time in seconds
  // set it to our starting point
  var start = Math.floor(new Date().getTime() / 1000);
  // start elapsed time at 0
  var elapsed = 0;
  // set stop point to our time
  // interval in seconds
  var stop = time * 60;
  console.log("Timer started..");
  // call up the clock loop at an interval
  // of 100ms
  clock = setInterval(function(){
    // get current time in seconds
    var current = Math.floor(new Date().getTime() / 1000);
    // calculate time since start
    elapsed = current - start;
    // set minutes and seconds variables
    var rMin = Math.floor((stop - elapsed) / 60);
    var rSec = Math.floor((stop - elapsed) - (rMin * 60));
    // ask drawClock to update the display
    drawClock(rMin,rSec);
    // check if time is up
    // if so run the alert function and
    // tell the controller to continue
    if(rMin === 0 && rSec === 0){
      console.log("Time is up!");
      pomtroller('continue');
    }
  }, 100);
}
// the main controller function
// directs the flow, start/stop etc
function pomtroller(state){
  // switch case for our program state
  switch(state){
    case 'run':
      // default start with the study time
      clockSw = 'study';
      // disable +/- controls
      uiSw = false;
      // no one wants multiple timers
      // running, clear any running timer
      clearInterval(clock);
      $("#pomTitle").html("Study, study hard!");
      // start new timer
      startTimer(focus);
      break;
    case 'continue':
      console.log("Pomtroller continues..");
      // check which state we are in
      // then switch the flag, clear the current
      // timer instance and call it again 
      // for the next timed period
      if(clockSw === 'study'){
        console.log("Going from study to break..");
        clockSw = 'break';
        clearInterval(clock);
        $("#pomTitle").html("Take a load off");
        startTimer(rest);
      }else if(clockSw === 'break'){
        console.log("Going from break to study..");
        clockSw = 'study';
        clearInterval(clock);
        $("#pomTitle").html("Study, study hard!");
        startTimer(focus);
      }
      break;
    case 'stop':
      // stop timer instance
      // and reset numebrs to null --
      console.log("Timer stopped..");
      clearInterval(clock);
      drawClock('--','--');
      $("#pomTitle").html("Pomodoro");
      uiSw = true;
      break;
    default:
      console.log("Timer stopped..(Default action, possible error.)");
      clearInterval(clock);
      uiSw = 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