css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

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.

            
              <head>
  <!-- importing font awesome icons --> 
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <!-- import jQuery --> 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
  <!-- import spell -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/4.7.1/bodymovin.min.js"></script>
</head>

<body>     
  <h1><strong> Random Quote Generator </strong></h1> 
  <div id="potter-animation"></div>
  <h2><button id="genQuote"> Cast a spell </button></h2>
  <a id="tweet" title="Tweet this quote!" target="_blank">
    <span><button class="fa fa-lg fa-twitter"></button></span>
  </a>
  <a id="facebook" title="Share this quote!" target="_blank">
    <span><button class="fa fa-lg fa-facebook"></button></span>
  </a>
  <div class="quoteContainer hide">
    <h3><div id="quote"></div></h3>
    <h4><strong><div id="character"></div></strong></h4>
  </div>
  <p> Inspired by <a href="https://codepen.io/abrahamrkj1/pen/MoEXYw" target="_blank"> Abraham K. </a><p>
  
<!-- The footer -->
<footer>
  <p>Copyright © Chris Jim 2017. All Rights Reserved</p>
  <div class="footerIcons">
    <p>
      <a href="mailto:chrisjim316@gmail.com"><i class="fa fa-envelope"></i></a>
      <a href="https://www.linkedin.com/in/chris-jim-77b090128/" target="_blank"><i class="fa fa-linkedin"></i></a>
      <a href="https://github.com/chrisjim316" target="_blank"><i class="fa fa-github"></i></a>
      <a href="https://www.quora.com/profile/Chris-Jim-1" target="_blank"><i class="fa fa-quora"></i></a>
      <a href="https://www.freecodecamp.com/chrisjim316" target="_blank"><i class="fa fa-free-code-camp"></i></a>
    </p>
  </div>
</footer>
  
</body> 

            
          
!
            
              body {
  background: url("https://github.com/chrisjim316/freeCodeCamp-/blob/master/Assets/Images/Random%20Quote%20Generator/defaultBackground.jpg?raw=true");
  background-size: cover;
  background-repeat: repeat-y;
  height: 600px;
  text-align: center; 
}

/* title */
h1 {
  font-size: 6em;
  top: 100px;
  position: relative;
  color: white; 
}
/* cast a spell button */
h2 {
  font-size: 2.5em;
}
/* quote */
h3 {
  font-size: 2em;
}
/* character */
h4 {
  font-size: 1.6em;
}
/* credits */
p {
  position: relative; 
  top: 300px;
  color: white;
}

.quoteContainer {
  background: white;
  opacity: .7;
  border-width: 5px;
  border-radius: 25px;
  width: 30%;
  padding-bottom: 10px;
  padding-top: 10px;
  margin-right: auto;
  margin-left: auto;
  top: 180px;
  position: relative;
}

#tweet {
  position: relative; 
  top: 160px;
}

#facebook {
  position: relative;
  top: 160px;
}

.hide {
  display: none;
}

#genQuote {
  position: relative;
  top: 160px;
}

/* spell customization */
#potter-animation {
  width: 100%;
  height: 100%;
  position: absolute;
  bottom: 50px;
}

footer {
  position: absolute;
  top: 550px;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 1rem;
  text-align: center;
  color: black;
}

/*mobile screens */
@media (max-width: 800px) and (min-width: 300px) {
  /* title */
  h1 {
    top: 70px;
    font-size: 3em;
  }
  /* cast a spell button */
  h2 {
    font-size: 2em;
  }
  /* quote */
  h3 {
    font-size: 1.1em;
  }
  /* character */
  h4 {
    font-size: 0.9em;
  }
  /* credits */
  p {
    top: 110px;
  }
  .quoteContainer {
    width: 70%;
  }
  body {
    height: 560px;
  }
  #genQuote {
    top: 90px;
  }
  .quoteContainer {
    top: 100px;
    padding-bottom: 5px;
    padding-top: 5px;
  }
  footer {
    top: 370px;
    font-size: 0.7em;
  }
  #tweet {
    top: 90px;
  }
  #facebook {
    top: 90px;
  }
}
            
          
!
            
              var tweetURL = "";
var facebookURL = "";

var quotes = [
  {quote: "Death is what gives life meaning. To know your days are numbered. Your time is short.", character: "The Ancient One"},
  {quote: "We never lose our demons, Mordo. We only learn to live above them.", character: "The Ancient One"},
  {quote: "Your work saved the lives of thousands. What if I told you that reality is one of many?", character: "The Ancient One"},
  {quote: "I spent so many years peering through time... looking at this exact moment. But I can't see past it.", character: "The Ancient One"},
  {quote: "Through the mystic arts, we harness energy and shape reality.", character: "The Ancient One"},
  {quote: "I never saw your future, only its possibilities.", character: "The Ancient One"},
  {quote: "The true purpose of a sorcerer is to twist things out of their proper shape. Stealing power. Perverting nature. Like you.", character: "Baron Mordo"},
  {quote: "Power has a purpose.", character: "Baron Mordo"},
  {quote: "Temporal manipulations can create branches in time. Unstable dimensional openings. Spatial paradoxes! Time loops!", character: "Baron Mordo"},
  {quote: "It's the Wi-Fi password. We're not savages.", character: "Baron Mordo"},
  {quote: "I'm fluent in Google Translate.", character: "Dr. Stephen Strange"},
  {quote: "Dormammu, I've come to bargain!", character: "Dr. Stephen Strange"},
  {quote: "The warnings come after the spells.", character: "Dr. Stephen Strange"},
  {quote: "Since you gave Kaecilius power from your dimension, I brought some power from mine. This is time. Endless, looped time!", character: "Dr. Stephen Strange"},
  {quote: "No. But I can lose. Again. And again. And again. Forever. That makes you my prisoner.", character: "Dr. Stephen Strange"},
  {quote: "While heroes like the Avengers protect the world from physical dangers, we sorcerers safeguard it against more mystical threats.", character: "Wong"},
  {quote: "*Laughs", character: "Wong"},
  {quote: "Word of the Ancient One's death will spread through the Multiverse. Earth has no Sorcerer Supreme to defend it. We must be ready.", character: "Wong"},
  {quote: "Stephen. Everything is about you.", character: "Christine Palmer"},
  {quote: "This isn't the end, there are other things that can give your life meaning.", character: "Christine Palmer"},
  {quote: "I call it the Strange technique.", character: "Christine Palmer"},
  {quote: "You are still in shock.", character: "Christine Palmer"},
  {quote: "People think in terms of good and evil, but really, time is the true enemy of us all. Time kills everything.", character: "Kaecilius"},
  {quote: "I am death, and pain!", character: "Kaecilius"},
  {quote: "You'll die protecting this world!", character: "Kaecilius"},
  {quote: "This world doesn't have to die, Mister Doctor. We can all live forever", character: "Kaecilius"},
  {quote: "But the Dark Dimension, it's a place beyond time. Beyond death.", character: "Kaecilius"}
];

$(document).ready(function() {
  $("#tweet").hide();
  $("#facebook").hide();
  $("#genQuote").on("click", function() { 
    $("div.quoteContainer").removeClass("hide");
    generateQuote();
    $("body").css("height", "500px");
    $("#tweet").show();
    $("#facebook").show();
  });
  
  $("#tweet").on("click", function () {
    tweetQuote();
  });
  
  $("#facebook").on("click", function() {
    shareQuote();
  });
});

function generateQuote() {
  randomQuote = quotes[parseInt(Math.random() * quotes.length)];
  var quote = randomQuote.quote;
  var character = randomQuote.character;
  $("#quote").text(quote);
  $("#character").text(character);
  getBackground(character); 
  spellAnimation.stop();
  spellAnimation.play(); 
  /* (% url encoding) %20 => space line %23 = hashtag */ 
  tweetURL = "https://twitter.com/intent/tweet?text=" + quote + "%0A-" + character + "%20%23quoteOfTheDay%20%23drstrange";
  facebookURL = "https://www.facebook.com/sharer/sharer.php?u="+escape("https://codepen.io/liljimbos/pen/JydZJX")+"&t="+document.title;
}

function tweetQuote() {
  $("#tweet").attr("href", tweetURL);
}

function shareQuote() {
  $("#facebook").attr("href", facebookURL);
}

function getBackground(character) {
  switch (character) {
      
    case "The Ancient One": 
      $("body").css("background-image", "url(https://user-images.githubusercontent.com/26378494/28656463-b7ec080a-72d4-11e7-8c16-319f5ea4879d.png)");
      $("h1").css("color", "white");
      break;
      
    case "Baron Mordo":
      $("body").css("background-image", "url(https://user-images.githubusercontent.com/26378494/28656464-b80256be-72d4-11e7-831a-2e98b9df8d9d.jpg)");
      $("h1").css("color", "white");
      break;
      
    case "Dr. Stephen Strange":
      $("body").css("background-image", "url(https://user-images.githubusercontent.com/26378494/28656460-b7c1eafc-72d4-11e7-9f84-4615ae5651e9.jpg)");
      $("h1").css("color", "white");
      break;
      
    case "Wong":
      $("body").css("background-image", "url(https://user-images.githubusercontent.com/26378494/28656459-b7c1b3ac-72d4-11e7-86a2-3fc4ff92fe93.jpg)");
      $("h1").css("color", "white");
      $("footer").css("top", "400px");
      break;
      
    case "Christine Palmer":
      $("body").css("background-image", "url(https://user-images.githubusercontent.com/26378494/28656462-b7eb39fc-72d4-11e7-92ab-6065929b70a9.jpg)");
      $("h1").css("color", "white");
      break;
      
    case "Kaecilius":
      $("body").css("background-image", "url(https://user-images.githubusercontent.com/26378494/28656465-b802f556-72d4-11e7-9ca2-78f6a8ad58d2.jpg)");
      $("h1").css("color", "black");
      break;
  }
}

/* spell customization */

var spellAnimation = bodymovin.loadAnimation({
  container: document.getElementById('potter-animation'),
  renderer: 'svg',
  loop: false,
  autoplay: false,
  path: 'https://raw.githubusercontent.com/abrahamrkj/facebook-spell/master/data.json'
})

/* mobile screens media query in JavaScript */
var mqls = [ // list of window.matchMedia() queries
    window.matchMedia("(min-width: 300px)"),
    window.matchMedia("(max-width: 800px)"),
];

if (mqls[0].matches && mqls[1].matches) {
  $("div.footerIcons").remove();
  // window width is at least 300px & window wiith is at most 800px; 
  function getBackground(character) {
    switch (character) {
      
      case "The Ancient One": 
        $("body").css("background-image", "url(https://github.com/iam-chrisjim/Images/blob/master/RandomQuote/AncientOne-mobile.jpg?raw=true)");
        break;
      
      case "Baron Mordo":
        $("body").css("background-image", "url(https://github.com/iam-chrisjim/Images/blob/master/RandomQuote/Mordo-mobile.jpg?raw=true)");
        $("body").css("color", "black");
        break;
      
      case "Dr. Stephen Strange":
        $("body").css("background-image", "url(https://github.com/iam-chrisjim/Images/blob/master/RandomQuote/Strange-mobile.jpg?raw=true)");
        break;
      
      case "Wong":
        $("body").css("background-image", "url(https://github.com/iam-chrisjim/Images/blob/master/RandomQuote/Wong-mobile.jpg?raw=true)");
        break;
      
      case "Christine Palmer":
        $("body").css("background-image", "url(https://github.com/iam-chrisjim/Images/blob/master/RandomQuote/Christine-mobile.jpg?raw=true)");
        $("body").css("color", "black");
        break;
      
      case "Kaecilius":
        $("body").css("background-image", "url(https://github.com/iam-chrisjim/Images/blob/master/RandomQuote/kaecilius-mobile.jpg?raw=true)");
        break;
    }
  }
} 

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console