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.

            
              <head>
  <title>Random quote machine</title>
</head>

<body class="text-center">


  <div class="container">
    <blockquote class="blockquote message">
      <p id="quote" class="quoteText">Click the left button to learn some life wisdom. Click the right button to tweet another. Enjoy!
      </p>
      <footer id="author" class="blockquote-footer quoteAuthor author">Radek</footer>
    </blockquote>
    <button type="button" id="quotebutton" onclick="quoteMachine()">Next quote</button>
    <button id="tweet" onclick="tweet()">Tweet quote</button>
    <div>


      <footer id="main_footer">
        Made by <a href="https://www.freecodecamp.com/radekjohn" target="_blank">Radek John</a> with use of <a href="https://forismatic.com/" target="_blank">Forismatic</a> API.
      </footer>

</body>
            
          
!
            
              body {
  font-family: Courier New, Courier, monotype;
  color: black;
}

a {
  color: #4949FF;
  text-decoration: none;
}

a:hover {
  color: #ffffff;
  background-color: #4949FF;
  text-decoration: none;
}

button {
  background-color: #ffffff;
  border: 1px dashed black;
  font-family: Courier New, Courier, monotype;
}


#main_footer {
  margin: 15%;
}

.container {
  margin-top: 15%;
}

.blockquote {
  border: none;
}
            
          
!
            
              // API address
var url = "https://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=jsonp&lang=en&jsonp=?";

// Quote machine
function quoteMachine() {
  // Read data from API  
  $.getJSON(url, function(data) {
    // Change no author to “Unknown”
    if (data.quoteAuthor === "") {
      data.quoteAuthor = 'Unknown';
    }
    // Get quote text from API
    $("#quote").html(data.quoteText);
    // Get quote author from API    
    $("#author").html(data.quoteAuthor);
  })
}

// Tweeting machine
function tweet() {
  // Read data from API  
  $.getJSON(url, function(data) {
    // Change no author to “Unknown”  
    if (data.quoteAuthor === "") {
      data.quoteAuthor = 'Unknown';
    }
    //Open Twitter window
    window.open('https://twitter.com/intent/tweet?text=' + data.quoteText + ' ' + '― ' + data.quoteAuthor);
  })
}
            
          
!
999px
Loading ..................

Console