-
Notifications
You must be signed in to change notification settings - Fork 0
/
index1.html
345 lines (295 loc) · 12.3 KB
/
index1.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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!doctype html>
<html lang="en">
<head>
<!-- Important Globals -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Personal Content -->
<link href="style.css" rel="stylesheet">
<title>Bruce Qu</title>
<link href="images/tomato.png" rel="icon">
<meta name="keywords" content="bruce qu, brucequz">
<!-- JS -->
<script>
// 1
//4 0 2
// 3
// Set Room Trackers
var prevRoom = 0;
var room = 0;
// Declare Content Variables
var mainroom;
var greeting;
var aboutme_room;
// Declare Edge Variables
var top_edge;
var right_edge;
var bottom_edge;
var left_edge;
// Declare Edge Disablers
var top_disabler;
var right_disabler;
var bottom_disabler;
var left_disabler;
// Declare Disablers Array
var disablers = [];
// Declare About Me Content
var current_num_of_chars = 0;
var aboutme_text = "I'm Bruce Qu, an senior undergraduate electrical engineering student at UCLA."
var typing_delay = 50;
document.addEventListener('DOMContentLoaded', function() {
// Initialize Content Variables
mainroom = document.querySelector('#mainroom');
greeting = document.querySelector('#greeting');
aboutme_room = document.querySelector('#aboutme_room');
// Initialize Edge Variables
top_edge = document.querySelector('#top_edge');
right_edge = document.querySelector('#right_edge');
bottom_edge = document.querySelector('#bottom_edge');
left_edge = document.querySelector('#left_edge');
// Initialize Edge Disablers
top_disabler = document.querySelector('#top_disabler');
right_disabler = document.querySelector('#right_disabler');
bottom_disabler = document.querySelector('#bottom_disabler');
left_disabler = document.querySelector('#left_disabler');
// Initialize Disablers Array
disablers = document.querySelectorAll('.disabler');
// Fire Arrows After Greeting Animation Ends
greeting.addEventListener('animationend', function() {
top_edge.classList.add('animate_up');
setTimeout(function() {right_edge.classList.add('animate_right');}, 500);
setTimeout(function() {bottom_edge.classList.add('animate_down');}, 1000);
setTimeout(function() {left_edge.classList.add('animate_left');}, 1500);
});
// Enable Edges
left_edge.addEventListener('animationend', function() {
for (let i = 0; i < disablers.length; i++) {
disablers[i].classList.remove('disable_opaque');
}
});
// Handle Room Changes
// Top Edge
top_edge.addEventListener('click', moveUp);
// Right Edge
right_edge.addEventListener('click', moveRight);
// Bottom Edge
bottom_edge.addEventListener('click', moveDown);
// Left Edge
left_edge.addEventListener('click', moveLeft);
// About Me Room Handler
// Initialize content-based size of wrapper
aboutme_size_wrapper_paragraph.innerHTML = aboutme_text;
// Start typewriter effect upon first entry of room
aboutme_room.addEventListener('transitionend', function() {
aboutme_header.classList.toggle('aboutme_header_animation');
aboutme_content.classList.toggle('aboutme_content_animation');
});
aboutme_content.addEventListener('animationend', aboutmeTypingEffect);
// Re-enable Edges After Room Change
mainroom.addEventListener('transitionend', enableEdgesAndArrows);
// Re-enable Hover After Room Change
mainroom.addEventListener('transitionend', enableHover);
});
function moveUp() {
disableEdgesAndArrows();
// Stop Hover on Top Edge
top_edge.classList.add('stop_hover');
// Update Previous Room
prevRoom = room;
// Move to Room 1 if in Room 0
if (room == 0) {
mainroom.classList.add('exit_bottom');
document.querySelector('#aboutme_room').classList.add('enter_top');
room = 1;
}
// Move to Room 0 if in Room 3
if (room == 3) {
mainroom.classList.remove('exit_top');
//document.querySelector('#placeholder').classList.remove('enter_bottom');
room = 0;
}
}
function moveRight() {
disableEdgesAndArrows();
// Stop Hover on Right Edge
right_edge.classList.add('stop_hover');
// Update Previous Room
prevRoom = room;
// Move to Room 2 if in Room 0
if (room == 0) {
mainroom.classList.add('exit_left');
//document.querySelector('#placeholder').classList.add('enter_right');
room = 2;
}
// Move to Room 0 if in Room 4
if (room == 4) {
mainroom.classList.remove('exit_right');
document.querySelector('#tomato').classList.remove('enter_left');
room = 0;
}
}
function moveDown() {
disableEdgesAndArrows();
// Stop Hover on Bottom Edge
bottom_edge.classList.add('stop_hover');
// Update Previous Room
prevRoom = room;
// Move to Room 3 if in Room 0
if (room == 0) {
mainroom.classList.add('exit_top');
//document.querySelector('#placeholder').classList.add('enter_bottom');
room = 3;
}
// Move to Room 0 if in Room 1
if (room == 1) {
mainroom.classList.remove('exit_bottom');
document.querySelector('#aboutme_room').classList.remove('enter_top');
room = 0;
}
}
function moveLeft() {
disableEdgesAndArrows();
// Stop Hover on Left Edge
left_edge.classList.add('stop_hover');
// Update Previous Room
prevRoom = room;
// Move to Room 4 if in Room 0
if (room == 0) {
mainroom.classList.add('exit_right');
document.querySelector('#tomato').classList.add('enter_left');
room = 4;
}
// Move to Room 0 if in Room 2
if (room == 2) {
mainroom.classList.remove('exit_left');
//document.querySelector('#placeholder').classList.remove('enter_right');
room = 0;
}
}
function disableEdgesAndArrows() {
if (room == 0) {
// Disable all Edges
for (let i = 0; i < disablers.length; i++) {
disablers[i].classList.add('disable');
}
}
else if (room == 1) {
// Disable Bottom Edge
bottom_disabler.classList.add('disable');
}
else if (room == 2) {
// Disable Left Edge
left_disabler.classList.add('disable');
}
else if (room == 3) {
// Disable Top Edge
top_disabler.classList.add('disable');
}
else {
// Disable Right Edge
right_disabler.classList.add('disable');
}
}
function enableEdgesAndArrows() {
if (room == 0) {
// Enable all Edges
for (let i = 0; i < disablers.length; i++) {
disablers[i].classList.remove('disable');
}
}
else if (room == 1) {
// Enable Bottom Edge
bottom_disabler.classList.remove('disable');
}
else if (room == 2) {
// Enable Left Edge
left_disabler.classList.remove('disable');
}
else if (room == 3) {
// Enable Top Edge
top_disabler.classList.remove('disable');
}
else {
// Enable Right Edge
right_disabler.classList.remove('disable');
}
}
function enableHover() {
if (prevRoom == 1 || prevRoom == 3) {
top_edge.classList.remove('stop_hover');
bottom_edge.classList.remove('stop_hover');
}
else if (prevRoom == 2 || prevRoom == 4) {
right_edge.classList.remove('stop_hover');
left_edge.classList.remove('stop_hover');
}
}
function aboutmeTypingEffect() {
if (current_num_of_chars < aboutme_text.length)
{
aboutme_content_paragraph.innerHTML += aboutme_text.charAt(current_num_of_chars);
current_num_of_chars++;
setTimeout(aboutmeTypingEffect, typing_delay);
}
}
</script>
</head>
<body>
<!-- Room 0 Contents -->
<div id="mainroom">
<div class="wrapper">
<div id="name">
<b>I'm Bruce Qu</b>
</div>
</div>
<div class="wrapper">
<div id="greeting">
<b>Welcome</b>
</div>
</div>
</div>
<!-- Room 1 Contents -->
<div id="aboutme_room">
<div id="aboutme_header">
<b>About Me</b>
</div>
<div id="aboutme_size_wrapper">
<p id="aboutme_size_wrapper_paragraph">
</p>
<div id="aboutme_content">
<p id="aboutme_content_paragraph">
</p>
</div>
</div>
</div>
<!-- Room 4 Contents -->
<div id="tomato">
<img src="images/tomato.png">
</div>
<!-- Edges and Arrows -->
<div id="top_disabler" class="disabler disable_opaque">
<div id="top_edge" class="edge">
<div id="up_arrow" class="arrow"><b>‹</b></div>
<div id="north" class="border"></div>
</div>
</div>
<div id="right_disabler" class="disabler disable_opaque">
<div id="right_edge" class="edge">
<div id="right_arrow" class="arrow"><b>›</b></div>
<div id="east" class="border"></div>
</div>
</div>
<div id="bottom_disabler" class="disabler disable_opaque">
<div id="bottom_edge" class="edge">
<div id="down_arrow" class="arrow"><b>›</b></div>
<div id="south" class="border"></div>
</div>
</div>
<div id="left_disabler" class="disabler disable_opaque">
<div id="left_edge" class="edge">
<div id="left_arrow" class="arrow"><b>‹</b></div>
<div id="west" class="border"></div>
</div>
</div>
</body>
</html>