Random quote generator - Zipline task form FreeCodeCamp
Created
January 19, 2016 13:00
-
-
Save db001/91eb3202ce8b8537cd21 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 lang="en"> | |
<head> | |
<title>Random Quote Generator</title> | |
<link href='https://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'> | |
<link href='https://fonts.googleapis.com/css?family=Sigmar+One' rel='stylesheet' type='text/css'> | |
<link href='https://fonts.googleapis.com/css?family=Vollkorn' rel='stylesheet' type='text/css'> | |
</head> | |
<body> | |
<h1>Random Quote Generator</h1> | |
<button class="action-button shadow animate blue btn" alt="Click here for a quote">Click here for a quote</button> | |
<div class="container"> | |
<p id="quote"></p> | |
<p id="person"></p> | |
</div> | |
<a class="twit-button" href="https://twitter.com/intent/tweet" | |
target="_blank"><img src="https://goo.gl/Ad3QRL" alt="Tweet this"></a> | |
</body> |
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() { | |
$('.btn').on('click', function() { | |
var randnum = Math.floor(Math.random() * 20); | |
text = Object.keys(quotes)[randnum]; | |
textee = quotes[text]; | |
$('#quote').empty(); | |
$('#person').empty(); | |
$('<p>"' + text + '"</p>').appendTo('#quote'); | |
$('<p>- ' + textee + '</p>').appendTo('#person'); | |
}); | |
$('a.twit-button').on('click', function() { | |
$('a.twit-button').each(function() { | |
$(this).attr('href', "https://twitter.com/intent/tweet"); | |
var href = $(this).attr('href'); | |
$(this).attr('href', href + "?text=" + text + "%20%2D%20" + textee); | |
}); | |
}); | |
}); | |
// 20 quotes | |
var quotes = { | |
'There is no abstract art. You must always start with something. Afterward you can remove all traces of reality.': 'Pablo Picasso', | |
'Artists who seek perfection in everything are those who cannot attain it in anything.': 'Eugene Delacroix', | |
'It was on my fifth birthday that Papa put his hand on my shoulder and said, "Remember, my son, if you ever need a helping hand, you\'ll find one at the end of your arm."': 'Sam Levenson', | |
'Never judge a book by its movie.': 'J. W. Eagan', | |
'We have really everything in common with America nowadays except, of course, language.': 'Oscar Wilde', | |
'Accomplishing the impossible means only that the boss will add it to your regular duties.': 'Doug Larson', | |
'All science is either physics or stamp collecting.': 'Ernest Rutherford', | |
'Do not be awe struck by other people and try to copy them. Nobody can be you as efficiently as you can.': 'Norman Vincent Peale', | |
'You don\'t have to be famous. You just have to make your mother and father proud of you.': 'Meryl Streep', | |
'We are always in search of the redeeming formula, the crystallizing thought.': 'Etty Hillesum', | |
'Experience is a hard teacher because she gives the test first, the lesson afterwards.': 'Vernon Sanders Law', | |
'When other people reject positive changes you make for yourself, there is always some nerve to get to the root of in those other people.': 'Jennifer Hudson', | |
'I\'m convinced there\'s a small room in the attic of the Foreign Office where future diplomats are taught to stammer.': 'Peter Ustinov', | |
'Drink nothing without seeing it; sign nothing without reading it.': 'Spanish Proverb', | |
'This is my favorite book in all the world, though I have never read it.': 'William Goldman, The Princess Bride', | |
'A classic is something that everybody wants to have read and nobody wants to read.': 'Mark Twain', | |
'I would visualize things coming to me. It would just make me feel better. Visualization works if you work hard. That\'s the thing. You can\'t just visualize and go eat a sandwich.': 'Jim Carrey', | |
'Those who flee temptation generally leave a forwarding address.': 'Lane Olinghouse', | |
'I have not lost my mind - it\'s backed up on disk somewhere.': 'Unknown', | |
'Cheese - milk\'s leap toward immortality.': 'Clifton Fadiman', | |
}; | |
/* | |
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")); | |
*/ |
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="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/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
body { | |
text-align: center; | |
} | |
h1 { | |
font-family: 'Sigmar One', cursive; | |
font-size: 3em; | |
} | |
.animate { | |
transition: all 0.1s; | |
-webkit-transition: all 0.1s; | |
} | |
.action-button { | |
padding: 10px 40px; | |
margin: auto; | |
border-radius: 10px; | |
font-family: 'Pacifico', cursive; | |
font-size: 25px; | |
color: #FFF; | |
text-decoration: none; | |
} | |
.blue { | |
background-color: #3498DB; | |
border-bottom: 5px solid #2980B9; | |
text-shadow: 0px -2px #2980B9; | |
} | |
.container { | |
margin: auto; | |
width: 60%; | |
} | |
#quote { | |
font-family: "Pacifico", cursive; | |
font-size: 2em; | |
} | |
#person { | |
font-family: 'Vollkorn', serif; | |
font-size: 1.5em; | |
padding-left: 20em; | |
} | |
.twit-button img { | |
width: 175px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment