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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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="main">
		
		<div class="container">
			
			<div class="session-length">
				<div class="pomodoro-length">
					<p>Session Length</p>
					<button class="btn btn-count" id="pomodoro-plus-btn">+</button>
					<span class="pomodoro-minutes-count"></span>
					<button class="btn btn-count" id="pomodoro-minus-btn">-</button>
				</div>

				<div class="break-time-length">
					<p>Break Time</p>
					<button class="btn btn-count" id="break-plus-btn">+</button>
					<span class="break-minutes-count"></span>
					<button class="btn btn-count" id="break-minus-btn">-</button>
				</div>
			</div>

			<section class="clock">

				<div class="clock-timer" id="clock-timer">
					<span class="minutes"></span>:<span class="seconds"></span>
				</div>

				<div class="options">
					<button class="btn btn-control start-pomodoro">Start Pomodoro</button>
					<button class="btn btn-control break">Take a break</button>
					<button class="btn btn-control reset hidden">Reset</button>
				</div>			

			</section>			

		</div>

	</div>
              
            
!

CSS

              
                //Reset all browser styles

@import "compass/reset";

//Mixins

@mixin absoluteCenter {
	position: absolute;
	top: 30%;
	right: 0;
	bottom: 0;
	left: 0;
	margin: 0 auto;
}

@mixin btn-styles {
	text-align: center;
	border: 1px solid #7f8c8d;
	border-radius: 5px;
	background-color: #ECF0F1;
	font-weight: 600;
	color: #000;
}

//

body {
	background-color: #F1C40F;
}
  
  //Mobile Styles
  
  @media only screen and (max-width: 720px) {
    
    .clock {
			max-width: 100%;
		}

		.clock-timer {
			font-size: 7em !important;
		}

		.session-length {
			max-width: 100%;
			font-size: 1.5em !important;
		}

		.session-length .btn {
			width: 30px !important;
			height: 30px !important;
		}

		.btn-control {
			padding: 5px !important;
			margin: 80px 5px !important;
		}
	}

  //Desktop Styles

	.session-length .btn {
		width: 70px;
		height: 30px;
		text-align: center;	
		margin-top: 10px;
	}

	.clock {
		width: 500px;
		height: 150px;
		@include absoluteCenter;
		text-align: center;
    cursor: pointer;
	}

	.clock-timer {
		font-size: 12em;
		font-family: 'Lato', sans-serif;
	}

	.session-length {
		width: 500px;
		font-size: 2em;
		margin: 50px auto;
		text-align: center;
	}

	.pomodoro-length {
		float: left;
	}

	.break-time-length {
		float: right;
	}

	.btn-control {
		padding: 15px 35px; 
		margin-top: 80px;
		@include btn-styles;
		margin-left: 20px;
		margin-right: 20px;
    cursor: pointer;
	}

	.btn-control:hover {
		background-color: #F1C40F;
		color: #333;
	}

	.btn-count {
		@include btn-styles;
		padding: 5px 10px;
    cursor: pointer;
	}

	.reset:hover {
		background-color: transparent;
	}

	.hidden {
		display: none;
	}
	
              
            
!

JS

              
                $(document).ready(function () {

	//Set global variables

	var pomodoro = 25, currentTime = Date.parse(new Date()), deadline, timeInterval, breakTime = 5, i;

	//Display the clock

	var clock = document.getElementById("clock-timer");
	var minutesSpan = clock.querySelector(".minutes");
	var secondsSpan = clock.querySelector(".seconds");

	$(".pomodoro-minutes-count").html(pomodoro);
	$(".break-minutes-count").html(breakTime);
	minutesSpan.innerHTML = ("0" + pomodoro).slice(-2);
	secondsSpan.innerHTML = "00";

	//Customise length of each pomodoro

	$("#pomodoro-plus-btn").click(function () {
		pomodoro++;
		if (pomodoro > 60 ) {
			pomodoro = 60;
		}

		$(".pomodoro-minutes-count").html(pomodoro);
		minutesSpan.innerHTML = ("0" + pomodoro).slice(-2);
	});

	$("#pomodoro-minus-btn").click(function () {
		pomodoro--;
		if (pomodoro < 1) {
			pomodoro = 1;
		}
		$(".pomodoro-minutes-count").html(pomodoro);
		minutesSpan.innerHTML = ("0" + pomodoro).slice(-2);
	});

	//Customise break length

	$("#break-plus-btn").click(function () {
		breakTime++;
		if (breakTime > 15) {
			breakTime = 15;
		}
		$(".break-minutes-count").html(breakTime);
	});

	$("#break-minus-btn").click(function () {
		breakTime--;
		if (breakTime < 1) {
			breakTime = 1;
		}
		$(".break-minutes-count").html(breakTime);
	});

	//Calculate the time remaining
		
	function getTimeLeft (end) {
		var total = Date.parse(end) - Date.parse(new Date());
		var seconds = Math.floor((total/1000) % 60);
		var minutes = Math.floor((total/1000/60) % 60);

		return {
			"total": total,
			"minutes": minutes,
			"seconds": seconds
		};
	}

	//Initialize the timer

	function startClock () {
		timeInterval = setInterval(function () {
			var t = getTimeLeft(deadline);
			minutesSpan.innerHTML = ("0" + t.minutes).slice(-2);
			secondsSpan.innerHTML = ("0" + t.seconds).slice(-2);
			$("title").html(("0" + t.minutes).slice(-2) + ":" + ("0" + t.seconds).slice(-2));

			if (t.total <= 0) { //If timer reaches zero, stop the timer and reset the clock
				clearInterval(timeInterval);
				if (i === 0) {
					startBreak();
				}

				else if (i === 1) {
					startPomodoro();
				}
			}
		}, 1000);
	}

	//Functions for pomodoro, break and reset

	function startPomodoro () {
		minutesSpan.innerHTML = ("0" + pomodoro).slice(-2);
		secondsSpan.innerHTML = "00";
		$(".start-pomodoro, .break, .session-length").addClass('hidden');
		$(".reset").removeClass('hidden');
		$(".btn-count").prop("disabled", true);
		$("body").css('background-color', '#2ECC71');
		deadline = new Date(Date.parse(new Date()) + (pomodoro * 60 * 1000));
		startClock();
		i = 0;
	}

	function startBreak () {
		minutesSpan.innerHTML = ("0" + breakTime).slice(-2);
		secondsSpan.innerHTML = "00";
		$(".start-pomodoro, .break, .session-length").addClass('hidden');
		$(".reset").removeClass('hidden');
		$("body").css('background-color', '#3498DB');
		$(".btn-count").prop("disabled", true);
		deadline = new Date(Date.parse(new Date()) + (breakTime * 60 * 1000)); //Set deadline
		startClock();
		i = 1;
	}

	function resetClock () {
		$(".btn-count").prop("disabled", false);
		$("body").css('background-color', '#F1C40F');
		$(".start-pomodoro, .break, .session-length").removeClass('hidden');
		$(".reset").addClass('hidden');
		$(".minutes-count").html(pomodoro);
		$("title").html("Pomodoro")
		clearInterval(timeInterval);
		minutesSpan.innerHTML = ("0" + pomodoro).slice(-2);
		secondsSpan.innerHTML = "00";
		
	}

	//Start Pomodoro

	$(".start-pomodoro").click(function() {
		startPomodoro();
	});

	//Take a break 

	$(".break").click(function () {
		startBreak();
	});

	//Reset the clock

	$(".reset").click(function () {
		resetClock();
	});
		
});
              
            
!
999px

Console