123

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.

            
              <div class="container-fluid">
<div class="card text-center card-outline-muted quote-box">
<div class="row">
<div class="col-sm-10 offset-sm-1">
  <div class="h5 quote-text">
    <i class="fa fa-quote-left"></i> <span id="text"></span> <i class="fa fa-quote-right"></i>
  </div>
   <div class="lead quote-author">- <span id="author"></span> </div>
</div>
</div>
  <div class="row justify-content-between quote-box-button-group">
    <div class="col-sm-5 offset-sm-1">
    <a class="btn btn-danger quote-box-button" id="tweet-quote" title="Tweet this quote!" target="_blank"> <i class="fa fa-twitter"></i> Share</a>
    </div>
    <div class="col-sm-5 offset-sm-1">
      <button class="btn btn-danger quote-box-button" id="new-quote"> <i class="fa fa-refresh"></i> </button>
    </div>
  </div>
</div>
<div class="footer text-center"> by <a href="https://codepen.io/bitscaa/">Bitscaa</a></div>
</div>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Raleway:400,500);
@import url(https://fonts.googleapis.com/css?family=Lobster:400,500);

body {
  background: url("http://www.vectortiles.com/wp-content/uploads/sky-and-cloud-patterns-05-600x600.jpg") center center;
}

div .card {
  background: white;
}

.quote-box {
  margin: 5em 2em 2em 2em;
  padding: 2em;
}

.quote-text {
  font-family: "Raleway";
} 

.quote-author {
  font-family: "Lobster";
}

.quote-box-button-group {
  margin-top: 0.5em;
  margin-bottom: -0.5em;
}

.quote-box-button {
  margin: 0.5em;
}

.footer, .footer * {
  color: white;
}
            
          
!
            
              function inIframe() {
  try {
    return window.self !== window.top;
  } catch (e) {
    return true;
  }
}

var colors = ['#16a085', '#27ae60', '#2c3e50', '#f39c12', '#e74c3c', '#9b59b6', '#FB6964', '#342224', "#472E32", "#BDBB99", "#77B1A9", "#73A857"];

var currentQuote = '',
  currentAuthor = '';

function openURL(url) {
  window.open(url, 'Share');
}

function getQuote() {
  $.ajax({
    url: 'https://andruxnet-random-famous-quotes.p.mashape.com/?cat=famous',
    type: 'GET', // The HTTP Method, can be GET POST PUT DELETE etc
    data: {}, // Additional parameters here
    // dataType: 'json',
    success: function(response) {
      // var r = JSON.parse(response);
      var r = response;
      currentQuote = r.quote;
      currentAuthor = r.author;
      if (inIframe()) {
        $('#tweet-quote').attr('href', 'https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=' + encodeURIComponent('"' + currentQuote + '" ' + currentAuthor));
      }
      $(".quote-text").animate({
          opacity: 0
        },
        function() {
          $(this).animate({
            opacity: 1
          });
          $('#text').text(r.quote);
        });

      $(".quote-author").animate({
          opacity: 0
        },
        function() {
          $(this).animate({
            opacity: 1
          });
          $('#author').html(r.author);
        });

      var color = Math.floor(Math.random() * colors.length);
      $("html body").animate({
        // backgroundColor: colors[color],
        color: colors[color]
      }, 1000);
      $(".btn").animate({
        // backgroundColor: colors[color]
      }, 1000);

    },
    error: function(err) {
      alert(err);
    },
    beforeSend: function(xhr) {
      xhr.setRequestHeader("X-Mashape-Authorization", "OivH71yd3tmshl9YKzFH7BTzBVRQp1RaKLajsnafgL2aPsfP9V"); // Enter here your Mashape key   /* Key by Gabriel Nunes */
    }

  });
}

function getQuoteAnimatedDone() {
  $(".card").removeClass("animated bounceOut");
}

$(document).ready(function() {
  getQuote();
  $('#new-quote').on('click', function() {
    $(".card").addClass("animated bounceOut");
    setTimeout(function() { getQuote(); }, 1000);
    setTimeout(function() { getQuoteAnimatedDone(); }, 3000);
  });
  $('#tweet-quote').on('click', function() {
    openURL('https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=' + encodeURIComponent('"' + currentQuote + '" - ' + currentAuthor));
  });
  $('#tumblr-quote').on('click', function() {
    openURL('https://www.tumblr.com/widgets/share/tool?posttype=quote&tags=quotes,freecodecamp&caption=' + encodeURIComponent(currentAuthor) + '&content=' + encodeURIComponent(currentQuote));
  });
});
            
          
!
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.

Console