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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <!DOCTYPE>
<html>
<head>
    <title>Pomodoro Project by MuminjonGuru</title>
    <link rel="stylesheet" type="text/css" href="style.css">
    <link rel="stylesheet" type="text/css" href="animation.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel='stylesheet' href='https://use.fontawesome.com/releases/v5.7.0/css/all.css' integrity='sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ' crossorigin='anonymous'>
    <meta charset="UTF-8">
</head>
<body>
    <!-- Main Container -->          
    <div id="container">
        <div id="main">
            <h1 style="color:whitesmoke;">Pomodoro Technique</h1>    
            <div id="settings">
                <div id="settings-heading">
                    <div class="session"><h3>Session</h3></div>
                    <div><h3>Break</h3></div>
                </div>
                <div id="settings-input">
                    <i id="increase-session" class="fa fa-angle-up fa-2x button" title="Increase Session"></i>
                    <div id="session-minute"></div>
                    <i id="decrease-session" class="fa fa-angle-down fa-2x button" title="Decrease Session"></i>
                    <i id="increase-break" class="fa fa-angle-up fa-2x button" title="Increase Break"></i>
                    <div id="break-minute"></div>
                    <i id="decrease-break" class="fa fa-angle-down fa-2x button" title="Decrease Break"></i>
                </div>
            </div>

            <div id="clock">
                <div id="start-stop-reset-btns">
                    <i id="start" class="fa fa-play fa-2x button" title="Start Clock"></i>
                    <i id="reset" class="fa fa-sync-alt fa-2x button" title="Stop Clock & Reset Session & Break to 25 & 5"></i>
                </div>
                <div id="timer">
                    <div><h2 class="session" id="mode-indicator">Session</h2></div>
                    <div id="time"></div>
                </div>
                <div id="pause-stop-btns">
                    <i id="pause" class="fa fa-pause fa-2x button" title="Pause Clock"></i>
                    <i id="stop" class="fa fa-stop fa-2x button" title="Stop Clock"></i>
                </div>
            </div>
        </div>
    </div>
    <script src="script.js"></script>
    <script src="three.js"></script>
</body>
</html>
            
          
!

CSS

            
              html {
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: wheat;
}

body {
    background-color: #193c6d;
    filter: progid: DXImageTransform.Microsoft.gradient(gradientType=1, startColorstr='#003073', endColorstr='#029797');
    background-image: url(//img.alicdn.com/tps/TB1d.u8MXXXXXXuXFXXXXXXXXXX-1900-790.jpg);
    background-size: 100%;
    background-image: -webkit-gradient(linear, 0 0, 100% 100%, color-stop(0, #003073), color-stop(100%, #029797));
    background-image: -webkit-linear-gradient(135deg, #003073, #029797);
    background-image: -moz-linear-gradient(45deg, #003073, #029797);
    background-image: -ms-linear-gradient(45deg, #003073 0, #029797 100%);
    background-image: -o-linear-gradient(45deg, #003073, #029797);
    background-image: linear-gradient(135deg, #003073, #029797);
    text-align: center;
    margin: 0px;
    overflow: hidden;
}

#main {
    width: 50%;
    margin: 0 auto;
    text-align: center;
}

h1 {
    margin: 0;
    
}

#container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

#settings {
    background-color:navy;
    color: #FFF;
    width: 100%;
}

#settings-heading {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
}

#settings-heading .session {
    margin-right: 30px;
}

#settings-input {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 40px;
}

#settings-input div {
    font-size: 1.5em;
}

#start-stop-reset-btns {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    height: 40px;
}

#pause-stop-btns {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    height: 40px;
}

#timer {
    text-align: center;
}

#session-minute {
    text-align: center;
    width: 60px;
}

#break-minute {
    text-align: center;
    width: 60px;
}

.button {
    cursor: pointer;
}

#clock {
    margin-top: 15px;
    background-color: #000;
    color: #FFF;
    width: 100%;
    padding: 5px 0;
}

#start {
    margin-left: -35px;
}

#reset {
    margin-right: -45px;
}

#pause {
    margin-left: -35px;
}

#stop {
    margin-right: -45px;
}

#timer div {
    margin-bottom: 5px;
}

.session {
    margin: 0;
}

#time {
    margin: 0;
    font-size: 5em;
}
            
          
!

JS

            
              const mainBody = document.getElementById("main");
const modeIndicator = document.querySelector("#mode-indicator");

const hoverColor = (e) => e.target.classList.contains("button") ? e.target.style.color = "yellow": false;
const removeHoverColor = (e) => e.target.classList.contains("button") ? e.target.style.color = "white": false;
const addZeroPadding = (num) => "0" + num;
const updateSession = () => displaySessionMinute.textContent = sessionValue;
const updateBreak = () => displayBreakMinute.textContent = breakValue;

let sessionValue = 25;
const displaySessionMinute = document.getElementById("session-minute");
updateSession();
const IncreaseSessionBtn = document.getElementById("increase-session");
const DecreaseSessionBtn = document.getElementById("decrease-session");

let breakValue = 5;
const displayBreakMinute = document.getElementById("break-minute");
updateBreak();
const IncreaseBreakBtn = document.getElementById("increase-break");
const DecreaseBreakBtn = document.getElementById("decrease-break");

let timeValue = "25:00";
const displayTime = document.getElementById("time");
updateTimerDisplay();

function changeSessionTime(e) {
    const incrementSession = () => sessionValue += 1;
    const decrementSession = () => sessionValue -= 1;

    if (sessionValue == 1 && e.target.id == "increase-session") {
        incrementSession();
        updateSession();
    } else if (sessionValue == 1 && e.target.id == "decrease-session" || sessionValue == 1440 && e.target.id == "increase-session") {
        return;
    } else if (e.target.id == "increase-session") {
        incrementSession();
        updateSession();
    } else if (e.target.id == "decrease-session") {
        decrementSession();
        updateSession();
    } else {
        return;
    }
    convertNumberToTimer(sessionValue);
    updateTimerDisplay();
}

function pauseTimer(e) {
    if (e.target.id === "pause") {
        clearInterval(intervalID, 1000);
        mainBody.addEventListener("click", startTimer);
    } 
}

function startTimer(e) {
    if (e.target.id === "start") {
        intervalID = setInterval(updateTime, 1000);

        mainBody.removeEventListener("click", changeSessionTime);
        mainBody.removeEventListener("click", changeBreakTime);
        mainBody.removeEventListener("click", startTimer);
    }
}

function stopTimer(e) {
    if (e.target.id === "stop") {
        clearInterval(intervalID);
        convertNumberToTimer(sessionValue);
        updateTimerDisplay();
        modeIndicator.textContent = "Session";
        displayTime.removeAttribute("style");

        mainBody.addEventListener("click", changeSessionTime);
        mainBody.addEventListener("click", changeBreakTime);
        mainBody.addEventListener("click", startTimer);
        clearInterval(repeatBeep);
        NumberOfBeeps = 0;
    }
}

function updateTime() {
    timeArray = timeValue.split(":");
    hour = Math.floor(sessionValue / 60);

    countdownTimer();
    timeValue = timeArray.join(":");
    updateTimerDisplay();
    colorTimer();
    switchTimerMode();
}

function changeBreakTime(e) {
    const incrementBreak = () => breakValue += 1;
    const decrementBreak = () => breakValue -= 1;

    if (breakValue == 1 && e.target.id == "increase-break") {
        incrementBreak();
        updateBreak();
    } else if (breakValue == 1 && e.target.id == "decrease-break" || breakValue == 1440 && e.target.id == "increase-break") {
        return;
    } else if (e.target.id == "increase-break") {
        incrementBreak();
        updateBreak();
    } else if (e.target.id == "decrease-break") {
        decrementBreak();
        updateBreak();
    } else {
        return;
    }
}

function updateTimerDisplay() {
    displayTime.textContent = timeValue;
}

function displayZeroTime() {
    timeValue = "00:00";
    updateTimerDisplay();
}

function convertNumberToTimer(number) {
    let hours = Math.floor(number / 60);
    let minutes = number % 60;
    let digitalTime;
    let timeArr = [];
    
    if (number >= 1 && number <= 9) {
        digitalTime = addZeroPadding(number) + ":00";
        timeArr = digitalTime.split(":");
    } else if (number >= 10 && number <= 59) {
        digitalTime = number + ":00";
        timeArr = digitalTime.split(":");
    } else if (number >= 60) {
        timeArr[0] = addZeroPadding(hours);
        timeArr[2] = "00";
        if (minutes >= 0 && minutes <= 9 && hours >= 1 && hours <= 9) {
            timeArr[1] = addZeroPadding(minutes);
        } else if (minutes >= 10 && minutes <= 59 && hours >= 1 && hours <= 9) {
            timeArr[1] = minutes;
        } else if (hours >= 10) {
            timeArr[0] = hours;
            timeArr[2] = "00";
            if (minutes >= 0 && minutes <= 9) {
                timeArr[1] = addZeroPadding(minutes);
            } else if (minutes >= 10 && minutes <= 59) {
                timeArr[1] = minutes;
            }
        }
    }
    timeValue = timeArr.join(":");
    return timeValue;
}

function countdownTimer() {
    const seconds = timeArray[timeArray.length - 1];
    const minutes = timeArray[timeArray.length - 2];
    const hours = timeArray[timeArray.length - 3];

        if (seconds == "00" && minutes == "00" && hours == "01") {
            timeArray.shift();
            timeArray[timeArray.length - 2] = "59";
            timeArray[timeArray.length - 1] = "59";
        } else if (seconds == "00" && minutes == "00" && hours >= "02" && hours <= "09") {
            timeArray[timeArray.length -3] = addZeroPadding(hours - 1);
            timeArray[timeArray.length - 2] = "59";
            timeArray[timeArray.length - 1] = "59";
        } else if (seconds == "00" && minutes >= "11") {
            timeArray[timeArray.length - 1] = "59";
            timeArray[timeArray.length - 2] -= 1;
        } else if (seconds == "00" && minutes < 11) {
            timeArray[timeArray.length - 1] = "59";
            timeArray[timeArray.length - 2] = addZeroPadding(minutes - 1);
        } else if (seconds >= "11" && seconds <= "59") {
            timeArray[timeArray.length - 1] -= 1;
        } else if (seconds <= "10") {
            timeArray[timeArray.length - 1] = addZeroPadding(seconds - 1);
        }
}

function switchTimerMode() {
    if (timeValue.search(/\-/) > -1 && modeIndicator.textContent == "Session") {
        modeIndicator.textContent = "Break";
        changeAndStartTimerMode(breakValue);
    } else if (timeValue.search(/\-/) > -1 && modeIndicator.textContent == "Break") {
        modeIndicator.textContent = "Session";
        changeAndStartTimerMode(sessionValue);
    }
}

function colorTimer() {
    if (timeArray.length == 2 && timeArray[timeArray.length - 2] == 0 && timeArray[timeArray.length - 1] >= 0 && timeArray[timeArray.length - 1] <= 5) {
        displayTime.setAttribute("style", "color:red");  
    } else if (timeArray.length == 2 && timeArray[timeArray.length - 2] == 0 && timeArray[timeArray.length - 1] >= 6 && timeArray[timeArray.length - 1] <= 15) {
        displayTime.setAttribute("style", "color:yellow");
    } else {
        displayTime.setAttribute("style", "color:green");
    }
}

function changeAndStartTimerMode(value) {
    clearInterval(intervalID); 
    convertNumberToTimer(value);
    updateTimerDisplay();
    intervalID = setInterval(updateTime, 1000);
}

function resetToDefaultSettings(e) {
    if (e.target.id === "reset") {
        sessionValue = 25;
        updateSession();
        breakValue = 5;
        updateBreak();
        clearInterval(intervalID);
        convertNumberToTimer(sessionValue);
        updateTimerDisplay();
        modeIndicator.textContent = "Session";
        displayTime.removeAttribute("style");

        mainBody.addEventListener("click", changeSessionTime);
        mainBody.addEventListener("click", changeBreakTime);
        mainBody.addEventListener("click", startTimer);
    }
}

mainBody.addEventListener("mouseover", hoverColor);
mainBody.addEventListener("mouseout", removeHoverColor);
mainBody.addEventListener("click", changeSessionTime);
mainBody.addEventListener("click", changeBreakTime);
mainBody.addEventListener("click", startTimer);
mainBody.addEventListener("click", pauseTimer);
mainBody.addEventListener("click", stopTimer);
mainBody.addEventListener("click", resetToDefaultSettings);
            
          
!
999px

Console