-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
166 lines (148 loc) · 6.08 KB
/
index.html
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap" rel="stylesheet">
<link href="styles.css" rel="stylesheet">
<title>Trivia!</title>
<script>
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
};
function checkFirst(id) {
let cont = document.querySelector('#btn-cnt');
var childs = cont.children;
for (let i = 0; i < childs.length; i++)
{
var child = childs[i];
child.className = "";
}
let btn = document.getElementById("1-" + id);
if (id == Math.round(Math.pow(125, (1/3))))
{
btn.classList.add("correct");
setHint("hint_1", "correct");
}
else
{
btn.classList.add("incorrect");
setHint("hint_1", "incorrect");
}
}
function checkSecond(id) {
let cont = document.querySelector('#btn-cnt-2');
var childs = cont.children;
for (let i = 0; i < childs.length; i++)
{
var child = childs[i];
child.className = "";
}
let btn = document.getElementById("2-" + id);
if (id == Math.round((29414 / 1337) / 11))
{
btn.classList.add("correct");
setHint("hint_4", "correct");
}
else
{
btn.classList.add("incorrect");
setHint("hint_4", "incorrect");
}
}
function setHint(obj_id, val) {
var hint = document.querySelector('#' + obj_id);
while( hint.firstChild ) {
hint.removeChild( hint.firstChild );
}
hint.hidden = false;
hint.className = "";
hint.classList.add(val + "-span");
hint.appendChild( document.createTextNode(val.capitalize()) );
}
function checkFreeFirst() {
var input = document.querySelector('#answer-1');
var answer = input.value;
if (btoa(answer) == "U2Ftc3VuZw==") // don't make it toooo obvious
{
input.className = "";
input.classList.add("correct");
setHint("hint_2", "correct");
}
else
{
input.className = "";
input.classList.add("incorrect");
setHint("hint_2", "incorrect");
}
}
function checkFreeSecond() {
var input = document.querySelector('#answer-2');
var answer = input.value;
if (btoa(answer) == "TWFyaWUgQ3VyaWU=") // don't make it toooo obvious
{
input.className = "";
input.classList.add("correct");
setHint("hint_3", "correct");
}
else
{
input.className = "";
input.classList.add("incorrect");
setHint("hint_3", "incorrect");
}
}
</script>
</head>
<body>
<div class="jumbotron">
<h1>Trivia!</h1>
</div>
<div class="container">
<div class="section">
<h2>Part 1: Multiple Choice </h2>
<hr>
<h3>What is "anatidaephobia"?</h3>
<span id="hint_1" hidden></span>
<div id="btn-cnt">
<button id="1-1" onclick="checkFirst(1)">Fear of Dogs</button>
<button id="1-4" onclick="checkFirst(4)">Fear of Cars</button>
<button id="1-2" onclick="checkFirst(2)">Fear of Cats</button>
<button id="1-5" onclick="checkFirst(5)">Fear of being watched by ducks</button>
<button id="1-3" onclick="checkFirst(3)">Fear of Horses</button>
</div>
</div>
<div class="section">
<h2>Part 2: Free Response</h2>
<hr>
<h3>What is the name of the biggest technology company in South Korea?</h3>
<span id="hint_2" hidden></span>
<div class="flex">
<input type="text" id="answer-1">
<button id="submit-1" onclick="checkFreeFirst()" style="margin-left: 16px;">Check Awnser</button>
</div>
</div>
<div class="section">
<h2>Part 3: Another Free Response</h2>
<hr>
<h3>Who was the first woman to win a Nobel Prize (in 1903)?</h3>
<span id="hint_3" hidden></span>
<div class="flex">
<input type="text" id="answer-2">
<button id="submit-2" onclick="checkFreeSecond()" style="margin-left: 16px;">Check Awnser</button>
</div>
</div>
<div class="section">
<h2>Part 1: Another Multiple Choice </h2>
<hr>
<h3>How long is New Zealand’s Ninety Mile Beach?</h3>
<span id="hint_4" hidden></span>
<div id="btn-cnt-2">
<button id="2-1" onclick="checkSecond(1)">90 miles</button>
<button id="2-4" onclick="checkSecond(4)">91 miles</button>
<button id="2-2" onclick="checkSecond(2)">55 miles</button>
<button id="2-5" onclick="checkSecond(5)">69 miles</button>
<button id="2-3" onclick="checkSecond(3)">90 km</button>
</div>
</div>
</div>
</body>
</html>