A Pen by Sk. Imtiaz Ahmed on CodePen.
Created
October 13, 2016 11:38
-
-
Save excalliburbd/d21616e31769de580c35a4591c1ee684 to your computer and use it in GitHub Desktop.
Random Quote Machine -- FCC Zipline
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
| <div class="container"> | |
| <div class="jumbotron"> | |
| <h1 class="display-3">Random Quotes!</h1> | |
| <div class="card card-inverse card-info text-xs-center"> | |
| <div class="card-block"> | |
| <blockquote class="blockquote blockquote-reverse"> | |
| <p class="m-b-0">Loading...</p> | |
| <footer class="blockquote-footer"><cite title="Source Title"></cite></footer> | |
| </blockquote> | |
| </div> | |
| </div> | |
| <hr class="m-y-2"> | |
| <a class="btn btn-primary btn-lg" role="button">More</a> | |
| <a class="btn btn-info btn-lg" rol"button">Tweet</a> | |
| </div> | |
| </div> |
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
| $(document).ready(function() { | |
| var quoteNode = $('p'); | |
| var authorNode = $('cite'); | |
| var buttons = $('a'); | |
| quoteGen(quoteNode, authorNode); | |
| buttons.first().click(function() { | |
| history.go(0); | |
| }) | |
| buttons.last().click(function() { | |
| if (quoteNode.text().length > 140) { | |
| var limit = quoteNode.text().slice(0, 136) + "..."; | |
| } | |
| var tweet = limit || quoteNode.text(); | |
| window.open("https://twitter.com/intent/tweet?text=" + encodeURIComponent(tweet)); | |
| }) | |
| }); | |
| var quoteGen = function(quote, author) { | |
| var url = "http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=" | |
| $.getJSON(url, function(data) { | |
| quote.html(data[0].content); | |
| author.text(data[0].title); | |
| }); | |
| } |
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://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | |
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.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
| .blockquote{ | |
| border-right: 0; | |
| } |
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://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment