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.

            
              <!-- Chess clock inspired Pomodoro timer
		 by Andrew Creech 2017 -->

<audio id="bell-sound" src="http://www.inkspilldesign.com/demo/bell.mp3" type="audio/mpeg"></audio>
<audio id="toggle-sound" src="http://www.inkspilldesign.com/demo/toggle.mp3" type="audio/mpeg"></audio>	

<div class="switches">
	<div id="work-switch"></div>
	<div id="break-switch" class="switch-down"></div>
</div>

<div class="clock">
	
		<h1>Pomodoro</h1>
		<hr />

		<div class="timers">
		
		<div class="work">
			<h2>WORK</h2>
			<div class="display">
				<span id="work-time">00:00</span>
			</div>
			<div class="work-settings">
				<button id="work-decrement">-</button>
				<div class="work-settings-display">
					<span id="set-work-time"></span>
				</div>
				<button id="work-increment">+</button>
			</div>
		</div>

		<div class="break">
			<h2>BREAK</h2>
			<div class="display">
				<span id="break-time">00:00</span>
			</div>
			<div class="break-settings">
				<button id="break-decrement">-</button>
				<div class="break-settings-display">
					<span id="set-break-time"></span>
				</div>
				<button id="break-increment">+</button>
			</div>
		</div>
	</div>
</div>
<div class="clock-base"></div>
<div class="clock-base"></div>
            
          
!
            
              /* Chess inspired Pomodoro timer
   by Andrew Creech 2017 */

@import url('https://fonts.googleapis.com/css?family=Lobster');

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100vh;
	background: #F3E6DE;
	background: linear-gradient(to bottom, rgba(243,230,222,1) 0%,rgba(192,178,165,1) 100%); 
	font-family: Sans-Serif;
	color: #333;
}

.switches {
	width: 600px;
	display: flex;
	justify-content: space-around;
	align-items: flex-end;
}

.switches div {
	width: 75px;
	height: 30px;
	background: #462411;
	background: linear-gradient(to bottom, rgba(70,36,17,1) 0%, rgba(70,36,17,1) 0%, rgba(128,66,33,1) 100%);
	border-top-left-radius: 10px;
	border-top-right-radius: 10px;
	border: 3px solid rgba(0,0,0,.4);
	border-top: 3px solid rgba(255, 199, 168,.8);
	border-bottom: none;
}
#work-switch:hover, #break-switch:hover, button:hover {
	cursor: pointer;
}

.switches .switch-down {
	height: 10px;
}

.clock {
	background: #9e683c;
	background-image: url(http://blogrope.com/wp-content/uploads/2013/06/003-wood-melamine-subttle-pattern-background-pat.jpg);
	box-shadow: inset 0 0 200px rgba(70,36,17,.5);
	width: 600px;
	height: 300px;
	border-top: 8px solid rgba(255,255,255,.2);
	border-left: 8px solid rgba(70,36,17,.6);
	border-right: 8px solid rgba(70,36,17,.6);
	border-bottom: 2px solid rgba(70,36,17,.6);
	border-top-left-radius: 50px;
	border-top-right-radius: 50px;
}

.clock h1 {
	text-align: center;
	font-family: 'Lobster', cursive;
	color: #462411;
	font-size: 60px;
}

hr {
	height: 0;
	border: transparent;
	border-top: 2px solid rgba(70,36,17,.6);
	border-bottom: 2px solid rgba(255,255,255,.2);
	margin-bottom: 10px;
}

.timers {
	display: flex;
	align-items: center;
	justify-content: space-around;
}

.timers h2 {
	text-align: center;
	color: #462411;
}

.display {
	width: 200px;
	height: 75px;
	background: white;
	margin-bottom: 20px;
	border-radius: 10px;
	border-top: 2px solid #C1C1C1;
	border-right: 2px solid #C1C1C1;
	border-bottom: 2px solid #FFF;
	border-left: 2px solid #FFF;
	background-color: #FFF;
	box-shadow: inset 0px 0px 10px #030303, inset 0px -35px 1px rgba(150, 150, 150, .2);
}

#work-time, #break-time {
	display: block;
	text-align: center;
	margin-top: 5px;
	font-size: 55px;
	font-weight: bold;
}

.work-settings, .break-settings {
	display: flex;
	align-items: center;
	justify-content: space-around;
}

.work-settings button, .break-settings button {
	position: relative;
	width: 50px;
	height: 25px;
	color: tan;
	font-size: 14px;
	background: #462411;
	background: linear-gradient(to bottom, rgba(70,36,17,1) 0%, rgba(70,36,17,1) 0%, rgba(128,66,33,1) 100%);
	border-radius: 20px;
	border: 1px solid rgba(0,0,0,.3);
	border-top: 2px solid rgba(255, 199, 168,.8);
	border-bottom-color: rgba(255, 199, 168,.4);
	box-shadow: 0 2px 5px rgba(0,0,0,.7);
	outline: none;
}
.work-settings button:active, .break-settings button:active {
	box-shadow: 0 1px 2px black;
	top: 1px;
}

.work-settings-display, .break-settings-display {
	width: 50px;
	height: 50px;
	background: white;
	border-radius: 10px;
	border-top: 2px solid #C1C1C1;
	border-right: 2px solid #C1C1C1;
	border-bottom: 2px solid #FFF;
	border-left: 2px solid #FFF;
	background-color: #FFF;
	box-shadow: inset 0px 0px 10px #030303, inset 0px -20px 1px rgba(150, 150, 150, .2);
}

#set-work-time, #set-break-time {
	display: block;
	text-align: center;
	font-weight: bold;
	font-size: 25px;
	margin-top: 7px;
}

.clock-base {
	height: 25px;
	width: 640px;
	border-top-left-radius: 20px;
	border-top-right-radius: 20px;
	border-top: 5px solid rgba(255,255,255,.2);
	border-left: 2px solid rgba(70,36,17,.5);
	border-right: 2px solid rgba(70,36,17,.5);
	border-bottom: 1px solid rgba(70,36,17,.5);
	background: #9e683c;
	background-image: url(http://blogrope.com/wp-content/uploads/2013/06/003-wood-melamine-subttle-pattern-background-pat.jpg);
}
.clock-base:last-of-type {
	width: 680px;
	height: 35px
}
            
          
!
            
              //////////////////////////////////////
// Chess clock inspired Pomodoro timer
// by Andrew Creech 2017
//////////////////////////////////////

$(document).ready(function(){
	// sounds
	var bellSound = $('#bell-sound')[0];
	var toggleSound = $('#toggle-sound')[0];
	
	// work timer variables
	var displayWorkTime = $('#work-time');
	var workTime = 25;
	var workSeconds = workTime * 60;
	var setWorkTime = $('#set-work-time');
	var workSwitch = $('#work-switch');
	
	// break timer varialbles
	var displayBreakTime = $('#break-time')
	var breakTime = 5;
	var breakSeconds = breakTime * 60;
	var setBreakTime = $('#set-break-time');
	var breakSwitch = $('#break-switch');
	
	var timer;
	
	// set default clock times
	setWorkTime.html(workTime);
	setBreakTime.html(breakTime);
	
	// increment & decrement buttons
	$('#work-decrement').click(function(){
		if(workTime > 1 ){
			workTime--;
		}
		setWorkTime.html(workTime);
		workSeconds = workTime * 60;
	});
	
	$('#work-increment').click(function(){
		if(workTime < 60 ){
			workTime++;
		}
		setWorkTime.html(workTime);
		workSeconds = workTime * 60;
	});
	
	$('#break-decrement').click(function(){
		if(breakTime > 1 ){
			breakTime--;
		}
		setBreakTime.html(breakTime);
		breakSeconds = breakTime * 60;
	});
	
		$('#break-increment').click(function(){
		if(breakTime < 60 ){
			breakTime++;
		}
		setBreakTime.html(breakTime);
		breakSeconds = breakTime * 60;
	});
	
	// startBreakTimer function
	var startBreakTimer = function(){
		breakSwitch.addClass('switch-down');
		workSwitch.removeClass('switch-down');
		var counter = 0;
		timer = setInterval(function(){
			counter++;
			displayBreakTime.html(formatTime(breakSeconds));
			if(breakSeconds < 1){
				resetTimer();
				toggleSound.play();
				bellSound.play();
				startWorkTimer();
				breakSeconds = counter;
			}
			breakSeconds--;
		},1000);
	};
	
	// startWorkTimer function
	var startWorkTimer = function(){
		workSwitch.addClass('switch-down');
		breakSwitch.removeClass('switch-down');
		var counter = 0;
		timer = setInterval(function(){
			counter++;
			displayWorkTime.html(formatTime(workSeconds));
			if(workSeconds < 1){
				resetTimer();
				toggleSound.play();
				bellSound.play();
				startBreakTimer();
				workSeconds = counter;
			}
			workSeconds--;
		},1000);
	};
	
	// Start button
	workSwitch.click(function(){
		if(timer === undefined){
			toggleSound.play();
			startWorkTimer();
		}
	});
	
	// Reset button
	breakSwitch.click(function(){
		toggleSound.play();
		breakSwitch.addClass('switch-down');
		workSwitch.removeClass('switch-down');
		resetTimer();
		displayWorkTime.html("00:00");
		displayBreakTime.html("00:00");
		breakSeconds = breakTime * 60;
		workSeconds = workTime * 60;
		
	});
	
	// resetTimer function
	var resetTimer = function(){
		clearTimeout(timer);
		timer = undefined;
	};
	
	// formatTime function
	var formatTime = function(seconds) {
		if (seconds < 60){
			seconds = ("0" + seconds).slice(-2);
			return  '00:' + seconds;
		}
		var minutes = Math.floor(seconds / 60);
		var remainingSeconds = seconds % 60;
		seconds = ("0" + remainingSeconds).slice(-2);
		minutes = ("00" + minutes).slice(-2);
		return minutes + ':' + seconds;
	};
	
});
            
          
!
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