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.

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

            
              <div class="heading">
  <div class="container">
    <div class="row">
      <h1 id="title"> Pomodoro clock </h1>
    </div>
    <div class="row center-block length">
      <div class="col-lg-6 col-md-6 col-sm-6">
        <button type="button" class="btn" id="minusMinuteButton">-1</button>
        <strong>Session Length: <span id="sessionLength"></span> </strong>
        <button type="button" class="btn" id="addMinuteButton">+1</button>
      </div>
      <div class="col-lg-6 col-md-6 col-sm-6">
        <button type="button" class="btn" id="minusBreakMinuteButton"> -1 </button>
        <strong> Break Length: <span id="breakLength"></span> </strong>
        <button type="button" class="btn" id="addBreakMinuteButton"> +1 </button>
      </div>
    </div>
  </div>
</div>


<div class="timer">
  <div class="container">
    <h1>
          <div class="minutes"></div>
          :
          <div class="seconds"></div>
        </h1>
  </div>
  <div class="center-block">
    <span id="type"> WORK </span>
  </div>
</div>


<div class="buttons">
  <div class="container">
    <div class="row">
      <br>
      <div id="progressBar center-block">
        <div id="outsideBar">
          <div id="insideBar">
          </div>
        </div>
      </div>
      <button type="button" class="btn center-block " id="startBtn">Start</button>
    </div>

  </div>
</div>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Fredoka+One);

h1 {
  font-size: 400%;
}
h1, h2 {
  text-align: center;
}

#title {
  font-family: 'Fredoka One';
  padding-bottom: 5vh;
}
.minutes {
  display: inline;
}

.seconds {
  display: inline;
}

.center-block {
  margin: 0 auto;
  float: none;
  text-align: center;
}

#type {
  font-size: 220%;
}

#progressBar {
 	width: 200px;
	height: 100px;
	background: red;
}

.length {
   font-size: 150%; 
}

.btn {
   color: #DFDCE3;
   background-color: #FC4A1A;
   font-weight: bold;
   border: solid;
   border-radius: 5px;
}

.btn:hover {
   color: #DFDCE3;
   background-color: #C92E03;
   font-weight: bold;
   border: solid;
   border-radius: 5px;
}

.btn:focus {
   color: #DFDCE3;
   background-color: #FC4A1A;
   font-weight: bold;
   border: solid;
   border-radius: 5px;
}

body {
   background-color: #4ABDAC;
   color: #DFDCE3;
}
            
          
!
            
              $(document).ready(function() {
    var minutesClass = $(".minutes");
    var secondsClass = $(".seconds");
    var sessionLength = $("#sessionLength");
    var breakLength = $("#breakLength");
    var progressBar = $("#progressBar");
    var type = $("#type");
    var started = false;
    var breakTime = false;

    var minutes = 25;
    var seconds = 0;

    var minutesSession = 25;
    var minutesBreak = 5;

    $("#startBtn").on("click", startClock);
    $("#addMinuteButton").on("click", addMinuteClock);
    $("#minusMinuteButton").on("click", minusMinuteClock);
    $("#minusBreakMinuteButton").on("click", minusBreakMinute);
    $("#addBreakMinuteButton").on("click", addBreakMinute);
    buildClock();

    var timeInterval;

    function buildClock() {
        minutesClass.html(minutes);
        secondsClass.html("0" + seconds);
        sessionLength.html(minutesSession);
        breakLength.html(minutesBreak);
    }

    function updateClock() {
        if ((seconds === 0 && minutes === 0) && breakTime === false) {
            minutes = minutesBreak;
            breakTime = true;
            type.html("BREAK");
        } else if ((seconds === 0 && minutes === 0) && breakTime === true) {
            minutes = minutesSession;
            breakTime = false;
            type.html("WORK");
        }

        if (seconds === -1) {
            minutes = minutes - 1;
            seconds = 59;
        }
        if (seconds <= 9) {
            secondsClass.html("0" + seconds);
        } else {
            secondsClass.html(seconds);
        }
        minutesClass.html(minutes);
        seconds = seconds - 1;
    }

    function startClock() {
        if (started === true) {
            $("#startBtn").html("Start");
            clearInterval(timeInterval);
            started = false;
        } else {
            $("#startBtn").html("Stop");
            updateClock();
            timeInterval = setInterval(updateClock, 1000);
            started = true;
        }
    }

    function addMinuteClock() {
        if (started === false) {
            minutesSession++;
            adjustSessionClock();
        } else if (breakTime === true) {
            minutesSession++;
            sessionLength.html(minutesSession);
        }
    }

    function minusMinuteClock() {
        if (minutesSession > 1 && started === false) {
            minutesSession--;
            adjustSessionClock();
        } else if (minutesSession > 1 && breakTime === true) {
            minutesSession--;
            sessionLength.html(minutesSession);
        }
    }

    function adjustSessionClock() {
        sessionLength.html(minutesSession);
        if (breakTime === false) {
            minutes = minutesSession;
            minutesClass.html(minutes);
            seconds = 0;
            secondsClass.html("00");
        }

    }

    function adjustBreakClock() {
        breakLength.html(minutesBreak);
        if (breakTime === true) {
            minutes = minutesBreak;
            minutesClass.html(minutes);
            seconds = 0;
            secondsClass.html("00");
        }

    }

    function addBreakMinute() {
        if (started === false) {
            minutesBreak++;
            adjustBreakClock();
        } else if (breakTime === false) {
            minutesBreak++;
            breakLength.html(minutesBreak);
        }
    }

    function minusBreakMinute() {
        if (minutesBreak > 1 && started === false) {
            minutesBreak--;
            adjustBreakClock();
        } else if (minutesBreak > 1 && breakTime === false) {
            minutesBreak--;
            breakLength.html(minutesBreak);
        }
    }

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