cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <div id="top">
  <div class="container"> 
<h1>Random Quote Generator</h1>
<h3>Free Code Camp project to retrieve a random quote from forismatic.com.</h3>
<p class="section"><button type="button" class="btn btn-primary btn-l btn-block" id="quoteButton">Generate quote</button></p>
<div class="container" id="quoteArea"></div>
<div id="tweetArea" style="text-align: right;">    
<a id="link1" href="https://twitter.com/intent/tweet" class="twitter-share-button"{count} data-text="" data-size = "large"></a>
    </div>
  </div>
</div>


            
          
!
            
              h1 {
  color: black;
    text-align: center;
  font-size: 400%;
}

h3 {
  color: black;
  font-size: 125%;
        text-align: center;  
  }
#quoteArea{
  text-align: center;
  font-size: 200%;
}

.right{
  text-align: right;
}

#top
{ width: 100%; height: 768px;
  background: url(http://www.richardkeightley.com/Images/quotewall.jpg) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

.section button {
  font-size: 30px;
  font-weight: 400;
}
            
          
!
            
              $(document).ready(function(){
  document.getElementById("quoteButton").addEventListener("click", getForiQuote);
});

// API call for forismatic
function getForiQuote(){
$.ajax({
    url: "https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp",
   jsonp: "jsonp",
   dataType: "jsonp"
})
  .done(update)
  .fail(handleError);
}

function update(responseText){
  document.getElementById("quoteArea").innerHTML = "\"" + responseText.quoteText + "\"<br> - " + responseText.quoteAuthor; 
}

function handleError(jqxhr, textStatus, err){
  console.log("Request failed: " + textStatus + ", " + err);
}

// vanilla JS... never got it to work
  /*
    var url = 'https://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en';
  var request = new XMLHttpRequest();
  request.open("GET", url, false);

  request.send();
  request = JSON.parse(request.responseText);
  */
  var theQuote = request.quoteText;
  var theAuthor = request.quoteAuthor;
 document.getElementById("quoteArea").innerHTML =  theQuote + " " + theAuthor;
  /*
  // this is the Twitter part
  var elem = document.getElementById("link1");
elem.setAttribute("data-text", elem.getAttribute("data-text") + theQuote + " " + theAuthor);
  window.twttr = (function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0],
    t = window.twttr || {};
  if (d.getElementById(id)) return t;
  js = d.createElement(s);
  js.id = id;
  js.src = "https://platform.twitter.com/widgets.js";
  fjs.parentNode.insertBefore(js, fjs);
 
  t._e = [];
  t.ready = function(f) {
    t._e.push(f);
  };
 
  return t;
}(document, "script", "twitter-wjs"));        */





            
          
!
999px
Loading ..................

Console