-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
47 lines (43 loc) · 1.41 KB
/
app.js
File metadata and controls
47 lines (43 loc) · 1.41 KB
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
userName = document.getElementById("usernameBox")
phoneNum = document.getElementById("phoneBox")
logInName = (document.cookie).slice(9) //remove the "username=" part of the cookie
console.log(logInName)
IP = "http://127.0.0.1:5000"
function post(url,content) {
fetch(IP + url, {
method: "POST",
headers: {"Content-Type":"application/json"},
body: JSON.stringify(content)
}).then(response => response.json()).then(data => {
return (data)
})
}
function get(url,user) {
fetch(IP + url, {
method: "GET",
headers: {
'Content-Type': 'application/json'
}
}).then(response => response.json()).then(data => {
button = document.getElementById("logInButton")
console.log(data)
if(data['status'] == "success") {
document.cookie = "username=" + userName.value + "; path=/";
window.location.assign("http://127.0.0.1:5500/scare.html")
}
})
}
function openBar(){
// document.getElementById("navBar").style.width = "250px";
document.getElementById("navBar").classList.add("open");
}
function closeBar(){
// document.getElementById("navBar").style.width = "0";
document.getElementById("navBar").classList.remove("open");
}
function log() {
button = document.getElementById("logInButton")
user = userName.value
phone = phoneNum.value
get(`/login?total=${encodeURIComponent(userName.value + "," + phone,(user))}`)
}