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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <body>
  <div class='start btn-success' id='sound'>

  </div>
  <div id='pomodoro'>
    <div id='clock'>
      <p id='sob'>Session</p>
      <p id='time'>25:00</p>
    </div>
    <div id='changes'>
      <div id='sessionTime'>
        <h4>Session</h4>
        <div id='plusSession' class='btn btn-success'>+</div>
        <div id='currentSessionTime' class='btn btn-info'>25</div>
        <div id='minusSession' class='btn btn-danger'>-</div>
      </div>
      <div id='breakTime'>
        <h4>Break</h4>
        <div id='plusBreak' class='btn btn-success'>+</div>
        <div id='currentBreakTime' class='btn btn-info'>5</div>
        <div id='minusBreak' class='btn btn-danger'>-</div>
      </div>
      <div>
        <div class='btn btn-info' id='reset'>Reset</div>
      </div>
    </div>
  </div>


</body>
            
          
!
            
              #pomodoro {
  z-index: 1;
  position: absolute;
  top: 100px;
  left: 300px;
  height: 450px;
  width: 450px;
  border-radius: 100%;
  background-color: tomato;
}

.start {
  position: absolute;
  top: 33.33333333333px;
  left: 225px;
  z-index: 0;
  height: 600px;
  width: 600px;
  border-radius: 100%;
  background-color: green;
}

#clock {
  height: 150px;
  width: 250px;
  position: relative;
  left: 100px;
  top: 50px;
}

#sob {
  font-family: serif;
  font-size: 300%;
  color: white;
  text-align: center;
}

#time {
  font-family: serif;
  font-size: 300%;
  color: white;
  text-align: center;
}

#changes {
  height: 150px;
  width: 250px;
  position: relative;
  left: 100px;
  top: 50px;
}

#reset {
  position: relative;
  top: -60px;
  left: 95px;
}

#sessionTime {
  height: 150px;
  width: 125px;
  float: left;
  text-align: center;
}

#breakTime {
  height: 150px;
  width: 125px;
  float: right;
  text-align: center;
}
            
          
!
            
                  /* deklaracje zmiennych */
    var i = 0;
    var j = 0;
    var sessionTimevar = 26;
    var breakTimevar = 6;
    var timer;
    var seconds;
    var onlyseconds;
    var minutes;
    var currentSession = sessionTimevar;
    $('document').ready(function() {

      /* przyciski */

      $('#plusSession').click(function() {
        sessionTimevar++;
        $('#currentSessionTime').html(sessionTimevar - 1);
      });
      $('#minusSession').click(function() {
        if (sessionTimevar > 2) {
          sessionTimevar--;
        }
        $('#currentSessionTime').html(sessionTimevar - 1);
      });
      $('#plusBreak').click(function() {
        breakTimevar++;
        $('#currentBreakTime').html(breakTimevar - 1);
      });
      $('#minusBreak').click(function() {
        if (breakTimevar > 2) {
          breakTimevar--;
        }
        $('#currentBreakTime').html(breakTimevar - 1);
      });

      $('.start').click(function() {
        switch (i) {
          case 0:
            currentSession = sessionTimevar;
            seconds = currentSession * 60;
            minutes = Math.round(currentSession - 1);
            onlyseconds = 0;
            i = 1;
            if (j === 0) {
              started();
            } else
              breakTimeStart();
            break;

          case 1:
            i = 0;
            stopped();
            break;
        }
      });

      function started() {
        j = 0;
        $('#sob').html('Work time');
        seconds -= 1;
        if (onlyseconds <= 0.999) {
          minutes--;
        }
        onlyseconds = seconds % 60;
        onlyseconds = onlyseconds.toFixed(0);
        if (onlyseconds < 10) {
          onlyseconds = '0' + onlyseconds;
        }
        $('#time').html(minutes + ':' + onlyseconds);
        if (minutes < 0) {
          $('#time').html('0:00');
        }
        if (minutes >= 0) {
          timer = setTimeout(function() {
            started();
          }, 1000);
        } else {
          playSound();
          breakTimeStart();
        }
      };

      function breakTimeStart() {
        j = 1;
        currentSession = breakTimevar;
        seconds = currentSession * 60;
        minutes = currentSession - 1;
        onlyseconds = 0;
        $('#sob').html('Break time');
        breaktime();
      };

      function breaktime() {
        seconds -= 1;
        if (onlyseconds <= 0.999) {
          minutes--;
        }
        onlyseconds = seconds % 60;
        onlyseconds = onlyseconds.toFixed(0);
        if (onlyseconds < 10) {
          onlyseconds = '0' + onlyseconds;
        }
        $('#time').html(minutes + ':' + onlyseconds);
        if (minutes < 0) {
          $('#time').html('0:00');
        }
        if (minutes >= 0) {
          timer = setTimeout(function() {
            breaktime();
          }, 1000);
        } else {
          playSound();
        }
      }
      if (minutes < 0) {
        $('#time').html('0:00');
      }

      function stopped() {
        sessionTimevar = seconds / 60;
        clearTimeout(timer);
      }

      function playSound() {
        $("#sound").html('<audio autoplay="autoplay"><source src="https://www.freesound.org/people/JohnsonBrandEditing/sounds/173932/download/173932__johnsonbrandediting__ding-ding-small-bell.wav" type="audio/mpeg" />');
      }
      $('#reset').click(function() {
        clearTimeout(timer);
        sessionTimevar = 25;
        i = 0;
        j = 0;
        sessionTimevar = 26;
        breakTimevar = 6;
        timer = 0;
        seconds = 0;
        onlyseconds = 0;
        minutes = 0;
        currentSession = sessionTimevar;
        $('#time').html('25:00');
        $('#currentSessionTime').html(sessionTimevar - 1);
        $('#currentBreakTime').html(breakTimevar - 1);

      });

    });
            
          
!
999px
Loading ..................

Console