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>
  <head>
    <title>Wisdom Generator</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  </head>
  <body>
    <section class="container text-center">
      <h1>Wisdom Generator</h1>
      <div class="row">
        <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1 col-sm-12 col-xs-12">
          <div class="panel panel-default">
            <h3 id="quote" class="colored"></h3>
            <h4 id="author" class="colored"></h4>
            <div class="btn-toolbar" >
              <div class="btn-group">
                <button id="twitterButton" class="btn btn-default btn-social"><i class="fa fa-twitter"></i></button>
                <button id="newQuoteButton" class="btn btn-default btn-social">New Wisdom</button>
              </div>
            </div>
          </div>
        </div>
       </div>
      </div>
    </section>
    <script src="https://code.jquery.com/jquery.js"></script>    
  </body>
</html>
              
            
!

CSS

              
                  /* pacifico font */
@import url(https://fonts.googleapis.com/css?family=Pacifico);
body{
  -webkit-transition: background-color 1.5s;
  -moz-transition: background-color 1.5s;
  -o-transition: background-color 1.5s;
  transition: background-color 1.5s;
}
h1 {
    font-family: 'Pacifico', serif;
    font-size: 4em;
    color: white;
    margin:0.5em;
    text-shadow:2px 2px #222;
}
button{
  color: white;
  -webkit-transition: background-color 1.5s;
  -moz-transition: background-color 1.5s;
  -ms-transition: background-color 1.5s;
  -o-transition: background-color 1.5s;
  transition: background-color 1.5s;
}
.colored{
    -webkit-transition: color 1.5s;
    -moz-transition: color 1.5s;
    -ms-transition: color 1.5s;
    -o-transition: color 1.5s;
    transition: color 1.5s;
}
.btn-social{
  color: white;
  border-color: white;
}
#quote, #author{
  padding: 0.25em;
}
button:focus, button:active{
  outline: 0 !important;
}
              
            
!

JS

              
                // Color array for sorting background colors
var colors = ["#ffcc66","#ff6666","#666699","#999966","#009999","#cc00ff"];
var currentColor = colors[0];

// API URLs initialization:
// Quotes are retrieved from Forismatic.com ...
var forismaticURL = "https://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=jsonp&jsonp=?&lang=en";

// And can be sent to Twitter
var twitterURL = "https://twitter.com/intent/tweet?hashtags=WisdomGenerator&related=freecodecamp&text=";

// Variables to keep tracking of the current Quote and Author
var currentQuote;
var currentAuthor;

// As soon as the page loads, generate new quote
$(document).ready( function(){ NewQuote(); });

// Whenever the "New Quote" button is pressed, generate new quote
$("#newQuoteButton").on("click",function(){ NewQuote(); });
  
// When "Twitter" button is pressed, open new window with the current quote and author.
$("#twitterButton").on("click",function(){ window.open(twitterURL + '"' + currentQuote + '"- '+ currentAuthor); });

// To generate a new quote ...
function NewQuote(){
  // retrieve a quote from Forismatic.com into a JSON
  $.getJSON(forismaticURL, function(JSON){
    
    // and set the current quote and author to our variables
    currentQuote = JSON.quoteText; 
    currentAuthor = JSON.quoteAuthor;
  
    // if the author is unknown (empty string returned) then we'll display "Unknown Author"
    if(currentAuthor == "") currentAuthor= "Unknown Author";
  
    Animate();
    ChangeColor();
    SetQuote();
  });
}

// to animate the elements in the page ...
function Animate(){
    // add the "Fade In Down" animation class from Animation.css to them ...
    $("#quote").addClass("animated fadeInDown");
    $("#author").addClass("animated fadeInDown");
    
    // wait for the animation to be over ...
    window.setTimeout(function(){
      // and remove them
      $("#quote").removeClass("animated fadeInDown");
      $("#author").removeClass("animated fadeInDown");
    }, 800);
}

// to change the color of the elements
function ChangeColor(){
  // choose randomly a color from the colors array.
  currentColor = colors[Math.floor(Math.random() * colors.length)];
    
    // set the choosen color to the body, button and colored elements
    $("body").css("background-color",currentColor);
    $("button").css("background-color",currentColor);
    $(".colored").css("color",currentColor);
}

// to set (show) the quote to the user ...
function SetQuote (){
  
  // change the html inside the quote and author elements to the current quote (inside brackets - Awesome Font) and author variables
  $("#quote").html( '<i class="fa fa-quote-left"></i> '+ currentQuote + ' <i class="fa fa-quote-right"></i>')
  $("#author").html('- ' + currentAuthor);  
}
              
            
!
999px

Console