Skip to content

Instantly share code, notes, and snippets.

@mikehow1984
Created November 22, 2015 13:46
Show Gist options
  • Save mikehow1984/0316ff85837a987f6afb to your computer and use it in GitHub Desktop.
Save mikehow1984/0316ff85837a987f6afb to your computer and use it in GitHub Desktop.
Random Quote Page
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
</head>
<body>
<header>Random Quotes
</header>
<div id="desc">A collection of Mike's favorite quotes
</div>
<div id="button">
<input type="button" onclick="randQuote()" value="New Quote" />
</div>
<div id="quote-box">
<div id="quote">
</div>
<div id="author">
</div>
</div>
<div id="tweet">
<a id="tweet-button" href="" target="_blank">
<i class="fa fa-twitter-square"></i> Tweet This Quote</a>
</div>
</body>
var Quotes = [
["A banker is a fellow who lends you his umbrella when the sun is shining, but wants it back the minute it begins to rain.", "Mark Twain"],
["The trouble with the rat race is that even if you win, you're still a rat.", "Lily Tomlin"],
["It is necessary to try to surpass oneself always; this occupation ought to last as long as life.", "Queen Christina of Sweden"],
["You must learn from the mistakes of others. You can't possibly live long enough to make them all yourself.", "Sam Levenson"],
["Better by far you should forget and smile than you should remember and be sad.", "Christina Rossetti"],
["Get all the fools on your side and you can be elected to anything.", "Frank Dane"],
["What you do speaks so loud that I cannot hear what you say.", "Ralph Waldo Emerson"],
["The human brain starts working the moment you are born and never stops until you stand up to speak in public.", "George Jessel"],
["Some men are born mediocre, some men achieve mediocrity, and some men have mediocrity thrust upon them.", "Joseph Heller"],
["Genius is of no country.", "Charles Churchill"],
["A witty saying proves nothing.", "Voltaire"],
["Resolve to be thyself: and know, that he who finds himself, loses his misery.","Matthew Arnold"],
["Talent hits a target no one else can hit; Genius hits a target no one else can see.","Arthur Schopenhauer"],
["What counts is not necessarily the size of the dog in the fight - it's the size of the fight in the dog.","Dwight D. Eisenhower"],
["It is impossible to defeat an ignorant man in argument.","William G. McAdoo"]
];
var Q = Quotes.length;
var Tweet = document.getElementById("tweet-button");
var previousQuote = -1;
function randQuote() {
var currentQuote = Math.round(Math.random() * (Q - 1));
while(currentQuote == previousQuote){
currentQuote = Math.round(Math.random() * (Q - 1));
}
previousQuote = currentQuote;
document.getElementById("quote").innerHTML = Quotes[currentQuote][0];
document.getElementById("author").innerHTML = Quotes[currentQuote][1];
var twitterURL = "https://twitter.com/intent/tweet?text=" + document.getElementById("quote").innerHTML + " -" + document.getElementById("author").innerHTML;
twitterURL = twitterURL.replace(/;/g, '%3B');
Tweet.setAttribute("href", twitterURL);
}
window.onload = randQuote();
body {
background-color: cyan;
}
header{
font-size: 50px;
text-align: center;
}
#desc{
font-size: 24px;
text-align: center;
font-family: "Times New Roman", Verdana, Georgia, serif;
font-style: italic;
}
input {
text-align: center;
font-size: 24px;
margin: 10px 0px;
padding: 5px 30px;
text-align: center;
border: solid;
border-radius: 8px;
}
#button{
text-align: center;
font-family: Verdana, Georgia, serif;
}
#quote-box {
font-family: Georgia, serif;
padding: auto;
margin: auto;
width: 70%;
border: solid #000000;
text-align: center;
color: #000000;
background-color: #e0ffff;
}
#author{
font-style: italic;
margin: 5px 0px 0px 0px;
}
#tweet{
text-align: center;
margin: 10px;
}
#tweet-button{
text-align: center;
padding: 5px 10px;
text-decoration: none;
color: #000000;
border: solid;
background-color: gray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment