-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
92 lines (86 loc) · 2.49 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
let year1 = new Date().getFullYear();
let year2 = year1 + 1;
let year3 = year2 + 1;
let year4 = year3 + 1;
let year5 = year4 + 1;
y1 = document.getElementById("y1");
y1.innerHTML = year1;
y2 = document.getElementById("y2");
y2.innerHTML = year2;
y3 = document.getElementById("y3");
y3.innerHTML = year3;
y4 = document.getElementById("y4");
y4.innerHTML = year4;
y5 = document.getElementById("y5");
y5.innerHTML = year5;
var community;
function addUser() {
var firstName = document.getElementById("firstName").value;
var lastName = document.getElementById("lastName").value;
var year = document.getElementById("year").value;
if (firstName == "" || lastName == "" || year == "Select Year") {
alert("Please fill out all fields");
} else {
let data = {
uid: userID,
community: community,
fName: firstName,
lName: lastName,
gradYear: year,
};
sendData(data);
}
}
function sendData(data) {
fetch("https://SCUCrushes-Server.ethancl.repl.co/sendData", {
//"channel it is being sent to"
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ data }),
//What is being sent
})
.then((response) => response.json())
.then((data) => {
if (data.success) {
window.location.href = "main.html";
}
else {
alert("Error creating account. Please try again or contact [email protected].");
}
});
}
function sendUID(uid) {
//variable that is being sent
fetch("https://SCUCrushes-Server.ethancl.repl.co/sendUID", {
//"channel it is being sent to"
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ uid }),
//What is being sent
})
.then((response) => response.json())
.then((data) => {
if (!data.ver) {
alert(
"Account cannot be created. You must use your school (.edu) email address."
);
window.auth.signOut();
} else {
community = data.community;
localStorage.setItem("community", community);
if (data.accExists) {
window.location.href = "main.html";
}
else {
document.getElementById("accountForm").style.display = "block"; //also change padding top 1-px;
document.getElementById("gButton").style.display = "none";
document.getElementById("note").style.display = "none";
document.getElementById("loginHeader").style.display = "none";
}
}
});
}