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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                <!DOCTYPE html>
<html>
    <body>
        <div class="microwave-container">
            <div class="microwave">
                <div class="door-container">
                    <div class="door">
                        <div class="window-container">
                            <div class="window">
                                <div class="inside-light"> </div>
                            </div>
                        </div>
                        <div class="handle button" data-function="open">
                        </div>
                    </div>
                </div>
                <div class="control-panel-container">
                    <div class="control-panel">
                        <div class="clock">
                            <p id="time"></p>
                        </div>
                        <div class="controls">
                            <div class="control-row">
                                <div class="button" data-function="cook">
                                    <span>cook<br /><span class="smallText">time</span>
                                </div>
                                <div class="button">
                                    <span>timer</span>
                                </div>
                                <div class="button">
                                    <span>clock</span>
                                </div>
                            </div>
                            <div class="control-row">
                                <div class="button" data-function="popcorn">
                                    <span>popcorn</span>
                                </div>
                                <div class="button">
                                    <span>potato</span>
                                </div>
                                <div class="button">
                                    <span>beverage</span>
                                </div>
                            </div>
                            <div class="control-row">
                                <div class="button">
                                    <span>reheat</span>
                                </div>
                                <div class="button">
                                    <span>defrost</span>
                                </div>
                                <div class="button">
                                    <span>power</span>
                                </div>
                            </div>
                            <div class="control-row no-border">
                                <div class="button" data-function="one">
                                    <span>1</span>
                                </div>
                                <div class="button" data-function="two">
                                    <span>2</span>
                                </div>
                                <div class="button" data-function="three">
                                    <span>3</span>
                                </div>
                            </div>
                            <div class="control-row no-border">
                                <div class="button" data-function="four">
                                    <span>4</span>
                                </div>
                                <div class="button" data-function="five">
                                    <span>5</span>
                                </div>
                                <div class="button" data-function="six">
                                    <span>6</span>
                                </div>
                            </div>
                            <div class="control-row no-border">
                                <div class="button" data-function="seven">
                                    <span>7</span>
                                </div>
                                <div class="button" data-function="eight">
                                    <span>8</span>
                                </div>
                                <div class="button" data-function="nine">
                                    <span>9</span>
                                </div>
                            </div>
                            <div class="control-row no-border">
                                <div class="button" data-function="stop">
                                    <span>stop<br><span class="smallText">cancel</span></span>
                                </div>
                                <div class="button" data-function="zero">
                                    <span>0</span>
                                </div>
                                <div class="button" data-function="start">
                                    <span>start <br /><span class="smallText">+ 30 sec</span></span>
                                </div>
                            </div>

                            <div class="control-row no-border">
                                <div class="button">
                                    <span>exhaust<br /><span class="smallText">high - lo - off</span></span>
                                </div>
                                <div class="button">
                                    <span></span>
                                </div>
                                <div class="button" data-function="light">
                                    <span>light<br /><span class="smallText">on - off</span></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="light"> </div>
    </body>
    <footer>
        <script src="public/js/main.js"></script>
    </footer>
</html>
              
            
!

CSS

              
                html, body {
    display: flex;
    height: 100%;
    margin: 0 auto;
    flex-direction: column;
    justify-content: center;
}

.microwave-container{
    width: 1200px;
    height: 550px;
}

.microwave-container .microwave {
    width: 100%;
    height: 100%;
    background-color: grey;
    display: flex;
    border-radius: 10px;
}

.microwave-container .microwave .door-container {
    width: 80%;
    height: 100%;
}

.microwave-container .microwave .door-container .door {
    height: 100%;
    width: 100%;
    border-right: solid 7px black;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: relative;
}

.microwave-container .microwave .door-container .door .handle {
    position: absolute;
    height: 90%;
    width: 50px;
    background-color: silver;
    right: 2.5%;
    cursor: pointer;
}

.microwave-container .microwave .door-container .door .window-container {
    height: 80%;
    width: 95%;
    background-color:#000000d9;
    display: flex;
    align-items: center;
}

.microwave-container .microwave .door-container .door .window-container .window {
    height: 80%;
    width: 80%;
    background-color: silver;
    margin-left: 5%;
    background-image: url(https://i.ya-webdesign.com/images/comic-background-dots-png-5.png);
    background-repeat: no-repeat;
    background-size: cover;
    overflow: hidden;
}

.microwave-container .microwave .control-panel-container {
    width: 20%;
    height: 100%;
    display: flex;
    align-items: center;
}

.microwave-container .microwave .control-panel-container .control-panel {
    background-color: #000000d9;
    height: 80%;
    width: 90%;
}

.microwave-container .microwave .control-panel-container .control-panel .clock {
    height: 40px;
    width: 100%;
    text-align: center;
    color: green;
    font-family: monospace;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-panel .controls {
    width: 85%;
    height: 88%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.control-panel .controls .control-row {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

.control-panel .controls .control-row.no-border .button{
    border: none;
}

.control-panel .controls .control-row .button {
    width: 28%;
    font-size:11px;
    text-align: center;
    font-family: sans-serif;
    height: 30px;
    color: white;
    border: solid 1px white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.control-panel .controls .control-row .button span.smallText {
    font-size:6px;
}

.light {
    height: 0px;
    width: 80%;
    box-shadow: 0px 42px 92px 14px #ffd400;
    z-index: -1;
    display: none;
}

.inside-light {
    height: 0px;
    width: 100%;
    box-shadow: 0px 152px 1004px 84px #ffd40082;
    display: none;
}
              
            
!

JS

              
                var powerOn = false;
var readyForCookTime = false;
var currentDuration = 0;
var countDown;
var cookTime = '';
var paused = false;
var light = false;
var insideLight = false;

var clock = document.getElementById('time');
function setClock() {
    if (powerOn === false && readyForCookTime === false) {
        var t = moment().format('h:mm a');
        clock.textContent = t;
    }
}
setClock();
setInterval(setClock, 30000);


$('.button').on('click', function() {
    btnFunc = $(this).data('function');
    switch (btnFunc) {
        case 'popcorn':
            start('120');
            break;
        case 'stop':
            stop();
            break;
        case 'cook':
            if (!readyForCookTime && !powerOn) {
                readyForCookTime = true;
                clock.textContent = '00:00';
            }
            break;
        case 'one':
            setCookTime(1);
            break;
        case 'two':
            setCookTime(2);
            break;
        case 'three':
            setCookTime(3);
            break;
        case 'four':
            setCookTime(4);
            break;
        case 'five':
            setCookTime(5);
            break;
        case 'six':
            setCookTime(6);
            break;
        case 'seven':
            setCookTime(7);
            break;
        case 'eight':
            setCookTime(8);
            break;
        case 'nine':
            setCookTime(9);
            break;
        case 'zero':
            setCookTime(0);
            break;
        case 'start':
            start();
            break;
        case 'light':
            toggleLight();
            break;
        case 'open':
            stop();
            break;
    }

});

function start(duration) {
    if (!duration) {
        if (cookTime && currentDuration <= 0) {
            emptySpace = 4 - cookTime.length;
            var zeros = '';
            for (var i = 0; i < emptySpace; i++) {
                zeros += '0';
            }
            cookTime = zeros+cookTime;
            minutes = parseInt(cookTime.slice(0,2) * 60, 10);
            seconds = parseInt(cookTime.slice(2,4), 10) - 1;
            duration = minutes + seconds;
        } else if (paused && currentDuration > 0) {
            paused = false;
            duration = currentDuration;
        }
    }

    if (duration) {
        power();
        setTimer(duration); 
        readyForCookTime = false;
    }
}

function stop() {
    if (currentDuration > 0 && paused === false) {
        paused = true;
        clearInterval(countDown);
    } else if ((currentDuration > 0 && paused) || currentDuration <= 0) {
        power(false);
        paused = false;
        currentDuration = 0;
        cookTime = '';
        clearInterval(countDown);
        setClock();
    }
    toggleInsideLight(false);
}


function toggleLight() {
    if (light) {
        light = false;
        $('.light').hide();
    } else {
        light = true;
        $('.light').show();
    }
}

function toggleInsideLight(status = true) {
    if (status) {
        insideLight = true;
        $('.inside-light').show();
    } else {
        insideLight = false;
        $('.inside-light').hide();
    }
}

function power(status = true) {
    powerOn = status;
    toggleInsideLight(true);
}

function setCookTime(duration = null) {

    if (readyForCookTime) {
        duration = duration;
    } else {
        if (!paused) {
            start(duration * 60);
        }
        return;
    }

    for (var i = 4 - 1; i > 0; i--) {
        cookTime[i] = duration;
        cookTime = cookTime.substr(0, i) + duration + cookTime.substr(i + 1);
        break;
    }

    emptySpace = 4 - cookTime.length;

    var zeros = '';
    for (j = 0; j < emptySpace; j++) {
        zeros += '0';
    }

    displayCookTime = zeros + cookTime;

    var displayCookTime = displayCookTime.slice(0, 2) + ":" + displayCookTime.slice(2,4);

    clock.textContent = displayCookTime;
}


function setTimer(duration) {

    console.log(duration);
    currentDuration = duration;

    var timer = duration, minutes, seconds;
    countDown = setInterval(function () {

        currentDuration--;

        minutes = parseInt(timer / 60, 10)
        seconds = parseInt(timer % 60, 10);

        minutes = minutes < 10 ? "0" + minutes : minutes;
        seconds = seconds < 10 ? "0" + seconds : seconds;

        clock.textContent = minutes + ":" + seconds;

        if (--timer < 0) {
            power(false);
            cookTime = '';
            toggleInsideLight(false);
            clearInterval(countDown);
        }
    }, 1000);
}
              
            
!
999px

Console