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 id="endText" class="circle">03</div>

<div class="everything">
	<h1 id="title">Work Hard, Play Harder!!!</h1>
	<div>
		<h2 class="forColor">Break<span><input type="number" min="1" name="" id="theBreakTime" value="1"></span></h2>
	</div>
	<div>
		<h2 class="forColor" >Start..<span><input type="number" min="1" name="" id="theSessionTime" value="1"></span></h2>
	</div>
	<div id="theButtons">
		<button class="startAndReset">Start</button>
		<button class="playAndPause" disabled="">Pause</button>
	</div>
	<div id="timeSection">
		<h1 id="textDisplay">Work Hard</h1>	
		<h1 id="timeDisplay">00 : 01 : 00</h1>
	</div>
</div>
              
            
!

CSS

              
                body {
	background-image: url(https://source.unsplash.com/9HI8UJMSdZA);
	background-size: cover;
	background-position: center;
	color: white;
	font-family: 'Roboto Condensed', sans-serif;
}

html {
	height: 100%;
}

.everything {
    margin: auto;
    width: 50%;
    text-align: center;
    margin-top: 70px;
}

#title {
	font-family: 'Lobster', cursive;
	font-size: 50px;
	color: #c3130b
}

#textDisplay {
	font-family: 'Lobster', cursive;
	color: #c3130b	
}

#timeDisplay {
	font-size: 50px;
}

button {
	border: none;
	background: none;
	text-transform: uppercase;
	height: 100%;
	font-weight: 800;
	color: white;
	letter-spacing: 1px;
	font-size: inherit;
	outline: none;
}

#theButtons {
	background-color: black;
}

input {
    height: 20px;
    width: 50px;
}

span {
	padding-left: 20px;
}

#endText {
	font-size: 300px;
	text-align: center;
  	position: absolute;
  	left: 50%;
  	top: 50%;
  	-webkit-transform: translate(-50%, -50%);
  	transform: translate(-50%, -50%);
  	display: none;
  	color: black;
}

.circle {
  /*background-color: red;*/
  width: 350px;
  height: 350px;
  border-radius: 50%;
  border-width: 15px;
  /*border-color: black transparent transparent transparent;*/ /* 25% */
  /*border-color: black black transparent transparent;*/ /* 50% */
  /*border-color: black black black transparent;*/ /* 75% */
  /*border-color: black;*/ /* 100% */
  border-style: solid;
  transform: rotate(45deg);
}

#timeSection {
	border: 10px solid black;
}

img {
  width: auto ;
  max-width: 100% ;
  height: auto ;
}
              
            
!

JS

              
                var isPaused = false;
var sessionInt;
var breakInt;
var audio = new Audio('https://dl.dropboxusercontent.com/s/p61yqnij4fx3v0d/181148_3153523-lq%20%28mp3cut.net%29.mp3?dl=0');
var timer, hours, minutes, seconds;

var setSessionTimer = function (){ 
    timer = Number($("#theSessionTime").val())*60;
    document.body.style.backgroundImage = "url(https://source.unsplash.com/_UeY8aTI6d0)";
    fixBackgImage();
    sessionInt = setInterval(function(){
        if (!isPaused) {
            divideAssignTime();
            $("#textDisplay").html("Work Hard");
            if (--timer < 0) {
                clearInterval(sessionInt);
                setBreakTimer();
            } else if (hours === "00" && minutes === "00" && seconds === "05") {
                audio.play();
            } else if (hours === "00" && minutes === "00" && seconds === "03" || seconds==="02" || seconds==="01") {
                assignColorAndText();
            }
        }
    },1000);
}

var setBreakTimer = function (){ 
    timer = Number($("#theBreakTime").val())*60;
    document.body.style.backgroundImage = "url(https://source.unsplash.com/jp_hopLyOSU)";
    fixBackgImage()
    breakInt = setInterval(function(){
        if (!isPaused) {
            divideAssignTime();
            $("#textDisplay").html("Play Harder!!");            
            if (--timer < 0) {
                clearInterval(breakInt);
                setSessionTimer();
            } else if (hours === "00" && minutes === "00" && seconds === "05") {
                audio.play();
            } else if (hours === "00" && minutes === "00" && seconds === "03" || seconds==="02" || seconds==="01") {
                assignColorAndText();
            }           
        }
    },1000);
}

//for pause and play 
$('.playAndPause').on('click', function(e) {
    $("input").attr("disabled", true);
    if ($(this).html() === "Play") {
        $(this).html("Pause");
        e.preventDefault();
        isPaused = false;
    } else {
        e.preventDefault();
        $(this).html("Play"); 
        isPaused = true;
    }
});

//starting the countdown
$(".startAndReset").on("click", function(){
    if ($(this).html() === "Start") {
        $(this).html("Reset");
        $("input").attr("disabled", true);
        $('.playAndPause').removeAttr("disabled");
        isPaused = false;
        clearBoth();
        setSessionTimer();
    } else {
        reset();
    }
})

//checks for a change in the input section and displays it.. 
$('#theSessionTime').change(function() { 
    if ($("#textDisplay").html() === "Work Hard") {
        timer = Number($("#theSessionTime").val())*60;
        divideAssignTime();
        $("#timeDisplay").html(hours + " : " + minutes + " : " + "00");
    } else {
        timer = Number($("#theBreakTime").val())*60;
        divideAssignTime();
        $("#timeDisplay").html(hours + " : " + minutes + " : " + "00");       
    }
});

var colors = {
    01: "green",
    02: "yellow",
    03: "red"
}

var borderColors = {
    01: "black black black transparent",
    02: "black black transparent transparent",
    03: "black transparent transparent transparent"  
}

//assigns the color and text for the last 3 seconds
function assignColorAndText(){
    document.body.style.background = colors[Number(seconds)];
    $('#endText').show();
    $("#endText").html(seconds);
    $(".everything").hide();
    document.getElementById("endText").style.borderColor = borderColors[Number(seconds)];
}

//as the name implies..... :)
function reset(){
    document.body.style.backgroundImage = "url(https://source.unsplash.com/9HI8UJMSdZA)";
    $(".startAndReset").html("Start");
    $("input").val(1);
    clearBoth();
    isPaused = false;
    $("input").removeAttr("disabled");
    $('.playAndPause').removeAttr("disabled");
    $('.playAndPause').html("Pause");
    $("#timeDisplay").html("00 : 01 : 00")
}

//this fixes the background image cus after it changes, this style is removed from css
//i also added the hiding and showing of text here instead of making a new function
function fixBackgImage(){
    document.body.style.backgroundSize = "cover";
    document.body.style.backgroundPosition = "center";
    $('#endText').hide();
    $(".everything").show();
}

//divides the minutes to hours and seconds, assigns and displays it
function divideAssignTime() {
    hours = Math.floor(timer / 3600);
    minutes = Math.floor(timer % 3600 / 60);
    seconds = Math.floor(timer % 3600 % 60);
    hours = hours < 10 ? "0" + hours : hours;
    minutes = minutes < 10 ? "0" + minutes : minutes;
    seconds = seconds < 10 ? "0" + seconds : seconds;
    $("#timeDisplay").html(hours + " : " + minutes + " : " + seconds);
} 

// clearinterval 
function clearBoth(){
    clearInterval(sessionInt);
    clearInterval(breakInt);
}

// to be honest, i would probably do it with text, 
//have the text within the body tag, maybe have it display: none on css and 
//even give it transition to transform: scale , 
//so that it grows a little as it comes to the end of the second
              
            
!
999px

Console