cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <head>
  <title>Fast Pomodoro Timer</title>
  <link href='https://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'>
</head>
<div class="canvas">
<h1>Pomodoro Timer</h1>
  <div class="row">
    <div class="col-md-6">BREAK LENGTH</div>
    <div class="col-md-6">SESSION LENGTH</div>
  </div>
  <div class="row">
    <div  class="col-md-6" id="breakControls">
      <div class="col-md-4"></div>
      <div class="col-md-1"><button onclick="incrementBreak()">+</button></div>
      <div class="col-md-1 setting" id="break"></div>
      <div class="col-md-1"><button onclick="decrementBreak()">-</button></div>
    </div>
    <div  class="col-md-6" id="sessionControls">
      <div class="col-md-4"></div>
      <div class="col-md-1"><button onclick="incrementSession()">+</button></div>
      <div class="col-md-1 setting" id="session"></div>
      <div class="col-md-1"><button onclick="decrementSession()">-</button></div>
    </div>
  </div> 
  <div class="row">
    <div class="col-md-4"></div>
    <div class="btn col-md-4" id="circle" onclick="startSession()">
      <div id="whatItIs">Session</div>
      <div id="timer"></div>
    </div>
    <div class="col-md-4"></div>
  </div>
  <div class="row" style="background: blue;">
    <div class="col-md-1"></div>
    <div class="col-md-8"><span>
      <button class="btn" id="start" onclick="start()">Start / Resume</button>
      <button class="btn" id="pause" onclick="pause()">Pause</button>
      <button class="btn" id="reset" onclick="reset()">Reset</button></span>
    <div class="col-md-2"></div>
  </div>
</div>
</div>
            
          
!
            
              .canvas {
  background: #444444;
  font-family: 'Open Sans', sans-serif;
}

h1 {
  text-align: center;
  color: white;
}

.row {
  text-align: center;
  color: white;
  
}

.setting {
  font-size: 34px;
}

button {
  font-size: 34px;
  background: none;
  border: 0px;
  color: white;
  
  }

.footer {
  
}

#circle {
    background: #444444;
    width: 300px;
    height: 300px;
   border: 3px;
  border-color: #808000;
  border-style: solid;
    border-radius: 50%;
  margin: 0px 0px 50px 0px;
}

#whatItIs{
  position: absolute;
  top: 33%;
  left: 50%;
  transform:translate(-50%,-50%);
  color: #fff;
  font-size: 54px;
  font-family: 'Open Sans', sans-serif;
}

#timer {
  position: absolute;
  top: 67%;
  left: 50%;
  transform:translate(-50%,-50%);
  color: #fff;
  font-size: 64px;
}
            
          
!
            
              // global variables
var sessionText = "25";
var breakText = "5";
var breakLength = 5;
var sessionLength = 25;
var delay;
var secs = 0;
var mins = sessionLength;
var running=0;

window.onload = function() {
  document.getElementById('break').textContent = breakText;
  document.getElementById('session').textContent = sessionText;
  document.getElementById('whatItIs').textContent = "Session";
  if (secs < 10)
    secs = "0" +  secs;
  document.getElementById("timer").innerHTML = mins + ":" + secs;
};

// displays the countown time
function display(){
    if (secs < 10)
    secs = "0" +  secs;
  document.getElementById("timer").innerHTML = mins + ":" + secs;  
}

// starts (and resumes) the Session countdown
function start() {
  clearTimeout(delay);
  document.getElementById("start").disabled = true;
  document.getElementById("pause").disabled = false;
  document.getElementById("pause").enabled = true;
  document.getElementById("reset").enabled = true;  
  document.getElementById('whatItIs').textContent = "Session";
  if (secs==0 && mins==0) {
    mins = breakLength;
    secs = 1;
    startBreak();
  }
  if (secs==0 && mins>0){
    mins--;
    secs=59;
  }
  else
    secs--;  
 display();
  delay = setTimeout("start()", 125);
}

// starts the Break countdown
function startBreak() {
    clearTimeout(delay);
 // document.getElementById("start").disabled = true;
 // document.getElementById("pause").disabled = false;
 //   document.getElementById("pause").enabled = true;
 // document.getElementById("reset").enabled = true;  
  document.getElementById('whatItIs').textContent = "Break";
  if (secs==0 && mins==0) {
    mins = sessionLength;
    secs=1;
    start();
  }
  else if (secs==0 && mins>0){
    mins--;
    secs=59;
  }
  else 
      secs--;  
  display();
  delay = setTimeout("startBreak()", 125);
}

// pause the countdown
function pause(){
    clearTimeout(delay);
    document.getElementById("start").disabled = false;
    document.getElementById("start").enabled = true; 
    document.getElementById("pause").disabled = true;
}

// resets the countdown
function reset() {
  pause();
  mins = sessionLength;
  secs = 0;
  display();
}

// increments the break time
function incrementBreak() {
  breakLength += 1;
  breakText = breakLength.toString();
  document.getElementById('break').textContent = breakText;
}

// decrements the break time
function decrementBreak() {
  breakLength = Number(breakText);

  if (breakLength == 0)
    breakLength = 0;
  else {
    breakLength -= 1;
    breakText = breakLength.toString();
    document.getElementById('break').textContent = breakText;
  }
}

// increments the session time
function incrementSession() {
  sessionLength += 1;
  sessionText = sessionLength.toString();
  document.getElementById('session').textContent = sessionText;
}

// decrements the session time
function decrementSession() {
  sessionLength = Number(sessionText);
  if (sessionLength == 0){
    sessionLength = 0;  
  }
  else 
  {
    sessionLength -= 1;   
    sessionText = sessionLength.toString();
    document.getElementById('session').textContent = sessionText;
  }
}

            
          
!
999px
Loading ..................

Console