-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
73 lines (61 loc) · 2.42 KB
/
main.js
File metadata and controls
73 lines (61 loc) · 2.42 KB
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
$(document).ready(function() {
function showQuote() {
/* Only code having to do with putting a quote on the screen.
This is just the function definition - it isn't called yet.
Don't put the click handler in here. */
var quotes = [
{
"quote" : "Keep your face always toward the sunshine—and shadows will fall behind you.",
"author" : " Walt Whitman"
},
{
"quote" : "It is always the simple that produces the marvelous.",
"author" : " Amelia Barr"
},
{
"quote" : "The world is full of magical things patiently waiting for our wits to grow sharper.",
"author" : " Bertrand Russell"
},
{
"quote" : "Let us make our future now, and let us make our dreams tomorrow’s reality.",
"author" : " Malala Yousafzai"
},
{
"quote" : "All you need is the plan, the road map, and the courage to press on to your destination.",
"author" : " Earl Nightingale"
},
{
"quote" : "The glow of one warm thought is to me worth more than money.",
"author" : " Thomas Jefferson"
},
{
"quote" : "Once we believe in ourselves, we can risk curiosity, wonder, spontaneous delight, or any experience that reveals the human spirit.",
"author" : " E. E. Cummings"
},
{
"quote" : "The power of imagination makes us infinite.",
"author" : " John Muir"
}
]
randomQuote = quotes[Math.floor(Math.random() * (quotes.length))];
document.getElementById("quotation").innerHTML = `“${randomQuote.quote}”`;
document.getElementById("author").innerHTML = ' -- ' + randomQuote.author;
//document.getElementById("quote_slider").innerHTML = randomQuote;
}
// this is a click handler - it won't fire until clicked
// it just sits there and listens for that click
$('.get-quote').on('click', function(event){
event.preventDefault();
showQuote(); // re-calling to put up new quote
});
// this is a click handler - it won't fire until clicked
// it just sits there and listens for that click
$('.share-quote').on('click', function(event) {
event.preventDefault();
var twitter = " \"" + randomQuote.quote + "\" " + ' -- ' + randomQuote.author;
window.open("https://twitter.com/intent/tweet?text=" + encodeURIComponent(twitter));
//window.open('https://twitter.com/intent/tweet?text=' + encodeURIComponent(randomQuote + ' -- '))
});
// this is the only part of code that will actually run at first
showQuote(); // Here we call the function to put the first quote up
});