-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
81 lines (75 loc) · 2.56 KB
/
main.js
File metadata and controls
81 lines (75 loc) · 2.56 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
74
75
76
77
78
79
80
81
/**
* @title: Random Quote Generator
* @objective: Get a random quote whenever button is clicked
*/
var quoteArray = [
{
content: "Graphic design is building systems",
author: "Michael Stinson"
},
{
content: "I rarely agree with what clients ask me to do.",
author: "Ross Lovegrove"
},
{
content: "I think most programmers spend the first 5 years of their career mastering complexity, and the rest of their lives learning simplicity.",
author: "Buzz Andersen"
},
{
content: "Make it simple. Make it memorable. Make it inviting to look at. Make it fun to read.",
author: "Leo Burnett"
},
{
content: "What makes great design great is not a trendy technique, but the logic and conceptual aspect that were figured out in the designer's mind – or on more likely, on paper – before a mouse cursor ever opened Photoshop.",
author: "Kyle Meyer"
},
{
content: "Designers tend to whisper, ad agencies tend to shout.",
author: " David Stuart"
},
{
content: "Design is the method of putting form and content together. Design, just as art, has multiple definitions; there is no single definition. Design can be art. Design can be aesthetics. Design is so simple, that's why it is so complicated.",
author: "Paul Rand"
},
{
content: "Tell it like it is, in a way they want to hear it.",
author: "Wihan Meerholz"
},
{
content: "The best way to find any and all errors is to publish your work.",
author: "Dan Vore"
},
{
content: "Creativity is piercing the mundane to find the marvelous.",
author: "Bill Moyers"
},
{
content: "I warn you against believing that advertising is a science.",
author: "Bill Bernbach"
}
];
//grab html elements
var button = document.getElementById('new-quote'),
quote = document.getElementById('text'),
author = document.getElementById('author'),
tweet = document.getElementById('tweet-quote'),
thisQuote,
thisAuthor,
random;
//Generate a Random Quote
window.onload = randomQuote;
button.addEventListener('click', randomQuote);
//run the function so there are no double buttons happening
tweetQuote();
//random quote function
function randomQuote() {
//get a random number to pick a random quote object
random = Math.floor(Math.random() * quoteArray.length);
//get that random quote's content
quote.innerHTML = quoteArray[random].content;
//get that random quote's author
author.innerHTML = quoteArray[random].author;
thisQuote = quoteArray[random].content;
thisAuthor = quoteArray[random].author
tweet.setAttribute('href', `https://twitter.com/intent/tweet?text=${thisQuote} - ${thisAuthor}`, "_blank");
}