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 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.

Quick-add: + add another resource

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.

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.

            
              <div class="calculator-container div-center">

      <div class="header section">Pomodoro Clock</div>

      <div class="settings section">
          <div class="break">
            <span class="title">BREAK LENGTH</span>
            <br/>
            <button value="minus" class="button break-time">-</button>
            <span class="break-time">5</span>
            <button value="plus" class="button break-time">+</button>
          </div>
          <div class="session">
            <span class="title">SESSION LENGTH</span>
            <br/>
            <button value="minus" class="button session-time">-</button>
            <span class="session-time">25</span>
            <button value="plus" class="button session-time">+</button>
          </div>
      </div>

      <div class="main-display">
        <div class="pause">
            <button value="pause" class="button pause">&#x2016;</button>
            <span>PAUSE</span>
        </div>
        <div class="display section">
            <br/>
            <br/>
            <span class="title display-text">Session</span>
            <br/>
            <br/>
            <br/>
            <br/>
            <span class="title display-remaining-time">25</span>
        </div>
        <div class="reset">
            <button value="reset" class="button reset">&ndash;</button>
            <span>RESET</span>
        </div>
      </div>

      <div class="footer section">
        <span>Created by <a href="http://balach.de" target="_blank">Balach</a></span>
      </div>
    </div>
            
          
!
            
              body {
  background-color: rgba(245, 245, 245, 0.75);
  font-family: 'Raleway', sans-serif;
  color: rgb(52, 52, 52);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.header {
  font-family: 'Lobster', cursive;
  font-size: 400%;
  text-shadow: rgba(115, 111, 111, 0.55) 0px 0px 4px;
}

.settings {
  height: 3rem;
  margin-top: 2rem;
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: flex-end;
}

.main-display {
  margin-top: 2rem;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-end;
}

.display-text {
  font-size: 200%;
}

.display-remaining-time {
  font-size: 400%;
}

button {
  cursor: pointer;
  color: rgba(10,10,10, 0.7);
  font-size: large;
  width: 2rem;
  height: 2rem;
  background-color: rgba(0,0,0,0);
  border: none;
}
button:active {
  color: rgba(10,10,10,1);
  font-weight:bolder;
}
button:focus {
  outline: none;
}
button:disabled {
  opacity: 0.55; 
  cursor: not-allowed;
}
button.reset, button.pause {
  font-weight: bolder;
  color: red;
  border: 3px inset orange;
  border-radius: 50%;
}

button.break-time, button.session-time {
  margin: 1px;
  border-bottom: 2px solid grey;
  border-radius: 40%;
}

.display {
  cursor: pointer;
  transition: all 0.3s;
  color: #333333;
  width: 16rem;
  height: 16rem;
  border-radius: 50%;
  border: 5px solid rgba(87, 224, 118, 0.98);
  background: linear-gradient(rgba(205, 220, 57, 0.9) 100%, rgba(255, 87, 34, 0.9) 100%, rgba(255, 87, 34, 0.9));
  text-transform: capitalize;
}

.period-ending {
  border: 5px solid red;
}

.footer {
  margin-top: 3rem;
}
            
          
!
            
              // Set up global variables
var clock = {
  break: 5,
  session: 25,
  sessionRunning: false,
  breakRunning: false,
  paused: false,
  elapsedTime: 0,
  remainingTime: 25 * 60 * 1000,
  startTime: new Date().getTime(),
  endTime: new Date().getTime() + (25 * 60 * 1000),
  clockIntervalId: "",
  increaseTime: function(breakOrSession) {
    this[breakOrSession] = (this[breakOrSession] < 45) ? this[breakOrSession] + 1 : this[breakOrSession];
    $("span.break-time").html(clock.break);
    $("span.session-time").html(clock.session);
  },
  decreaseTime: function(breakOrSession) {
    this[breakOrSession] = (this[breakOrSession] > 1) ? this[breakOrSession] - 1 : this[breakOrSession];
    $("span.break-time").html(clock.break);
    $("span.session-time").html(clock.session);
  },
  startSession: function(breakOrSession, continued) {
    clock.startTime = new Date().getTime();
    clock.breakRunning = false;
    clock.sessionRunning = false;
    clock[breakOrSession + "Running"] = true;
    clock.endTime = (!!continued) ? clock.startTime + clock.remainingTime : clock.startTime + (clock[breakOrSession] * 60 * 1000);

    clock.clockIntervalId = window.setInterval(function() {
      
      clock.remainingTime = clock.endTime - new Date().getTime();
      clock.updateView(breakOrSession);

      if (clock.remainingTime < 1000) {
        window.clearInterval(clock.clockIntervalId);
        clock.startSession((breakOrSession === "session") ? "break" : "session");
      }
    }, 1000, breakOrSession);
  },
  pauseSession: function() {
    clock.paused = true;
    window.clearInterval(clock.clockIntervalId);
  },
  updateView: function(breakOrSession) {
    $("span.display-text").html(breakOrSession);
    $("span.display-remaining-time").html( parseInt(clock.remainingTime / 1000 / 60) + ":" + parseInt(clock.remainingTime / 1000 % 60));
    
    if (clock.remainingTime < 50000) {
      $(".display").toggleClass("period-ending");
    }
  },
  reset: function() {
    clock.remainingTime = clock.session;
    clock.sessionRunning = false;
    clock.breakRunning = false;
    clock.paused = false;
    clock.elapsedTime = 0;
    window.clearInterval(clock.clockIntervalId);
    $("span.display-text").html("Session");
    $("span.display-remaining-time").html(clock.session);
    $(".display").removeClass("period-ending");
  }
};

// Start the engines
$(document).ready(function() {

  $("button", ".settings").on("click", function() {
    var plusOrMinus = $(this).val();
    var breakOrSession = $(this).hasClass("session-time") ? "session" : "break";
    if (plusOrMinus === "minus") {
      clock.decreaseTime(breakOrSession);
    }
    else {
      clock.increaseTime(breakOrSession);
    }
  });

  $("button.reset").on("click", function() {
    clock.reset();
  });
  $("button.pause").on("click", function() {
    clock.pauseSession();
    $("button.pause").prop("disabled", true);
  });


  $(".display").on("click", function() {
    $("span.break-time").html(clock.break);
    $("span.session-time").html(clock.session);
    if (clock.paused) {
      clock.startSession(clock.sessionRunning ? "session" : "break", true);
      $("button.pause").prop("disabled", false);
      clock.paused = false;
    } else if (!clock.paused && !clock.sessionRunning && !clock.breakRunning) {
        clock.startSession("session");
      }
    else {
      clock.pauseSession();
    }
  });
});
            
          
!
999px
Loading ..................

Console