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

              
                <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>LOLCAT CLOCK</title>
    <link href="https://fonts.googleapis.com/css?family=Bungee|Bungee+Shade|Covered+By+Your+Grace" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:800" rel="stylesheet">
  <link rel="stylesheet" type="text/css" href="style.css">
<body>
    <div class="page">
        <header>
          <h1>LOLCAT CLOCK</h1>
        </header>
    
        <h4>
          I CAN HAZ TIME?? 
          <span id="clock">Clock goes here</span>
        </h4>
    
        <img id="lolcat" src="https://s3.amazonaws.com/media.skillcrush.com/skillcrush/wp-content/uploads/2016/08/normalTime.jpg" alt="lolcat">
    
        <blockquote id="timeEvent">This is where time events are reported</blockquote>
    
    
        set Wake Up Time
        <select id="wakeUpTimeSelector">
          <option value="1">1 AM - 2AM</option>
          <option value="2">2 AM - 3AM</option>
          <option value="3">3 AM - 4AM</option>
          <option value="4">4 AM - 5AM</option>
          <option value="5">5 AM - 6AM</option>
          <option value="6">6 AM - 7AM</option>
          <option value="7">7 AM - 8AM</option>
          <option value="8" selected>8 AM - 9AM</option>
          <option value="9">9 AM - 10AM</option>
          <option value="10">10 AM - 11AM</option>
          <option value="11">11 AM - 12PM</option>
          <option value="12">12 PM - 1PM</option>
          <option value="13">1 PM - 2PM</option>
          <option value="14">2 PM - 3PM</option>
          <option value="15">3 PM - 4PM</option>
          <option value="16">4 PM - 5PM</option>
          <option value="17">5 PM - 6PM</option>
          <option value="18">6 PM - 7PM</option>
          <option value="19">7 PM - 8PM</option>
          <option value="20">8 PM - 9PM</option>
          <option value="21">9 PM - 10PM</option>
          <option value="22">10 PM - 11PM</option>
          <option value="23">11 PM - 12AM</option>
          <option value="24">12 AM - 1AM</option>
        </select>
        
        set Lunch Time
          <select id="lunchTimeSelector">
            <option value="1">1 AM - 2AM</option>
            <option value="2">2 AM - 3AM</option>
            <option value="3">3 AM - 4AM</option>
            <option value="4">4 AM - 5AM</option>
            <option value="5">5 AM - 6AM</option>
            <option value="6">6 AM - 7AM</option>
            <option value="7">7 AM - 8AM</option>
            <option value="8">8 AM - 9AM</option>
            <option value="9">9 AM - 10AM</option>
            <option value="10">10 AM - 11AM</option>
            <option value="11">11 AM - 12PM</option>
            <option value="12" selected>12 PM - 1PM</option>
            <option value="13">1 PM - 2PM</option>
            <option value="14">2 PM - 3PM</option>
            <option value="15">3 PM - 4PM</option>
            <option value="16">4 PM - 5PM</option>
            <option value="17">5 PM - 6PM</option>
            <option value="18">6 PM - 7PM</option>
            <option value="19">7 PM - 8PM</option>
            <option value="20">8 PM - 9PM</option>
            <option value="21">9 PM - 10PM</option>
            <option value="22">10 PM - 11PM</option>
            <option value="23">11 PM - 12AM</option>
            <option value="24">12 AM - 1AM</option>
          </select>
        
        set Nap Time
        <select id="napTimeSelector">
          <option value="1">1 AM - 2AM</option>
          <option value="2">2 AM - 3AM</option>
          <option value="3">3 AM - 4AM</option>
          <option value="4">4 AM - 5AM</option>
          <option value="5">5 AM - 6AM</option>
          <option value="6">6 AM - 7AM</option>
          <option value="7">7 AM - 8AM</option>
          <option value="8">8 AM - 9AM</option>
          <option value="9">9 AM - 10AM</option>
          <option value="10">10 AM - 11AM</option>
          <option value="11">11 AM - 12PM</option>
          <option value="12">12 PM - 1PM</option>
          <option value="13">1 PM - 2PM</option>
          <option value="14">2 PM - 3PM</option>
          <option value="15" selected>3 PM - 4PM</option>
          <option value="16">4 PM - 5PM</option>
          <option value="17">5 PM - 6PM</option>
          <option value="18">6 PM - 7PM</option>
          <option value="19">7 PM - 8PM</option>
          <option value="20">8 PM - 9PM</option>
          <option value="21">9 PM - 10PM</option>
          <option value="22">10 PM - 11PM</option>
          <option value="23">11 PM - 12AM</option>
          <option value="24">12 AM - 1AM</option>
          </select>
        
        <button id="partyTimeButton">Party Time!</button>
    
        <footer>
          <p>&copy; 2020 <a href="https://adrianne.dev" target="_blank">Adrianne P.</a></p>
        </footer>
      </div>
    
      <script type="text/javascript" src="script.js"></script>
     
</body>
</html>
              
            
!

CSS

              
                body {
    background-color: #f16059;
  }
  .page {
    width: 80%;
    max-width: 960px;
    margin: 50px auto;
    text-align: center;
    background-color: #f16059;
    border-radius: 5px;
  }
  body {
    font: 14px/26px 'Bungee', Helvetica, Arial, sans-serif;
    color: #222;
    margin: 0px;
    padding: 0px;
    text-transform: uppercase;
  }
  header{
    font-size: 24px;
    line-height: 48px;
  }
  h4 {
    font-size: 21px;
    font-family: 'Bungee', cursive;
  }
  h4 #clock {
    font-size: 36px;
    display: block;
    padding: 5px 0px;
  }
  h1, h2, h3, h6 {
    font-family: 'Bungee Shade', cursive;
  }
  
  blockquote {
    font: 2em/1em 'Open Sans', sans-serif;
    -webkit-text-stroke: 1px black;
    text-shadow: 2px 2px #000;
    margin: -80px 0 100px 0;
    color: #fff;
  }
  
  blockquote:before { content: '"'; }
  blockquote:after { content: '"'; }
  
  #lolcat {
    margin: 0 auto;
    -webkit-border-radius: 100px;
    -moz-border-radius: 100px;
    border-radius: 10px;
    border:10px solid #222;
  }
  #wakeUpTimeSelector, #lunchTimeSelector, #napTimeSelector {
    padding: 10px 0;
  }
  #partyTimeButton {
    background-color: #222;
    width: 300px;
    font-family: 'Bungee', cursive;
    font-size: 18px;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 10px 0;
    margin-top: 20px;
  }
  
  footer p {
    text-transform: uppercase;
    font-size: 12px;
  }
  
              
            
!

JS

              
                var noon = 12;
var evening = 18; // 6PM
var wakeupTime = 9; // 9AM
var lunchTime = 12; // 12PM
var partyTime = 17; // 5PM
var napTime = lunchTime + 2; // 2PM
var time = new Date().getHours();

var partyTimeButton = document.getElementById("partyTimeButton");
var isPartyTime = false;
var wakeUpTimeSelector = document.getElementById("wakeUpTimeSelector");
var lunchTimeSelector = document.getElementById("lunchTimeSelector");
var napTimeSelector = document.getElementById("napTimeSelector");

var updateClock = function() {
    var lolcat = document.getElementById('lolcat'); // images
    var message = document.getElementById('timeEvent');
    var messageText;
    var catPic = "https://s3.amazonaws.com/media.skillcrush.com/skillcrush/wp-content/uploads/2016/08/wakeUpTime.jpg";

	if (time == partyTime){
	catPic = "https://s3.amazonaws.com/media.skillcrush.com/skillcrush/wp-content/uploads/2016/08/partyTime.jpg";
    messageText = "IZ PARTEE TIME!!";
} else if (time == napTime) {
	catPic = "https://s3.amazonaws.com/media.skillcrush.com/skillcrush/wp-content/uploads/2016/09/cat3.jpg";
    messageText = "IZ NAP TIME...";
} else if (time == lunchTime) {
	catPic = "https://s3.amazonaws.com/media.skillcrush.com/skillcrush/wp-content/uploads/2016/09/cat2.jpg";
    messageText = "IZ NOM NOM NOM TIME!!";
} else if (time == wakeupTime) {
	catPic = "https://s3.amazonaws.com/media.skillcrush.com/skillcrush/wp-content/uploads/2016/09/cat1.jpg";
    messageText = "IZ TIME TO GETTUP.";
} else if (time < noon) {
	messageText = "Good morning!";
} else if (time > evening) {
	messageText = "Good Evening!";
} else {
	messageText = "Good afternoon!";
}
  message.innerText = messageText;
  lolcat.src = catPic;
  showCurrentTime();
};

var showCurrentTime = function()
{
    // display the string on the webpage
    var clock = document.getElementById('clock');
 
    var currentTime = new Date();
 
    var hours = currentTime.getHours();
    var minutes = currentTime.getMinutes();
    var seconds = currentTime.getSeconds();
    var meridian = "AM";
 
    // Set hours 
    if (hours >= noon) 
    { 
        meridian = "PM"; 
    }  
    if (hours > noon) 
    { 
        hours = hours - 12; 
    }
 
    // Set Minutes
    if (minutes < 10)
    {
        minutes = "0" + minutes;
    }
 
    // Set Seconds
    if (seconds < 10)
    {
        seconds = "0" + seconds;
    }
 
    // put together the string that displays the time
    var clockTime = hours + ":" + minutes + ":" + seconds + " " + meridian + "!";
 
    clock.innerText = clockTime;
};

updateClock();

var oneSecond = 1000;
setInterval( updateClock, oneSecond);

var partyEvent = function() {
   
   if (isPartyTime === false) {
      isPartyTime = true;
      time = partyTime;
      // text in the button should read "Party Over"
	   partyTimeButton.innerText = "Party Over";
      // color of the button should be "#0A8DAB" (bonus!)
	   partyTimeButton.style.backgroundColor = "#0A8DAB";
   }
   else {
      isPartyTime = false;
      time = new Date().getHours();
      // text in the button should read "PARTY TIME!"
	   partyTimeButton.innerText = "PARTY TIME!";
      // color of the button should be "#222" (bonus!)
	   partyTimeButton.style.backgroundColor = "#222";
   }
};

var wakeUpEvent = function() {
	wakeupTime = wakeUpTimeSelector.value;	
};
var lunchTimeEvent = function() {
	lunchTime = lunchTimeSelector.value;	
};
var napTimeEvent = function() {
	napTime = napTimeSelector.value;	
};

partyTimeButton.addEventListener('click', partyEvent);
wakeUpTimeSelector.addEventListener('click', wakeUpEvent);
lunchTimeSelector.addEventListener('click', lunchTimeEvent);
napTimeSelector.addEventListener('click', napTimeEvent);
              
            
!
999px

Console