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

              
                <div id="wrap">
  <div id="main" class="container clear-top text-center">
    <!-- quote card -->
    <div class="jumbotron">
      <blockquote class="blockquote-reverse">
        <i class="fa fa-quote-left fa-3x fa-pull-left" aria-hidden="true"></i>
        <p id="quoteText">...</p>
        <div id="quoteAuthor" class="quote-author"></div>
      </blockquote>
    </div><!-- jumbotron -->

    <!-- buttons -->
    <div class="container-fluid">
      <!-- warning icon -->
      <a id="warningIcon" href="#" title="There seem to be a problem loading the quote. Try again, or come back after a break." class="invisible">
        <span id="">
          <i class="fa fa-exclamation-triangle fa-1x" aria-hidden="true"></span></i>
      </a>
      <!-- refresh button -->
      <a id="refreshAnchor" href="#">
        <span id="refreshButton" class="fa-stack fa-lg fa-rw">
          <i class="fa fa-square-o fa-stack-2x"></i>
          <i id="spinButton" class="fa fa-refresh fa-stack-1x"></i>
        </span>
      </a>

      <!-- twitter button -->
      <a id="twitterButton" href="https://twitter.com/share" target="_blank">
        <span class="fa-stack fa-lg fa-rw">
          <i class="fa fa-square-o fa-stack-2x" aria-hidden="true"></i>
          <i class="fa fa-twitter fa-stack-1x" aria-hidden="true"></i>
        </span>
      </a>
    </div><!-- container-fluid -->
  </div><!-- container -->
</div><!--   wrap -->
  
<!-- footer -->
<footer class="bg-footer footer-app-colophon text-gray-light text-sm text-center">
  <p>Bootstrap Theme designed and coded with &nbsp;<i class="fa fa-star fa-1" title="love" aria-hidden="true"></i>&nbsp; by 
    <a href="https://codepen.io/lorepirri/full/WpBJKO/" title="lorepirri" target="_blank">me</a>
    :)</p>
</footer>

              
            
!

CSS

              
                  .container {
    padding: 70px 0px 70px 0px;
  }

  .jumbotron {
    background-color: #efab95;
    margin-left: 2%;
    margin-right: 2%;
    padding-bottom: 10px;
    margin-bottom: 10px;
  }

  .jumbotron p {
    color: #435071;
    font-size: 21px;
  }

  blockquote {
    color: #719ac1;
    font-size: 18px;
  }


  body {
    color: #435071;
    font-size: 14px;
    font-weight: 300;
    font-family: RobotoDraft, Roboto, sans-serif;
  }

  a {
    color: #435071;
    text-decoration: none;
  }
  a:hover {
    color: #719ac1;
    text-decoration: none;
  }

  .fa-twitter:hover {
    color: #1da1f2;
    text-decoration: none;
  }

  .fa-exclamation-triangle {
    color: orange;
    text-decoration: none;
  }

  a:-webkit-any-link{
  text-decoration:none !important;
  /* https://www.google.com/support/forum/p/Chrome/thread?tid=44100701f93d5951&hl=en */
  }

  footer {
    font-size: 14px;
    font-weight: 300;
    padding-top: 30px;
    padding-bottom: 30px;
    color: grey;
    position: relative;
    margin-top: -60px; /* negative value of footer height */
    height: 60px;
    clear:both;
    padding-top:20px;
  }

html, body {
  height: 100%;
}

#wrap {
  min-height: 100%;
}

#main {
  overflow:auto;
  padding-bottom:150px; /* this needs to be bigger than footer height*/
}

              
            
!

JS

              
                function fixedEncodeURIComponent(str) {
  return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
    return '%' + c.charCodeAt(0).toString(16);
  });
}

var defaultQuote = {"quoteText":"The key to growth is the introduction of higher dimensions of consciousness into our awareness. ", "quoteAuthor":"Lao Tzu", "senderName":"", "senderLink":"", "quoteLink":""}

function showWarning() {
    $("#warningIcon").toggleClass("invisible"); // show warning 
}
function hideWarning() {
    $("#warningIcon").addClass("invisible"); // hide warning
}
function waitForQuote() {
  $("#refreshAnchor").bind('click', false); // disable
  $("#spinButton").addClass('fa-spin'); // spin 
  hideWarning();
}
function readyQuote(thereWasAnError) {
  $("#refreshAnchor").unbind('click'); // enable
  $("#spinButton").toggleClass('fa-spin'); // stop spin 
  if (thereWasAnError) {
    showWarning();
  } else {
    hideWarning();
  }
}

function fetchRandomQuote() {
  
  waitForQuote(); // update UI
  
  // fetch the quote
  // in case of error, notify with an icon 
  // and return the default quote
  $.ajax({
    url: "https://crossorigin.me/https://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=json&lang=en",
    datatype: 'jsonp',
    error: function(err){
      console.log('error');
      readyQuote(true); // update UI
      setQuote(defaultQuote); // update UI
    },//error
    success: function(result){
      readyQuote(false); // update UI
      console.log('success!');
      setQuote(result); // update UI
    }//succes
  });
}

function setQuote(quote) {
  $("#quoteText").html(quote.quoteText);
  $("#quoteAuthor").html(quote.quoteAuthor);
  // generate URL
  var url = fixedEncodeURIComponent("https://codepen.io/lorepirri/pen/aJgMey");
  var text =  fixedEncodeURIComponent('"' + quote.quoteText + '" [' + quote.quoteAuthor + "]");
  
  var tweetURL = "https://twitter.com/share?url="+url+"&via=lorepirri&related=twitterapi%2Cfreecodecamp&hashtags=freecodecamp%2Crandomquotegenerator&text="+text;  
  // update link in the twitter button
  $("#twitterButton").attr('href', tweetURL);

  console.log("tweet set: " + tweetURL);  
}


$(document).ready(function() {
  // first quote
  //setQuote(firstQuote);
  fetchRandomQuote();
  
  $("#refreshButton").on("click", function() {
    fetchRandomQuote(); // fetch and update UI
    console.log("click!");
  });
  
});

              
            
!
999px

Console