Created
March 19, 2018 16:38
-
-
Save jwgeller/37d0d6fc470eb53bd8df30dab3f5435b to your computer and use it in GitHub Desktop.
_Random Quote Generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| </head> | |
| <body> | |
| <p>to be similar in function to | |
| <a href="https://codepen.io/freeCodeCamp/full/ONjoLe" target="_blank">this CodePen project</a> | |
| </p> | |
| <div> | |
| <p id="quote"></p> | |
| <p id="author"></p> | |
| </div> | |
| <div> | |
| <button class="btn btn-default" onclick="getQuote()">New Quote</button> | |
| <a id="tweet-quote" href="" target="_blank"> | |
| <button class="btn btn-primary"><i class="fa fa-twitter"></i></button> | |
| </a> | |
| </div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| derived from original Code by Gabriel Nunes | |
| https://codepen.io/freeCodeCamp/pen/ONjoLe | |
| */ | |
| $(document).ready(function() { | |
| getQuote(); | |
| }); | |
| function getQuote() { | |
| $.ajax({ | |
| headers: { | |
| "X-Mashape-Key": "OivH71yd3tmshl9YKzFH7BTzBVRQp1RaKLajsnafgL2aPsfP9V", | |
| Accept: "application/json", | |
| "Content-Type": "application/x-www-form-urlencoded" | |
| }, | |
| url: 'https://andruxnet-random-famous-quotes.p.mashape.com/cat=', | |
| success: function(r) { | |
| if (typeof r === 'string') { | |
| r = JSON.parse(r); | |
| } | |
| $('#quote').text(r.quote); | |
| $('#author').text(r.author); | |
| $('#tweet-quote').attr( | |
| 'href', | |
| 'https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=' + | |
| encodeURIComponent('"' + r.quote + '" ' + r.author) | |
| ); | |
| } | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" /> | |
| <link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment