-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgame.html
246 lines (205 loc) · 6.83 KB
/
game.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Homework 11 example solution</title>
<!-- <link rel="stylesheet" href="style.css">-->
<style>
h1 {
font-size: 1.8em;
font-family: sans-serif;
margin: 50px 100px 0;
}
h2 {
font-size: 1.4em;
font-family: sans-serif;
padding-bottom: 8px;
border-bottom: 1px solid black;
width: 300px;
margin: 0 auto;
display: block;
text-align: center;
margin-bottom: 50px;
}
h3 {
font-size: 1.2em;
}
section {
background-color: aliceblue;
width: 600px;
margin: 50px 100px;
padding: 30px;
border: 1px #999 solid;
border-radius: 10px;
}
</style>
</head>
<body>
<h1>Playing the game</h1>
<section id="first">
<h2>Start</h2>
<form action="http://zenlabs.pro/api/game/start" method="post" target="_blank">
<p>
<label for="form1Name">Твоето име</label>
<br>
<input placeholder="Your name" name="name" type="text" id="form1Name" required>
</p>
<p>
<label for="form1Email">Твоят имейл</label>
<br>
<input type="email" placeholder="Your email" name="email" id="form1Email" required>
</p>
<p>
<label for="form1Message">Изпрати текста 'game', за да започнеш играта</label>
<br>
<textarea name="message" placeholder="Type 'game' to begin" id="form1Message"></textarea>
</p>
<p>
<input type="submit" value="Изпрати">
</p>
</form>
</section>
<section id="setup">
<h2>Set the key</h2>
<p>
Enter your key here, right after you receive it:
<input id="theKey" type="text">
</p>
<small>then you can keep on submitting the forms below</small>
</section>
<section id="second">
<h2>Round 2</h2>
<form action="http://zenlabs.pro/api/game/continue" method="post" target="_blank">
<input type="hidden" name="key" class="key-input">
<h3>Моля, попълвай само на латиница!</h3>
<p>
<label for="form2Answer1">Коя година е приет HTML5 стандарта?</label>
<br>
<input type="number" value="2014" name="answer_1" id="form2Answer1" required>
</p>
<p>
<label for="form2Answer2">Кой е създателят на JSON нотацията?</label>
<br>
<input type="text" value="Douglas Crockford" name="answer_2" id="form2Answer2" required>
</p>
<p>
Кой от изброените HTML атрибути не е глобален?
<br>
<input type="radio" name="answer_3" value="data" id="form2Answer3-1"><label for="form2Answer3-1"> data</label>
<br>
<input type="radio" name="answer_3" value="title" id="form2Answer3-2"><label for="form2Answer3-2"> title</label>
<br>
<input type="radio" name="answer_3" value="alt" id="form2Answer3-3" checked><label for="form2Answer3-3"> alt</label>
</p>
<p>
<input type="submit" value="Изпрати">
</p>
</form>
</section>
<section id="third">
<h2>Round 3</h2>
<form action="http://zenlabs.pro/api/game/continue" method="post" target="_blank">
<input type="hidden" name="key" class="key-input">
<h3>What you know about Chuck Noris?</h3>
<p>
<label for="form3Name">Name</label>
<br>
<input type="text" value="Chuck Norris" name="name" id="form3Name" required>
</p>
<p>
<label for="form3Email">Email</label>
<br>
<input type="email" value="[email protected]" name="email" id="form3Email" required>
</p>
<p>
<label for="form3Occupation">Occupation</label>
<br>
<input type="text" value="ultimate hero" name="occupation" id="form3Occupation" required>
</p>
<p>
<label for="form3Eyes">Eyes Color</label>
<br>
<input type="color" name="eyes_color" value="#0000ff" id="form3Eyes" required>
</p>
<p>
<label for="form3Photo">Photo</label>
<br>
<input type="file" name="photo" id="form3Photo" required>
</p>
<p>
<input type="submit" value="Go!">
</p>
</form>
</section>
<section id="fourth">
<h2>Round 4</h2>
<form action="http://zenlabs.pro/api/game/continue" method="post" target="_blank">
<p>
Type your key, please:
<input type="text" name="key" class="key-input">
</p>
<p>
Let the JS to generate this:
<input id="javascript-rocks" type="text" name="javascript-rocks" readonly>
</p>
<p>
<input type="submit" value="Go!">
</p>
</form>
<script>
var myVar = "let's keep it simple".length;
var myOtherVar = 213 % 36 - 5 * 3;
if (myVar === myOtherVar) {
myVar += 1;
} else {
myVar = myOtherVar;
}
var myDate = new Date;
myVar *= myDate.getFullYear() - Number(7);
/*
The following code will update the value of the `javascript-rocks' field
with the result from the calculation above. It uses the JS object `document'
to access arbitrary elements in our html code by their id tag.
HINT: It doesn't contain the error, look for it in the calculations! ;)
*/
document.getElementById("javascript-rocks").value = myVar;
</script>
</section>
<section id="final">
<h2>Complete the game</h2>
<a id="chucks-secret-key" class="key-link" href="" target="_blank"></a>
<script>
var methods = ['charAt', 'reverse', 'round', 'join', 'split', 'charAt'];
var myName = "Chuck Norris";
var myBirthYear = 1940;
var myImmortalityIndex = 99.99;
var myAge = Math.round(myBirthYear * myImmortalityIndex);
var mySecretCode = myName.charAt(0) + myAge + myName.charAt(6);
var result = mySecretCode.split('').reverse().join('');
var myLink = document.getElementById('chucks-secret-key');
myLink.innerHTML = "result: " + result;
myLink.setAttribute('href', "http://zenlabs.pro/api/game/complete?result=" + result);
</script>
</section>
<script>
"use strict";
document.getElementById("theKey").onkeyup = setKey;
function setKey() {
var value = this.value;
var keyInputs = document.getElementsByClassName('key-input');
for (var i = 0; i < keyInputs.length; i++) {
var input = keyInputs[i];
input.value = value;
}
var keyLinks = document.getElementsByClassName('key-link');
for (var i = 0; i < keyLinks.length; i++) {
var link = keyLinks[i];
var url = link.getAttribute('href');
url = url.split('&')[0] + '&key=' + value;
link.setAttribute('href', url);
}
return false;
}
</script>
</body>
</html>