-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquotes.js
99 lines (81 loc) · 3.2 KB
/
quotes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
window.onload = function() {
displayQuote();
};
var lastQuote;
function selectQuote() {
var num = quotes.length - 1;
var quoteIndex = Math.floor(Math.random() * (num - 0 + 1)) + 0;
return quoteIndex;
};
function displayQuote() {
var quoteIndex = selectQuote();
if(quoteIndex == lastQuote) {
quoteIndex = selectQuote();
};
var selectedQuote = quotes[quoteIndex];
$("#quote").text('"' + selectedQuote.quote + '"' );
$("#author").text("- " + selectedQuote.author);
$(".twitter-share-button").attr("href", "https://twitter.com/intent/tweet?text=" + '"' + selectedQuote.quote + " - " + selectedQuote.author);
lastQuote = quoteIndex;
generateRGB();
console.log(quoteIndex);
};
// A better way to pick colors would be to have an array of colors to choose from
// This would ensure that the font is always readable on the background.
function generateRGB() {
var r = Math.floor(Math.random() * (255 - 0 + 1)) + 0;
var g = Math.floor(Math.random() * (255 - 0 + 1)) + 0;
var b = Math.floor(Math.random() * (255 - 0 + 1)) + 0;
var color = "rgb("+r+","+g+","+b+")";
$("body").css("background-color", color);
$("#quote").css("color", color);
$("#author").css("color", color);
$("#newQuote").css("background-color", color);
$("i").css("color", color);
};
var quotes = [
{
quote: "I have six locks on my door all in a row. When I go out, I lock every other one. I figure no matter how long somebody stands there picking the locks, they are always locking three.",
author: "Elayne Boosler"
},
{
quote: "Always borrow money from a pessimist. He won't expect it back.",
author: "Oscar Wilde"
},
{
quote: "The scientific theory I like best is that the rings of Saturn are composed entirely of lost airline luggage.",
author: "Mark Russell"
},
{
quote: "Friendship is like peeing on yourself: everyone can see it, but only you get the warm feeling that it brings.",
author: "Robert Bloch"
},
{
quote: "First the doctor told me the good news: I was going to have a disease named after me.",
author: "Steve Martin"
},
{
quote: "A successful man is one who makes more money than his wife can spend. A successful woman is one who can find such a man.",
author: "Lana Turner",
},
{
quote: "My therapist told me the way to achieve true inner peace is to finish what I start. So far I've finished two bags of M&Ms and a chocolate cake. I feel better already.",
author: "Dave Barry"
},
{
quote: "Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad.",
author: "Miles Kington"
},
{
quote: "I love deadlines. I like the whooshing sound they make as they fly by.",
author: "Douglas Adams"
},
{
quote: "By all means, marry. If you get a good wife, you'll become happy; if you get a bad one, you'll become a philosopher.",
author: "Socrates"
},
{
quote: "I asked God for a bike, but I know God doesn't work that way. So I stole a bike and asked for forgiveness.",
author: "Emo Philips"
}
];