123

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.

            
              <head>

  <script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
  <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
  <title>Pomodoro Clock</title>
</head>

<body>
  <div class="workConsole consoleOuter">
    <div class="row arrowRow upRow">
      <div class="arrow" id="workkHourxUp">&#9650;</div>
      <div class="arrow" id="workkMinxUp">&#9650;</div>
      <div class="arrow" id="workkSecxUp">&#9650;</div>
    </div>
    <div class="row numbers">
      <div class="digit" id="workkHour">00</div>
      <div class="colon">:</div>
      <div class="digit" id="workkMin">25</div>
      <div class="colon">:</div>
      <div class="digit" id="workkSec">00</div>
    </div>
    <div class="row arrowRow downRow">
      <div class="arrow" id="workkHourxDown">&#9660;</div>
      <div class="arrow" id="workkMinxDown">&#9660;</div>
      <div class="arrow" id="workkSecxDown">&#9660;</div>
    </div>
    <div class="row label">Work Time</div>
  </div>
  <div class="breakConsole consoleOuter">
    <div class="row arrowRow upRow">
      <div class="arrow" id="breakHourxUp">&#9650;</div>
      <div class="arrow" id="breakMinxUp">&#9650;</div>
      <div class="arrow" id="breakSecxUp">&#9650;</div>
    </div>
    <div class="row numbers">
      <div class="digit" id="breakHour">00</div>
      <div class="colon">:</div>
      <div class="digit" id="breakMin">05</div>
      <div class="colon">:</div>
      <div class="digit" id="breakSec">00</div>
    </div>
    <div class="row arrowRow downRow">
      <div class="arrow" id="breakHourxDown">&#9660;</div>
      <div class="arrow" id="breakMinxDown">&#9660;</div>
      <div class="arrow" id="breakSecxDown">&#9660;</div>
    </div>
    <div class="row label">Break Time</div>
  </div>

  <div class="timerBox">
    <div class="timer"><span class="timerHour">0</span>:<span class="timerMinute">25</span>:<span class="timerSecond">00</span>
      <br> Time Remaining
      <div class="buttonBox">
        <div class="button" id="pauseButton">II</div>
        <div class="button" id="startButton">&#9658;</div>
      </div>
    </div>
  </div>
  <div class="pictureBox">
    <div class="wheelContainer">
      <div class="wheel hours"><img class="pic hourpic" src="http://res.cloudinary.com/dmvfmmyly/image/upload/v1504143987/Clock/oie_gydWXfjXkq2a_zps3hdqhpdt.png" />
        <div class="wheel minutes"><img class="pic minpic" src="http://res.cloudinary.com/dmvfmmyly/image/upload/v1504143987/Clock/oie_Ip60UfwRWHo1_zpskie06tzu.png" />
          <div class="wheel seconds"><img class="pic secpic" src="http://res.cloudinary.com/dmvfmmyly/image/upload/v1504143987/Clock/oie_tzTDZNbrDgxi_zpsqwnubbsx.png" />

          </div>
        </div>
      </div>
      <div class="line"></div>
    </div>
  </div>
</body>
            
          
!
            
              body {
  background-image: url("http://res.cloudinary.com/dmvfmmyly/image/upload/v1504143987/Clock/clocks_gears_clockwork_hd-wallpaper-1341741_zps6lwpoanv.jpg");
  background-size: 100%;
  background-repeat: no-repeat;
}

.consoleOuter {
  margin-left: 1em;
  font-size: 3em;
  border: 2px solid black;
  position: absolute;
  border-radius: 5px;
  width: 5.5em;
  padding-left: 0.4em;
  margin-top: 1em;
}

.workConsole {
  background: #ff3333;
}

.breakConsole {
  position: relative;
  background: #33ff33;
  float: right;
  margin-right: 1em;
}

.label {
  float: left;
  text-shadow: -1px -1px black, 1px -1px black, -1px 1px black, 1px 1px black;
}

.digit {
  float: left;
  border 2px solid black;
  border: 1px solid black;
  border-radius: 5px;
  background: white;
  width: 1.3em;
  margin-left: 0.2em;
  padding-left: 0.05em;
}

.colon {
  float: left;
  margin-left: 0.1em;
}

.arrow {
  color: white;
  text-shadow: -1px -1px black, 1px -1px black, -1px 1px black, 1px 1px black;
  position: relative;
  float: left;
  width: 1.4em;
  margin-left: 0.4em;
}

.row {
  clear: left;
}

.wheelContainer {
  position: relative;
  text-align: center;
  margin-top: 3em;
}

.wheel {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
}

.hours {
  display: inline-block;
}

.minutes {
  top: 13%;
  display: inline-block;
}

.seconds {
  top: 22%;
  display: inline-block;
}

.pictureBox {
  margin: 0 auto;
  width: 75%;
  margin-top: 7em;
}

.timerBox {
  text-align: center;
  padding-left: 10em;
  width: 100%;
  font-size: 2em;
  color: white;
  text-shadow: -1px -1px black, 1px -1px black, -1px 1px black, 1px 1px black;
}

.buttonBox {
  text-align: center;
  margin-left: 33.3333%;
  width: 60%;
  height: 3em;
}

.button {
  text-align: center;
}

.button {
  font-size: 2em;
  font-weight: bold;
  position: relative;
  float: left;
}

.button:hover {
  cursor: pointer;
  color: black;
  text-shadow: -1px -1px red, 1px -1px red, -1px 1px red, 1px 1px red;
}

.arrow:hover {
  cursor: pointer;
  color: black;
  text-shadow: -1px -1px white, 1px -1px white, -1px 1px white, 1px 1px white;
}

.line {
  border: 2px solid red;
  height: 15em;
  width: 0em;
  margin: 0 auto;
  z-index: 3;
  position: relative;
}
            
          
!
            
              //POTENTIAL ENHANCEMENT: USE GRADIENTS IN WORK/BREAK TO SHOW PROGRESS

$(document).ready(function() {

  var hourVal = $('#workkHour').text;
  var minVal = $('#workkMin').text;
  var secondVal = $('#workkSec').text;
  var hourString;
  var minString;
  var secondString;
  var countdown;
  var running = false;
  var workflag = "workk"; //We are spelling "workk" with 2"k"s in the HTML so it has the same number of characters as "break".  This is useful when we want to break up the string to separate workk/break from hour/min/sec
  var modifier;
  var parentWidth;
  var thisCheck;
  var modified = false;
  var bell= new Audio("http://oringz.com/oringz-uploads/sounds-870-end-point-reached.mp3");

  
  //This code responsively centers the wheels based on the width of the browser window
  function centerWheels() {
    var wheels = ['.hours', '.minutes', '.seconds'];
    for (var i in wheels) {
      if (i == 0) {
        parentWidth = $('.wheelContainer').width();
      } else {
        parentWidth = $(wheels[i - 1]).width();
      }
      var thisWidth = $(wheels[i]).width();
      var wheelMargin = (parentWidth - thisWidth) / 2 + "px";
      $(wheels[i]).css("left", wheelMargin);
      console.log("this wheel is " + wheels[i] + " and its width is " + thisWidth + " and its middle is " + wheelMargin);
    }
  }

  function color() {
    if (workflag == "workk") {
      $(".workConsole").css("background", "#ff3333");
    } else {
      $(".breakConsole").css("background", "#33ff33");
    }
  }

  function checkDone() {
    if (hourVal <= 0 && minVal <= 0 && secondVal <= 0) {
      clearInterval(countdown);
      running = false;
      bell.play();
      if (workflag == "workk") {
        workflag = "break";
      } else {
        workflag = "workk";
      }
      setTimeout(startup, 0);
    }
  }

  function rotate(wheel, val) {
    var rotAmount;
    if (wheel == "hour") {
      rotAmount = (12 - val) * 30;
    } else {
      rotAmount = (60 - val) * 6;
    }
    var cssArgument = "rotate(" + rotAmount + "deg)";

    var cssTarget = "." + wheel + "pic";
    $(cssTarget).css("transform", cssArgument);
    $(cssTarget).css("-ms-transform", cssArgument);
    $(cssTarget).css("-webkit-transform", cssArgument);
  }

  function deductHour() {
    hourVal -= 1;
    checkDone();
    rotate("hour", hourVal);
  }

  function deductMinute() {
    minVal -= 1;
    if (minVal == -1) {
      deductHour();
      minVal = 59;
    }
    rotate("min", minVal);
  }

  function deductSecond() {
    secondVal -= 1;
    if (secondVal == -1) {
      deductMinute();
      secondVal = 59;
    }
    rotate("sec", secondVal + 1);
  }

  function display() {
    hourString = hourVal.toString();
    minString = minVal.toString();
    if (minString.length === 1) {
      minString = "0" + minString;
    }
    secondString = secondVal.toString();
    if (secondString.length === 1) {
      secondString = "0" + secondString;
    }

    $(".timerHour").html(hourString);
    $(".timerMinute").html(minString);
    $(".timerSecond").html(secondString);
    color();

  }

  rotate("hour", hourVal);
  rotate("min", minVal);
  rotate("sec", secondVal);

  function tick() {
    countdown = setInterval(function() {
      display();
      deductSecond();
    }, 1000);
  }

  function setVal(unit) {
    return Number($("#" + workflag + unit).text());
  }

  function startup() {
    running = true;
    $(".breakConsole").css("background", "#aaaaaa");
    $(".workConsole").css("background", "#aaaaaa");
    hourVal = setVal("Hour");
    minVal = setVal("Min");
    secondVal = setVal("Sec");
    rotate("hour", hourVal);
    rotate("min", minVal);
    rotate("sec", secondVal);
    tick();
  }

  function resume() {
    rotate("hour", hourVal);
    rotate("min", minVal);
    rotate("sec", secondVal);
    $(".breakConsole").css("background", "#aaaaaa");
    $(".workConsole").css("background", "#aaaaaa");
    tick();
  }

  $("#pauseButton").click(function() {
    running = false;
    clearInterval(countdown);
    $(".breakConsole").css("background", "#33ff33");
    $(".workConsole").css("background", "#ff3333");
  });

  $("#startButton").click(function() {
    if (running === false) {
      if (modified === true) {
        modified = false;
        startup();
      } else {
        resume();
      }
    }
  });

  $(".arrow").click(function() {
    modified = true;
    var buttId = this.id;
    var selectedArrow = buttId.split("x");
    if (running === false) {
      if (selectedArrow[1] == "Up") {
        modifier = 1;
      } else {
        modifier = -1;
      }
      var toModify = "#" + selectedArrow[0];
      var units = (selectedArrow[0].slice(5));
      var current = Number($(toModify).text());
      current += modifier;
      if (current === -1) {
        if (units == "Hour") {
          current = 0;
        } else {
          current = 59;
        }
      }
      if (current === 60) {
        current = 0;
      }
      if (current >= 12 && units == "Hour") {
        current = 12;
      }
      var currString = current.toString();
      if (currString.length == 1) {
        currString = "0" + currString;
      }
      $(toModify).text(currString);
    }
  });

  centerWheels();
  hourVal = setVal("Hour");
  minVal = setVal("Min");
  secondVal = setVal("Sec");
  rotate("hour", hourVal);
  rotate("min", minVal);
  rotate("sec", secondVal);
});
            
          
!
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.

Console