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.

Quick-add: + add another resource

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.

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.

            
              <html>

<body>
  <header>
    <h1 class="title"> POMODORO CLOCK</h1>
  </header>

  <div class=container>
    <div class="row">
      <div class="col-md-6">
    <div class="settings">
      <h2>Session Length</h2>
      <button class="operator" value="-">-</button>
      <h3 id="sessionLength" class="">25</h3>
      <button class="operator" value="+">+</button>
    </div>
      </div>
      <div class="col-md-6">
      <div class="settings">
        <h2>Break Length</h2>
      <button class="operator2" value="-">-</button>
      <h3 id="breakLength" class="">05</h3>
      <button class="operator2" value="+">+</button>
    </div>
      </div>
      </div>

    <div class="timer">
      <h1 class="clock">25 : 00</h1>
    </div>
    
    <div class="buttons">
      <button class="reset invisible">RESET</button>
    </div>
  </div>
</body>

</html>
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Baloo+Bhaina');
@import url('https://fonts.googleapis.com/css?family=Inconsolata');

body{
  font-family:Open Sans;
  color:#E8EAF6;
  background-color:#0D47A1;
  transition: all 0.35s;
}

header{
  font-family:Baloo Bhaina;
  padding-top:10%;
  padding-bottom:5%;
  text-align:center;
}
h1{

}
h3{
  padding-top:10px;
  text-align:center;
  display:inline-block;
}
.operator{
  height:30px;
  width:30px;
  background-color:#E8EAF6;
  border-radius:15px;
  border-color:#7986CB;
  margin:0;
  display:inline-block;
}

.operator2{
  height:30px;
  width:30px;
  background-color:#E8EAF6;
  border-radius:15px;
  border-color:#7986CB;
  margin:0;
  display:inline-block;
}
.settings{
  font-family:inconsolata;
  text-align:center;
}
.hidden{
  display : invisible;
}
.timer{
  cursor:pointer;
  margin:0 auto;
  margin-top:50px;
  position:relative;
  height:300px;
  width:300px;
  border-radius:50%;
  border:10px solid;
  border-color:#E8EAF6;
  padding-top:120px;
  text-align:center;
  font-family:Inconsolata;
}

.buttons{
  padding:20px;
  text-align:center;
}
.reset {
  position:relative;
  height:30px;
  width:auto;
  background-color:#E8EAF6;
  border-radius: 5px;
  border-color:#7986CB;
  margin:3px;
  display:inline-block;
}


            
          
!
            
              $(function() {
  let sessionLength = 25
  let breakLength = 5
  const [notRunning, session, breakTime] = [0, 1, 2]
  let status = notRunning
  let paused = false
  let currentTime = 0
  
  const reset = $('.reset')
  const clock = $('.clock')
  const sessionLengthDOM = $('#sessionLength')
  const breakLengthDOM = $('#breakLength')

  const [sessMinus, sessPlus] = $('.operator')
  const [breakMinus, breakPlus] = $('.operator2')

  function pad(str) {
    str = "" + str
    return str.length > 1 ? str : "0" + str
  }

  function updateSessionLength() {
    $(sessionLengthDOM).html(pad(sessionLength))
    if (status == notRunning){
    currentTime = sessionLength * 60
    updateClock()
    }
  }

  function updateBreakLength() {
    $(breakLengthDOM).html(pad(breakLength))
  }

  $(sessMinus).on("click", function() {
    sessionLength = sessionLength > 1 ? sessionLength - 1 : 1
    updateSessionLength()
  })
  $(sessPlus).on("click", function() {
    sessionLength = sessionLength < 60 ? sessionLength + 1 : 60
    updateSessionLength()
  })

  $(breakMinus).on("click", function() {
    breakLength = breakLength > 1 ? breakLength - 1 : 1
    updateBreakLength()
  })
  $(breakPlus).on("click", function() {
    breakLength = breakLength < 60 ? breakLength + 1 : 60
    updateBreakLength()
  })

  function updateClock() {
    let sec = currentTime % 60
    let min = Math.floor(currentTime / 60)
    $(clock).html(pad(min) + " : " + pad(sec))
  }

  $('.timer').on('click', function(){
    if (status != notRunning){
    paused = !paused
    } else {
      status = session;
    }
  })
  $(reset).on('click', function(){
    reset.addClass('invisible')
    currentTime = sessionLength * 60
    status = notRunning
    paused = false
  })
  setInterval(function() {
    if(!paused){
    switch (status) {
      case notRunning:
        $("body").css("background-color", "#0D47A1")
        break
      case session:
        currentTime--
        $("body").css("background-color", "#004D40")
        if (currentTime < 1){
          currentTime = breakLength * 60
          status = breakTime
        }
        $(reset).removeClass("invisible")
        break
      case breakTime:
        $("body").css("background-color", "#212121")
        if (currentTime < 1){
          currentTime = sessionLength * 60
          status = session
        }
        currentTime--
        break
      default:
        break
    }
    }
    updateClock()
  }, 1000)
  
  
  updateSessionLength()
  updateBreakLength()
})
            
          
!
999px
Loading ..................

Console