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="container text-center">
  <div class="row text-center">
    <div class="col-xs-12">
      <h1>FreeCodeCamp Podomoro</h1>
    </div>
  </div>
  <div class="row intervalContainer text-center">
    <div class="col-xs-12" id="break">
      <h3>Break Time</h3> <br />
      <button class="btn btn-danger" id="breakMinus">-</button>
      <div id="breakNum">5</div>
      <button class="btn btn-success" id="breakPlus">+</button>
    </div>
    <div class="col-xs-12" id="Setpomodoro">
      <h3>Pomodoro Time</h3> <br />
      <button class="btn btn-danger" id="workMinus">-</button>
      <div id="pomodoroNum">25</div>
      <button class="btn btn-success" id="workPlus">+</button>
    </div>
  </div>
  <div class="row timerContainer text-center">
    <div class="col-xs-12">
      <h2 id="timerStatus">Work</h2>
      <span id="timer">25</span>
    </div>
  </div>
  <div class="row start_stop">
    <div class="col-xs-12 text-center" id="buttonContainer">
      <button class="btn btn-success" id="startBtn">Start</button>
      <button class="btn btn-danger" id="stopBtn">Stop</button>
    </div>
  </div>

</div>
              
            
!

CSS

              
                body{
  background-color:#000066;
  color:grey;
  }

#breakNum{
 display: inline-block;
  margin: 0 10px;
  
}
#pomodoroNum{
  display:inline-Block;
  margin: 0 10px;
}

#buttonContainer {
  margin-top:20px;
}

.timerContainer {
  border:5px solid red;
  border-radius:50%;
  margin:12px 0 7px;
  display:inline-block;
  padding:15px;

}

#timer{
  font-size:1.8em;
}


              
            
!

JS

              
                $(document).ready(function() {
  var pomoTime = $('#pomodoroNum');
  var breakTime = $('#breakNum');
  var status = $('#timerStatus');
  var timerDisplay = $('#timer');
  var startButton = $('#startBtn');
  var stopButton = $('#stopBtn');
  var breakVal = 4; // initial value of break clock when switched.
  var state = 1; // 1=stopped 2=running
  var countDown; // intervalID;
  var minutes = 24;
  var seconds = 60;

  startButton.click(function() {
    if (state == 1) { // if timer is not running then start timer
      startTimer(minutes, seconds);
      $('#breakMinus').off("click");
      $('#breakPlus').off("click");
      $('#workMinus').off("click");
      $('#workPlus').off("click"); // disable +- controls when timer starts

    };
  });

  updateDisplay(); // initially controls are enabled at the start

  stopButton.on("click", function() {
    if (state == 2) {
      pauseTimer();
      state = 1;
      updateDisplay(); // renable +- controls when timer stops

    }
  });

  if (status.text() == "Break") {
    $('#workMinus').off("click");
    $('#workPlus').off("click");
    // disable work control when break is on.
  }

  function startTimer(m, s) {
    state = 2;
    var startMinutes = m;
    var startSeconds = s;

    countDown = setInterval(function() {

      startSeconds--;
      startMinutes = ("0" + startMinutes).slice(-2); // double digits conversion if <10
      startSeconds = ("0" + startSeconds).slice(-2);

      minutes = ("0" + startMinutes).slice(-2); // update minutes and seconds so when timer is stopped, it can resume from where it left off when startButton is pressed.
      seconds = ("0" + startSeconds).slice(-2);

      timerDisplay.html(startMinutes + ":" + startSeconds);

      if (startSeconds <= 0 && startMinutes > 0) {
        startMinutes -= 1; // decerement minutes when seconds 0...
        startSeconds += 60; // ..and reset seconds to 60
      }

      if (startMinutes <= 0 && startSeconds <= 0 && status.text() == "Work") {
        status.text("Break");
        startMinutes = breakVal;
        startSeconds = 60;
        minutes = breakVal;
        seconds = 60;
        state = 2;
        $(".timerContainer").css({
          "border-color": "green"
        });
      };

      if (startMinutes <= 0 && startSeconds <= 0 && status.text() == "Break") {
        status.text("Work");
        startMinutes = pomoTime.text() - 1;
        startSeconds = 60;
        seconds = 60;
        state = 2;
        $(".timerContainer").css({
          "border-color": "red"
        });
      }

    }, 1000);

  };

  function pauseTimer() {

    clearInterval(countDown);
  };

  function updateDisplay() { // this function updates time and display. thought it was easier to do it one function rather than two even though readability is affected.
    // break +-
    $('#breakMinus').on("click", function() {
      if (breakTime.text() > 1) {
        breakVal = breakTime.text() - 2; // -2 because timer was always +2 than it should have been when minus control was used.
        if (status.text() == "Break") {
          minutes = breakTime.text() - 2;
          seconds = 60;
        }
      }
      if (breakTime.text() > 1) {
        breakTime.text(+breakTime.text() - 1);
      };
      if (status.text() == "Break") {
        timerDisplay.text(breakTime.text());
      };
    });

    $('#breakPlus').on("click", function() {
      breakVal = breakTime.text();
      breakTime.text(+breakTime.text() + 1);
      if (status.text() == "Break") {

        minutes = breakTime.text() - 1;
        seconds = 60;
        timerDisplay.text(breakTime.text());
      };
    });

    // work +-
    $('#workMinus').on("click", function() {
      if (pomoTime.text() > 1) {
        if (status.text() == "Work")
          minutes = pomoTime.text() - 2;
        seconds = 60;
      }
      if (pomoTime.text() > 1) {
        pomoTime.text(+pomoTime.text() - 1);
      };
      timerDisplay.text(pomoTime.text());
    });

    $('#workPlus').on("click", function() {
      if (status.text() == "Work") {
        minutes = pomoTime.text();
        seconds = 60;
      }
      pomoTime.text(+pomoTime.text() + 1);

      timerDisplay.html(pomoTime.html());

    });
  };

});
              
            
!
999px

Console