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.

+ 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.

            
              <div id="container">
		<div id="title">Pomodoro Clock</div>
		<div id="settings">
			
			<div id="break-box">
				<div class="settings-titles">Break Length</div>
				<div class="settings-box">
					<button class="minus" id="minus-break">-</button>
					<span class="numbers" id="break-length"></span>
					<button class="plus" id="plus-break">+</button>
				</div><!--settings-box-->
			</div> <!--break-box-->
			<div id="session-box">
				<div class="settings-titles">Session Length</div>
				<div class="settings-box">
					<button class="minus" id="minus-session">-</button>
					<span class="numbers" id="session-length"></span>
					<button class="plus" id="plus-session">+</button>
				</div><!--settings-box-->
			</div> <!--session-box-->
			<div class="pomodoro-box">
				<div id="session-text">Session</div>
				<div id="session-clock">25:00</div>
			</div> <!--pomodoro-box-->
			<div id="credits">Designed & Coded by <a href="https://www.linkedin.com/in/rafal-kmiecik-137693138/" target="_blank">Rafal Kmiecik</a></div>
			<div id="reset">reset</div>
		</div> <!--settings-->
	</div> <!--container-->
            
          
!
            
              html {
	height: 100vh;
	width: 100vw;
	background-image: url("http://i.imgur.com/jOxICPe.png");

}

a {
		color: rgba(0, 137, 32, 0.9);
		text-shadow: 1px 2px 15px #048014;
}

#title {
	text-align: center;
	font-size: 64px;
	padding-top: 20px;
	font-family: 'Orbitron', sans-serif;
	color: rgba(0, 137, 32, 0.9);
	text-shadow: 1px 2px 15px #048014;
}

#settings {
	margin-top: 20px;
	width: 400px;
	margin-left: auto;
	margin-right: auto;
}

.settings-titles {
	padding-top: 5px;
	text-align: center;
	font-family: 'Orbitron', sans-serif;
	color: rgba(0, 137, 32, 0.9);
	text-shadow: 1px 2px 15px #048014;
}

.minus, .plus  {
	position:relative;
	top:-5px;
	background-color: Transparent;
	background-repeat:no-repeat;
    border: none;
    cursor:pointer;
    overflow: hidden;
    outline:none;
	color: blue;
	font-size: 30px;
}

.plus {
	top:-2px;
}

.settings-box {
	text-align: center;
	margin-top: 15px;
	font-size: 28px;
	line-height: 28px;
	font-family: 'Orbitron', sans-serif;
	color: rgba(0, 137, 32, 0.9);
	text-shadow: 1px 2px 15px #048014;	
}

#break-box {
	height: 120px;
	width: 120px;
	float: left;
}

#session-box {
	height: 120px;
	width: 120px;
	margin-left: 280px;
}

.pomodoro-box { /*style for session state*/
	height: 300px;
	width: 300px;
	background-color: black;
	border-style: solid;
	border-width: 3px;
	 -webkit-transition: border 1s linear, box-shadow 1s linear;
       -moz-transition: border 1s linear, box-shadow 1s linear;
            transition: border 1s linear, box-shadow 1s linear;
	border-color: blue;
	box-shadow: 1px 2px 15px #0038F0;
	margin: 30px auto 0px auto;
	border-radius: 50%;
	clear:both;
	cursor: pointer;
	z-index:4;
}

.pomodoro-box2 { /*style for break state*/
	height: 300px;
	width: 300px;
	background-color: black;
	border-style: solid;
	border-width: 3px;
	 -webkit-transition: border 1s linear, box-shadow 1s linear;
       -moz-transition: border 1s linear, box-shadow 1s linear;
            transition: border 1s linear, box-shadow 1s linear;
	border-color: red;
	box-shadow: 1px 2px 15px #D60000;
	margin: 30px auto 0px auto;
	border-radius: 50%;
	clear:both;
	cursor: pointer;
	z-index:4;
}

.pomodoro-box.active { /*blue glover for session state*/
	-webkit-box-shadow: 0 0 180px #0038F0;
       -moz-box-shadow: 0 0 180px #0038F0;
            box-shadow: 0 0 180px #0038F0;
}

.pomodoro-box2.active { /*red glover for session state*/
	-webkit-box-shadow: 0 0 180px #D60000;
       -moz-box-shadow: 0 0 180px #D60000;
            box-shadow: 0 0 180px #D60000;
}

.pomodoro-box.inactive {  /*class added to reset glover state (pause and reset)*/
	-webkit-box-shadow: 0 0 0px #0038F0;
       -moz-box-shadow: 0 0 0px #0038F0;
            box-shadow: 0 0 0px #0038F0;
}



#session-text {
	padding-top: 30px;
	margin-top:15px;
	text-align: center;
	color: rgba(0, 137, 32, 0.9);
	text-shadow: 1px 2px 15px #048014;
	font-size: 44px;
	font-family: 'Orbitron', sans-serif;;
}

#session-clock {
	font-family: 'Orbitron', sans-serif;
	font-size: 76px;
	margin-top:10px;
	text-align: center;
	color: rgba(0, 137, 32, 0.9);
	text-shadow: 1px 2px 15px #048014;
}

#reset {
	text-align: center;
	font-family: 'Orbitron', sans-serif;
	color: rgba(0, 137, 32, 0.9);
	text-shadow: 1px 2px 15px #048014;
	margin-top:70px;
	border: solid 1px;
	width: 55px;
	float:right;
	right: -200px;
	position:relative;
	cursor: pointer;
}

#reset:hover {
	box-shadow: 1px 2px 15px #048014;
}

#credits {
	text-align: center;
	font-family: 'Orbitron', sans-serif;
	color: rgba(0, 137, 32, 0.9);
	margin-top:70px;
		float:left;
	left: -300px;
	position:relative;
	font-size: 14px;
}
            
          
!
            
              $(document).ready(function(){

var breakLength = 5; //number of minutes set as break
var breakLeft = 5;	//time left to the end of break in minutes (default same as breakLength)
var sessionLength = 25; //number of minutes set as session
var timeLeft = sessionLength-1; //time left to the end of session  in minutes (default same as sessionLength)
var seconds = 59;	//number of seconds left to decrase minutes left by 1
var checkIfPaused = 0; // checking if timer is paused, 1 - paused
var glower = $('.pomodoro-box'); //store class for glow animation
var titleName = $("#session-text").html();
var audio = new Audio('https://soundbible.com/grab.php?id=2156&type=mp3'); //store sound for alert when timer set 0

// --------- settings for length of break and session below this line ---------

// decrasing and incrasing break length

$("#break-length").html(breakLength);
	$("#minus-break").click(function(){
		if(breakLength>1 && checkIfPaused !== 1){	//working only if break length is bigger than 0 and timer is paused
		breakLength--;
		breakLeft = breakLength;
		$("#break-length").html(breakLength);
		}
	});
	$("#plus-break").click(function(){
		if( checkIfPaused!== 1 && breakLength<99){	//working only if timer is paused and breakLength is smaller than 100
		breakLength++;
		breakLeft = breakLength;
		$("#break-length").html(breakLength);
		}
	});	
	
// decrasing and incrasing session length

$("#session-length").html(sessionLength);
	$("#minus-session").click(function(){
		if(sessionLength>1 && checkIfPaused !== 1){		//working only if session length is bigger than 0 and timer is paused
		sessionLength--;
		timeLeft = sessionLength-1;
		$("#session-clock").html(timeLeft+1+":00");
		$("#session-length").html(sessionLength);
		}
	});
	$("#plus-session").click(function(){
		if(checkIfPaused !== 1 && sessionLength<99){	//working only if timer is paused and sessionLength is smaller than 100
		sessionLength++;
		timeLeft = sessionLength;
		timeLeft = sessionLength-1;
		$("#session-clock").html(timeLeft+1+":00");
		$("#session-length").html(sessionLength);
		}
	});
	
// --------- settings for length of break and session above this line ---------

function beep() {  //function that plays sound when timer reach 0
  audio.play();
}

// ----main function starts here---------

$(".pomodoro-box").click(function clock(){  //timer starts and stops when element is clicked

	if(checkIfPaused == 0){
		checkIfPaused = 1;
	} else {
		checkIfPaused = 0;
	}
		function timer(){ 
			if( checkIfPaused == 1){
				glower.addClass('active').removeClass('inactive'); // turning on glower after pause
				$("#session-clock").html((timeLeft)+":"+seconds);
				if(seconds<10 && seconds>0){
					$("#session-clock").html(timeLeft+":0"+seconds);
					seconds--;
				} else if(seconds === 0 && timeLeft>0){
					$("#session-clock").html(timeLeft+":"+"00");
					seconds--;
				} else if(seconds<0 && timeLeft>0){
					seconds = 59;
					timeLeft--;
					$("#session-clock").html(timeLeft+":"+seconds);
					seconds--;
				} else if(seconds==0 && timeLeft==0){
					beep();
					if(titleName == "Session"){ //if titleName is "Session" when timer reaching 0 changing it to "Break" and changing css to break mode
						breakLeft = breakLength;
						timeLeft = breakLength-1;
						seconds = 59;
						$(".pomodoro-box").addClass('pomodoro-box2').removeClass('pomodoro-box');
						$(".pomodoro-box.active").addClass('.pomodoro-box2.active').removeClass('.pomodoro-box.active');
						$("#session-text").html("Break");
						titleName = "Break";
					} else if(titleName == "Break") { //if titleName is "Break" when timer reaching 0 changing it to "Session" and changing css to session mode
						timeLeft = sessionLength-1;
						seconds = 59;
						$(".pomodoro-box2").addClass('pomodoro-box').removeClass('pomodoro-box2');
						$(".pomodoro-box2.active").addClass('.pomodoro-box.active').removeClass('.pomodoro-box2.active');
						$("#session-text").html("Session");
						titleName = "Session";
					}
					timer(); 
				} else{
					seconds--;
				}
			} else {
				clearInterval(refreshIntervalId);  //clearing interval for timer
				clearInterval(glo);	//clearing interval for glow
				glower.addClass('inactive').removeClass('active'); //reseting glower to default (inactive) state
			}
		};
				var glo = window.setInterval(function() {  //interval for glowing pomodoro-box
					glower.toggleClass('active');
				}, 500);
	
				var refreshIntervalId = setInterval(function(){	//interval for timer
					timer();
				}, 1000);
		
});	//onclick pomodoro-box ends here
	
$("#reset").click(function clock(){  //reset everything to default values
		
	breakLength = 5; 
	breakLeft = 5;	
	sessionLength = 25; 
	timeLeft = sessionLength-1; 
	seconds = 59;	
	checkIfPaused = 0; 
				$("#break-length").html(breakLength);
				$("#session-length").html(sessionLength);
				$(".pomodoro-box2").addClass('pomodoro-box').removeClass('pomodoro-box2');
				$(".pomodoro-box2.active").addClass('.pomodoro-box.active').removeClass('.pomodoro-box2.active');
				$("#session-text").html("Session");
				$("#session-clock").html(timeLeft+1+":00");
				glower.addClass('inactive').removeClass('active'); //reseting glower to default (inactive) state

});
	
});
	


            
          
!
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.
Loading ..................

Console