-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventregistration.html
executable file
·549 lines (374 loc) · 15.6 KB
/
eventregistration.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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">
<title>SwampHacks 2018 - Check In</title>
<meta name="description" content="
SwampHacks is a 36 hour open coding event where students become creators.
In the time allotted, students from around the country come together at the
University of Florida to collaborate on projects, mingle in activities, and
network with sponsors for a fully immersive experience.
"/>
<!-- Stylesheets
================================================== -->
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link href="https://fortawesome.github.io/Font-Awesome/assets/font-awesome/css/font-awesome.css" rel="stylesheet">
<!-- Favicon
================================================== -->
<link rel="icon" type="image/png" href="favicon.png" />
<!-- Icons & Fonts
================================================== -->
<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- MLH Badge
================================================== -->
<!-- <a id="mlh-trust-badge" style="display:block;max-width:100px;min-width:60px;position:absolute;right:50px;top:0;width:10%;z-index:0" href="https://mlh.io/seasons/na-2018/events?utm_source=na-2018&utm_medium=TrustBadge&utm_campaign=na-2018&utm_content=white" target="_blank"><img src="https://s3.amazonaws.com/logged-assets/trust-badge/2018/white.svg" alt="Major League Hacking 2017 Hackathon Season" style="width:100%"></a> -->
</head>
<body>
<div id="animationWindow" class="hide">
<div class="loader"></div>
</div>
<div id="layout" class="">
<div id="menuLogin-register" class="show">
<div class="pure-menu-heading" href="#">
<h1 id="mainheader">swamp<b>hacks IV</b></h1>
<!-- <img id="logo" class="" src="img/logoblue.svg"></img> -->
</div>
<div class="btngroup hide">
<span id="statusWithBtn" class="">Please fill in all fields!</span> <span onclick="resendEmailClicked()" class="resend" id="resendBtn">Resend it?</span>
</div>
<div id="loginStatusTxt-register" class="hide">
Please fill in all fields!
</div>
<div class="menu-items-con-login">
<div class="row log">
<form id="loginForm-register" class="" autocomplete="off">
<div class="col-md-12 top-margin">
<label class="form-lbl" for="q1" name="">First Name</label>
<input class="form-field" id="fname" name="q1" type="text" placeholder="" required/>
</div>
<div class="col-md-12 top-margin">
<label class="form-lbl" for="q1" name="">Last Name</label>
<input class="form-field" id="lname" name="q1" type="text" placeholder="" required/>
</div>
<div class="col-md-12 top-margin">
<label class="form-lbl" for="q1" name="">School</label>
<input class="form-field" id="school" name="q1" type="text" placeholder="" required/>
</div>
<div class="col-md-12 top-margin">
<label class="form-lbl" for="q1" name="">Year</label>
<select class="form-field" id="year" required>
<option value="freshman">Freshman</option>
<option value="sophomore">Sophomore</option>
<option value="junior">Junior</option>
<option value="senior">Senior</option>
<option value="super-senior">Super Senior</option>
</select>
</div>
<div class="col-md-12 top-margin">
<label class="form-lbl" for="q1" name="">Gender</label>
<select class="form-field" id="gender" required>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
</div>
<div class="col-md-12 top-margin">
<label class="form-lbl" for="q1" name="">Email</label>
<input class="form-field" id="email" name="q1" type="text" placeholder="" required/>
</div>
<div class="col-md-12 top-margin">
<!-- <label class="form-lbl" for="q1" name="">Password -<span class="underline-btn" onclick="resetPasswordClicked()">Forgot?</span></label> -->
<label class="form-lbl" for="q1" name="">Password</label>
<i class="fa fa-lock pass-visibility" aria-hidden="true" id="pv5" onclick="showPassPressed(password, pv5)"></i>
<input class="form-field" id="password" name="q1" type="password" placeholder="" required/>
</div>
<div class="col-md-12 top-margin">
<!-- <label class="form-lbl" for="q1" name="">Password -<span class="underline-btn" onclick="resetPasswordClicked()">Forgot?</span></label> -->
<label class="form-lbl" for="q1" name="">Confirm Password</label>
<i class="fa fa-lock pass-visibility" aria-hidden="true" id="pv6" onclick="showPassPressed(confirmPassword, pv6)"></i>
<input class="form-field" id="confirmPassword" name="q1" type="password" placeholder="" required/>
</div>
<div class="col-md-12 top-margin">
<button class="button green" onClick="createActCheckInClicked()"><a href=""><p class="loginbtn">Create Account and Check In</p></a></button>
</div>
</form>
<div class="margin-buffer">
<div class="col-md-12 top-margin login-txt">
<button class="button txtbtnouter"><a href="checkin.html"><p class="textbtn"><b>or Check In</b></p></a></button>
</div>
<!--
<div class="col-md-12 descrip-txt login-txt">
Please check in with the email you applied with!
</div> -->
</div>
</div>
</div>
</div>
<div id="login-side">
<!-- <img class="clock" src="img/clock.jpg"></img> -->
<!-- <div class="imgcon">
<img class="colorlogo" src="img/colorlogo.svg"></img>
</div> -->
<div class="top-blk">
<div class="top-txt">CHECK</div>
</div>
<div class="bottom-blk">
<div class="bottom-txt">IN</div>
</div>
</div>
</div>
<script src="js/menu.js"></script>
<script src="js/jquery.js"></script>
<script src="js/classie.js"></script>
</body>
<script src="https://www.gstatic.com/firebasejs/3.7.6/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.7.6/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.7.6/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.7.6/firebase.js"></script>
<script src="https://cdn.firebase.com/js/client/2.3.1/firebase.js"></script>
<script src="firebaseconfig.js"></script>
<script>
var ref = firebase.database().ref();
var usersRef = ref.child("applicants");
var checkedInRef = ref.child("confirmed");
var acceptedRef = ref.child("accepted");
var userObj = JSON.parse(localStorage.getItem('loggedInUser'));
var loggedInUserKey = localStorage.getItem('loggedInUserKey');
$("form").submit(function() { return false; });
if (userObj === null || userObj === undefined || userObj.isVolunteer === undefined || userObj.isVolunteer === false) {
// Only volunteers and admin can access this page
window.location.href = "index.html";
}
function loginBtnClicked() {
var email = $("#email").val();
var password = $("#password").val();
if (email !== "" && password !== "") {
// Show the loader
$("#animationWindow").removeClass("hide");
$("#animationWindow").addClass("showflex");
// Login user
firebase.auth().signInWithEmailAndPassword(email, password).then(function(user) {
// User signed in
var delay = 5000;
var smallDelay = 500;
setTimeout(function() {
// Delay before checking
acceptedRef.orderByChild("email").equalTo(email).on("value", function(snapshot) {
});
firebase.auth().onAuthStateChanged(function(user) {
if (user.emailVerified) {
// SUCCESS
$("#loginStatusTxt").text("Checked in!");
$("#loginStatusTxt").addClass("show");
// Hide the loader
$("#animationWindow").removeClass("showflex");
$("#animationWindow").addClass("hide");
setTimeout(function() {
// Reload form for next check in
location.reload();
}, delay);
} else if (!user.emailVerified) {
// Hide the loader
$("#animationWindow").removeClass("showflex");
$("#animationWindow").addClass("hide");
// ERROR
$("#statusWithBtn").text("Email not verified! Check your inbox, it could take up to 10 minutes.");
$(".btngroup").addClass("show");
$("#loginStatusTxt").addClass("hide");
$("#loginStatusTxt").removeClass("show");
}
});
}, delay);
}).catch(function(error) {
// Hide the loader
$("#animationWindow").removeClass("showflex");
$("#animationWindow").addClass("hide");
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode.includes("auth/wrong-password")) {
$("#loginStatusTxt").text("Wrong password!");
$("#loginStatusTxt").addClass("show");
$(".btngroup").addClass("hide");
$(".btngroup").removeClass("show");
} else if (errorCode.includes("weak-password")) {
// ERROR
$("#loginStatusTxt").text("Password should be at least 6 characters!");
$("#loginStatusTxt").addClass("show");
$(".btngroup").addClass("hide");
$(".btngroup").removeClass("show");
} else if (errorCode.includes("email-already-in-use")) {
// ERROR
$("#loginStatusTxt").text("Email already in use!");
$("#loginStatusTxt").addClass("show");
$(".btngroup").addClass("hide");
$(".btngroup").removeClass("show");
} else if (errorCode.includes("invalid-email")) {
// ERROR
$("#loginStatusTxt").text("Invalid email!");
$("#loginStatusTxt").addClass("show");
$(".btngroup").addClass("hide");
$(".btngroup").removeClass("show");
} else {
// ERROR
$("#loginStatusTxt").text("Unknown error logging in. Wrong email?");
$("#loginStatusTxt").addClass("show");
$(".btngroup").addClass("hide");
$(".btngroup").removeClass("show");
}
});
} else {
$("#loginStatusTxt").text("Please fill in all fields.");
$("#loginStatusTxt").addClass("show");
$(".btngroup").addClass("hide");
$(".btngroup").removeClass("show");
}
}
function resetPasswordClicked() {
var email = $("#email").val();
firebase.auth().sendPasswordResetEmail(email).then(function() {
// Password reset email sent.
$("#loginStatusTxt").text("Reset password email sent! Check your inbox.");
$("#loginStatusTxt").addClass("show");
}).catch(function(error) {
// Error occurred. Inspect error.code.
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode.includes("auth/invalid-email")) {
$("#loginStatusTxt").text("Please provide a valid email below!");
$("#loginStatusTxt").addClass("show");
} else if (errorCode.includes("auth/user-not-found")) {
$("#loginStatusTxt").text("There is no user associated with that email, did you create an account?");
$("#loginStatusTxt").addClass("show");
} else {
$("#loginStatusTxt").text("Error sending reset password email.");
$("#loginStatusTxt").addClass("show");
}
});
}
function resendEmailClicked() {
firebase.auth().onAuthStateChanged(function(user) {
if (!user.emailVerified) {
user.sendEmailVerification();
$("#resendBtn").text("Email Sent!");
$("#resendBtn").addClass("disabled");
} else {
$("#resendBtn").text("Already Verified!");
$("#resendBtn").addClass("disabled");
}
});
}
function checkIfUserExists(email) {
var cD;
var k;
acceptedRef.orderByChild("email").equalTo(email).on("value", function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var key = childSnapshot.key;
var childData = childSnapshot.val();
cD = childData;
k = key;
});
});
if (cD !== undefined) {
localStorage.setItem('loggedInUser', JSON.stringify(cD));
localStorage.setItem('loggedInUserKey', k);
return true;
} else if (cD === undefined) {
return false;
} else {
return false;
}
}
function showPassPressed(field, icon) {
if (field.type === "password") {
field.type = "text";
$(icon).removeClass("fa-lock");
$(icon).addClass("fa-unlock-alt");
} else {
field.type = "password";
$(icon).addClass("fa-lock");
$(icon).removeClass("fa-unlock-alt");
}
}
function validateEmail(emailVal) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(emailVal);
}
function createActCheckInClicked() {
$("#menuLogin-register").animate({
scrollTop: 0
}, 200);
var fnameVal = $("#fname").val();
var lnameVal = $("#lname").val();
var email = $("#email").val();
var genderVal = $("#gender").val();
var schoolVal = $("#school").val();
var yearVal = $("#year").val();
var password = $("#password").val();
var confirmPassword = $("#confirmPassword").val();
myArray = ["herons", "gators", "turtles", "dragonflies"]
var iteam = myArray[Math.floor(Math.random() * myArray.length)];
if (password !== "" && confirmPassword !== "" && email !== "") {
if ((confirmPassword === password)) {
// Creating user in firebase
firebase.auth().createUserWithEmailAndPassword(email, password).then(function(user) {
// You can save the user data here.
// Adding to DB
if (validateEmail(email)) {
checkedInRef.push({
fname: fnameVal,
lname: lnameVal,
email: email,
gender: genderVal,
school: schoolVal,
year: yearVal,
subscribedToMail: "false",
isVolunteer: false,
team: iteam
});
} else {
}
// STATUS
$("#loginStatusTxt-register").text("Checked In!");
$("#loginStatusTxt-register").addClass("show");
var delay = 3000;
setTimeout(function() {
window.location.href = "checkin.html";
}, delay);
}).catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
// Handling different types of errors
if (errorCode.includes("weak-password")) {
// ERROR
$("#loginStatusTxt-register").text("Password should be at least 6 characters!");
$("#loginStatusTxt-register").addClass("show");
} else if (errorCode.includes("email-already-in-use")) {
// ERROR
$("#loginStatusTxt-register").text("Email already in use! Please Check In.");
$("#loginStatusTxt-register").addClass("show");
} else if (errorCode.includes("invalid-email")) {
// ERROR
$("#loginStatusTxt-register").text("Invalid email!");
$("#loginStatusTxt-register").addClass("show");
} else {
// ERROR
$("#loginStatusTxt-register").text("Unknown error making your account. Try again");
$("#loginStatusTxt-register").addClass("show");
}
});
} else {
// ERROR
$("#loginStatusTxt-register").text("Passwords do not match!");
$("#loginStatusTxt-register").addClass("show");
}
} else {
// ERROR
$("#loginStatusTxt-register").text("Please fill in all fields!");
$("#loginStatusTxt-register").addClass("show");
}
}
</script>
</html>