-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
150 lines (138 loc) · 6.04 KB
/
index.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
const quotes = [
{ author: "placeholder", quotation: "placeholder quotation" },
{
author: "Kevin McCloud",
quotation:
"\"Every decently-made object, from a house to a lamp post to a bridge, spoon or egg cup, is not just a piece of 'stuff' but a physical embodiment of human energy, testimony to the magical ability of our species to take raw materials and turn them into things of use, value and beauty.\""
},
{
author: "Kevin McCloud",
quotation:
'"So, agricultural barn meets domestic dwelling. Magical mothership meets metal warehouse. Rational and clinical meets soft and soulful."'
},
{
author: "Kevin McCloud",
quotation:
"\"It's possible to be satisfied with a day's work or a cake, but a life... what is a life but a history of events badly remembered?\""
},
{
author: "Kevin McCloud",
quotation:
"\"Of course, there are many ways to work together, many ways to demonstrate that a building can be greater than the sum of its parts. That is doesn't need to be the result of one individual's dogma. And therein lies the brilliance of collaboration.\""
},
{
author: "Kevin McCloud",
quotation:
'"We are borrowing money from future generations. We are borrowing the carbon impact, the resource impact from future generations to get stuff cheap now. We have swept the dirt and dust from our society under the carpet - but this carpet is on other side of the planet."'
},
{
author: "Kevin McCloud",
quotation:
"\"How do you define modern family life? Well, I'd argue it's down to three things. A chaotic, relentless diary, plastic play furniture everywhere and a general anxiety about where the children are and what they're doing right now to each other.\""
},
{
author: "Kevin McCloud",
quotation:
'"You might baulk at the amounts of materials and energy that have gone into making it, but buildings don\'t just happen. They have to be willed, forced and wrangled into existence. And, in this case, its costs are incalculable, because the greatest amount of energy in a building like this, is human energy. At times, it even seems superhuman."'
},
{
author: "Kevin McCloud",
quotation:
'"After all, why, when life itself is defined by, bound up with, the ideas of craftsmanship and utility, by the acts of making and doing, why would you want it to ever end?"'
},
{
author: "Socrates",
quotation:
'"True wisdom comes to each of us when we realise how little we understand about life, ourselves, and the world around us."'
},
{
author: "Montgomery Burns",
quotation:
'"Family, religion, friendship. These are the three demons you must slay if you wish to succeed in business."'
},
{
author: "Des'Ree",
quotation:
"\"I don't want to see a ghost, it's a sight that I fear most. I'd rather have a piece of toast and watch the evening news.\""
},
{
author: "David Brent",
quotation:
"\"I don't look upon this like it's the end, I look upon it like it's moving on you know. It's almost like my work here's done. I can't imagine Jesus going 'Oh, I've told a few people in Bethlehem I'm the son of God, can I just stay here with Mum and Dad now?' No. You gotta move on. You gotta spread the word. You gotta go to Nazareth, please. And that's, very much like... me.\""
},
{
author: "Dalai Lama",
quotation:
'"People take different roads seeking fulfillment and happiness. Just because they’re not on your road doesn’t mean they’ve gotten lost."'
}
];
function randomInteger(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function getQuote(arr) {
let randomIndex = randomInteger(1, quotes.length - 1);
let randomQuote = arr[randomIndex];
return randomQuote;
}
const quoteButton = document.getElementById("getQuoteButton");
const quoteText = document.getElementById("quoteText");
const quoteContainer = document.getElementById("quoteContainer");
const pointCounter = document.getElementById("points-score");
const questionsCounter = document.getElementById("questions-total");
function appendQuote() {
let currentQuote = getQuote(quotes);
quoteText.textContent = currentQuote["quotation"];
currentQuoteAuthor = currentQuote["author"];
yesButton.textContent = "IT'S KEV";
noButton.textContent = "NOT KEV";
}
quoteButton.addEventListener("click", function (event) {
authorReveal.remove();
appendQuote();
quoteButton.textContent = "NEXT";
});
let currentQuoteAuthor;
let yesButton = document.getElementById("yes-button");
let noButton = document.getElementById("no-button");
let authorReveal = document.createElement("p");
yesButton.addEventListener("click", function (event) {
if (currentQuoteAuthor === "Kevin McCloud") {
yesButton.textContent = "CORRECT!";
numberCorrect++;
questionsAnswered++;
pointCounter.textContent = numberCorrect;
questionsCounter.textContent = questionsAnswered;
} else {
yesButton.textContent = "INCORRECT!";
authorReveal.setAttribute("id", "author-reveal");
authorReveal.textContent = currentQuoteAuthor;
quoteContainer.appendChild(authorReveal);
questionsAnswered++;
questionsCounter.textContent = questionsAnswered;
}
});
noButton.addEventListener("click", function (event) {
if (currentQuoteAuthor === "Kevin McCloud") {
noButton.textContent = "INCORRECT!";
questionsAnswered++;
questionsCounter.textContent = questionsAnswered;
} else {
noButton.textContent = "CORRECT!";
numberCorrect++;
pointCounter.textContent = numberCorrect;
authorReveal.setAttribute("id", "author-reveal");
authorReveal.textContent = currentQuoteAuthor;
quoteContainer.appendChild(authorReveal);
questionsAnswered++;
questionsCounter.textContent = questionsAnswered;
}
});
let numberCorrect = 0;
let questionsAnswered = 0;
let resetButton = document.getElementById("reset-button");
resetButton.addEventListener("click", function (event) {
numberCorrect = 0;
questionsAnswered = 0;
pointCounter.textContent = numberCorrect;
questionsCounter.textContent = questionsAnswered;
});