Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="timerBlocks">
  <div id="timer">25:00</div>
  <div id="clockColumn">
    <!-- start timer blocks -->
    <div class="block" id="block1"></div>
    <div class="block" id="block2"></div>
    <div class="block" id="block3"></div>
    <div class="block" id="block4"></div>
    <div class="block" id="block5"></div>
    <div class="block" id="block6"></div>
    <div class="block" id="block7"></div>
    <div class="block" id="block8"></div>
    <div class="block" id="block9"></div>
    <div class="block" id="block10"></div>
    <!-- end timer blocks -->
  </div>
</div>
<div class="setTime">
  <div id="topStop"><div class="workBreak" id="work">work</div><div class="workBreak" id="break">break</div></div>
  <div id="setMid">
  <div class="colStop" id="leftStop"></div>
  <div class="slider">
    <div class="slider__thumb" id="workSlider"></div>
  </div>
  <div class="colStop" id="midStop"></div>
<div class="slider">
    <div class="slider__thumb" id="breakSlider"></div>
  </div>
  <div class="colStop" id="rightStop"></div>
  </div>
  <div id="go"><button id="goButton">GO!</button></div>
</div>
              
            
!

CSS

              
                body {
  //border: solid black;
  display: flex;
  display: -webkit-flex;
  
}

#timer {
  height: 25%;
  width: 70%;
  border: 5px solid rgb(74, 74, 74);
  border-radius: 15px;
  
  display: flex;
  display: -webkit-flex;
  font-size: 500%;
  justify-content: center;
  -webkit-justify-content: center;
  align-items: center;
  -webkit-align-items: center;
}

.timerBlocks {
  width: 50%;
  height: 80vh;
  //border: solid blue;
  display: flex;
  display: -webkit-flex;
  justify-content: center;
  -webkit-justify-content: center;
  align-items: center;
  -webkit-align-items: center;
  flex-direction: column;
  -webkit-flex-direction: column;
  
}

#clockColumn {
  height: 75%;
  width: 50%;
  border: 11px solid red;
  background-color: rgb(66, 165, 255);
  border-radius: 25px;
  display: flex;
  display: -webkit-flex;
  flex-direction: column;
  -webkit-flex-direction: column;
}

.block {
  border: solid rgb(66, 165, 255);

  background-color: yellow;
  border-radius: 10px;
  width: 100%;
  height: 10%;
  //-webkit-transition: width linear 1s; /*       Safari */
  //transition: width linear 1s;

}

#setMid {
  //border: solid purple;
  height: 50%;
  width: 100%;
  display: flex;
  display: -webkit-flex;
}

.setTime {
  width: 50%;
  height: 80vh;
  margin-right: 5px;
  //border: solid blue;
  display: flex;
  display: -webkit-flex;
  flex-direction: column;
  -webkit-flex-direction: column;

}

#topStop {
  //border: 5px solid grey;
  height: 25%;
  width: 100%;
  display: flex;
  display: -webkit-flex;
}

.workBreak {
  width: 50%;
  margin: 5px;
  color: rgb(169, 246, 169);
  border: 3px solid black;

  background-color: rgb(154, 68, 198);
  margin-top: 2%;
  height: 70%;
  font-size: 300%;
  display: flex;
  display: -webkit-flex;
  justify-content: center;
  -webkit-justify-content: center;
  align-items: center;
  -webkit-align-items: center;

}


#go {
  height: 25%;
  width: 100%;
  //border: solid black;
  display: flex;
  display: -webkit-flex;
  font-size: 500%;
  justify-content: center;
  -webkit-justify-content: center;
  align-items: center;
  -webkit-align-items: center;
  background-color: rgb(0, 147, 0);
  
}

#go:active {
  transform: translate(0px, 5px);
  height: 24%;
  margin-left: 1%;
  width: 98%;
  -webkit-transform: translate(0px, 5px);
}

#goButton {
  height: 100%;
  width: 100%;
  font-size: 100%;
  justify-content: center;
  -webkit-justify-content: center;
  align-items: center;
  -webkit-align-items: center;
  background-color: rgb(0, 147, 0);
  box-shadow: 5px 5px 5px black;
  outline: none;
  border: none;
  box-shadow: 0 9px black;
}

#goButton:hover {background-color: rgb(0, 177, 0)}

#goButton:active {
  box-shadow: 0 0px yellow;
  transform: translateY(4px);
}

#fader {
  border: solid purple;
  width: 20%;
  height: 20%;
  background-color: purple;
}

.colStop {
  
  width: 20%;
  height: 100%;
  display: inline-flex;
  display: -webkit-inline-flex;
  
}

.slider {
  margin-left: 10%;
  margin-right: 10%;
}
              
            
!

JS

              
                  var goColor = "green";
  var running = false;
  var done = true;
  var paused = false;
  var theTimer;
  var barCount = 0;

  var workMin;
  var breakMin;
  var work = true;
  var blockWidth = parseInt($("#block1").css("width"), 10);
  var blockWidthPercent = blockWidth / 100;
  var blockWidthPx = blockWidth + "px";
  var hundred = 100;

  ////////////////////////


  $("#goButton").on("click", function() {
      if (goColor === "green") {
        $(this).css("background-color", "rgb(255, 117, 230)");
        $(this).text("PAUSE!");
        goColor = "pink";
      } else {
        $(this).css("background-color", "rgb(0, 147, 0)");
        $(this).text("GO!");
        goColor = "green";
      }
      //////////////////////////
      workMin = $("#workSlider").attr('data-value');
      breakMin = $("#breakSlider").attr('data-value');
      

   
      var minutes = workMin - 1;
    
      var seconds = "60";
      seconds = parseInt(seconds, 10);

      //console.log("running: "+running+"; done: "+done+"; paused: "+paused);

      if (running) {

        if (done) {
          
          countDown(minutes, seconds, paused, done, work);

          //alert(minutes, seconds, paused);
        } else {

          // get current, set w/out timing
          minutes = getMinutes();
          seconds = getSeconds();
          console.log("??? "+seconds);
          countDown(minutes, seconds, paused, done, work);
          paused = true;
          running = false;

          if (seconds > 9) {
          $("#timer").text(minutes + ":" + seconds); } else {
            $("#timer").text(minutes + ":0"+seconds);
          }

        }

      } else {

        if (paused) {
 
          minutes = getMinutes();
          seconds = getSeconds();


          countDown(minutes, seconds, paused, done, work);

          running = true;
          paused = false;
          done = false;

          // get current and begin countdown

        } else {
          // set mins and countdown

          countDown(minutes, seconds, paused, done, work);
          running = true;
          paused = false;
          done = false;

        }

      } // end large else  

    }) // end button click

  ///////////////////////////

  function getMinutes() {

    var minutes;
    var current = $("#timer").text();
    var length = current.length;
    
    if (length === 5) {
      minutes = current.charAt(0) + current.charAt(1); } else {
      minutes = current.charAt(0);
    }

    minutes = parseInt(minutes, 10);

    return minutes;

  }

  function getSeconds() {

    var current = $("#timer").text();

    var length = current.length;

    if (length === 5) {
      var seconds = current.charAt(length-2) + current.charAt(length - 1);
    }

    if (length === 4) {
      var seconds = current.charAt(length - 2) + current.charAt(length - 1);
    }

    if (length === 3) {
      var seconds = current.charAt(length - 1);
    }


    seconds = parseInt(seconds, 10);

    return seconds;

  }

  function startTimer(minutes) {
    var seconds = "59";

    $("#block1").css("width", blockWidthPx);
    $("#block2").css("width", blockWidthPx);
    $("#block3").css("width", blockWidthPx);
    $("#block4").css("width", blockWidthPx);
    $("#block5").css("width", blockWidthPx);
    $("#block6").css("width", blockWidthPx);
    $("#block7").css("width", blockWidthPx);
    $("#block8").css("width", blockWidthPx);
    $("#block9").css("width", blockWidthPx);
    $("#block10").css("width", blockWidthPx);

    minutes = minutes - 1;
    whichBlock = 1;


    if (work) {
      work = false;
    } else {
      work = true;
    }

    countDown(minutes, seconds, false, true, work);

  }

  ////////////////////

  var whichBlock = 1;

console.log("before countDown work is "+work);

  function countDown(minutes, seconds, paused, done, work) {

    workMin = $("#workSlider").attr('data-value');
      breakMin = $("#breakSlider").attr('data-value');
    
    var unit;
    var width;

    if (paused || done) {

      theTimer = setInterval(function timerDown() {
        //alert("but wait THERE'S MORE");

        if (seconds < 1) {
          seconds = 60;
          minutes--;
        }

        seconds--;

        seconds = seconds.toString();
        if (seconds < 10) {
          seconds = "0" + seconds;
        }

        if (minutes < 0) {
  
          if (work) {
          minutes = breakMin;
          work = false;
          } else {
            minutes = workMin;
            work = true;
          }

          clearInterval(theTimer);
          startTimer(minutes);
          done = false;
          seconds = "59";
          minutes--;
        }

        $("#timer").text(minutes + ":" + seconds);

        function getTheBlock() {

          switch (whichBlock) {
            case 1:
              width = $("#block1").css("width");
              break;
            case 2:
              width = $("#block2").css("width");
              break;
            case 3:
              width = $("#block3").css("width");
              break;
            case 4:
              width = $("#block4").css("width");
              break;
            case 5:
              width = $("#block5").css("width");
              break;
            case 6:
              width = $("#block6").css("width");
              break;
            case 7:
              width = $("#block7").css("width");
              break;
            case 8:
              width = $("#block8").css("width");
              break;
            case 9:
              width = $("#block9").css("width");
              break;
            case 10:
              width = $("#block10").css("width");
              break;

          }

          width = parseInt(width);

          width = width / blockWidthPercent;

          return width;
        } // end get the block

        function shrinkTheBar(width) {

          switch (whichBlock) {
            case 1:
              $("#block1").css("width", width);

              break;
            case 2:
              $("#block2").css("width", width);
              break;
            case 3:
              $("#block3").css("width", width);
              break;
            case 4:
              $("#block4").css("width", width);
              break;
            case 5:
              $("#block5").css("width", width);
              break;
            case 6:
              $("#block6").css("width", width);
              break;
            case 7:
              $("#block7").css("width", width);
              break;
            case 8:
              $("#block8").css("width", width);
              break;
            case 9:
              $("#block9").css("width", width);
              break;
            case 10:
              $("#block10").css("width", width);
              break;

          }
        }

        function getUnit() {

          console.log("getUnit function work is "+work);
          var second;
          
          if (work) {
          second = (workMin * 60) / 10;
          } else {
            second = (breakMin * 60) / 10;
          }
        
          // second equals the number of seconds in each bar

          // unit equals the percent each shrink must shrink

          unit = 100/second;
          
          return unit;
        }

        

        unit = getUnit();

        barCount++;
        
        //console.log(hundred+" - "+unit+" = "+(hundred-unit));
        hundred -= unit;
        width = hundred;
        
        // console bar shrinking values
        /*
        console.log("width is "+hundred+"%");
        
        console.log("unit is "+unit+"%");
        
        console.log(barCount+" seconds in this bar");
        
        console.log(".......");        
        */
        
        if (width <= (unit/2)) {
          shrinkTheBar(0);
          hundred = 100;
          barCount = 0;
          whichBlock++;
        } else {
          
          width = width+"%";
        shrinkTheBar(width);

        } 
      }, 1000);
    } else {

      clearInterval(theTimer);

      $("#timer").text(minutes + ":" + seconds);

    } // end else

  } // end countDown
              
            
!
999px

Console