This repository has been archived by the owner on Aug 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
121 lines (109 loc) · 4.01 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/fontawesome.min.css" integrity="sha384-QYIZto+st3yW+o8+5OHfT6S482Zsvz2WfOzpFSXMF9zqeLcFV0/wlZpMtyFcZALm" crossorigin="anonymous">
<link rel="stylesheet" href="./css/style.css">
<title>Indian-O-Meetup</title>
</head>
<body>
<div class="hero">
<div class="form-box">
<div class="button-box">
<div id="btn"></div>
<button type="button" class="toggle-btn" onclick="login()">Log In</button>
<button type="button" class="toggle-btn" onclick="register()">Register</button>
</div>
<div class="social-icons">
<img src="./img/facebook.png" alt="">
<img src="./img/instagram.png" alt="">
<img src="./img/user.png" alt="">
</div>
<form name="myForm" method="post" id="login" class="input-group">
<input type="text" name="Uname" class="input-field" placeholder="User Id" required>
<input type="password" name="Pass" class="input-field" placeholder="Enter Password" required>
<input type="checkbox" class="check-box"> <span class="checkBx">Remember Password</span>
<button type="submit" name="log" class="submit-btn" onclick="location.href='./html/main.html';return false">Log In</button>
</form>
<form id="register" class="input-group">
<input type="text" class="input-field" placeholder="User Id" required>
<input type="email" class="input-field" placeholder="Email Id" required>
<input type="password" class="input-field" placeholder="Enter Password" required>
<input type="checkbox" class="check-box"> <span class="checkBx">I agree to terms & conditions</span>
<button type="submit" class="submit-btn">Register</button>
</form>
</div>
</div>
<script type="text/javascript">
var x = document.getElementById("login");
var y = document.getElementById("register");
var z = document.getElementById("btn");
function register(){
x.style.left = "-400px";
y.style.left = "50px";
z.style.left = "110px";
}
function login(){
x.style.left = "50px";
y.style.left = "450px";
z.style.left = "0px";
}
const name = document.querySelector('.text') || null;
const email = document.querySelector('.email');
const password = document.querySelector('.password');
const submitBtn = document.querySelector('.submit-btn')
if(name == null){
submitBtn.addEventListener('click',() => {
fetch('/login-user',{
method: 'post',
headers: new Headers({'Content-Type': 'application/json'}),
body: JSON.stringify({
email: email.value,
password: password.value
})
})
.then(res => res.json())
.then(data => {
validate(data);
})
})
} else{ //means register page is open
submitBtn.addEventListener('click',() => {
fetch('/register-user',{
method: 'post',
headers: new Headers({'Content-Type': 'application/json'}),
body: JSON.stringify({
name: text.value,
email: email.value,
password: password.value
})
})
.then(res => res.json())
.then(data => {
validate(data);
})
})
}
const validateData = (data) => {
if(!data.name){
alertBox(data);
} else {
sessionStorage.name = data.name;
sessionStorage.email = data.email;
location.href = './';
}
}
const alertBox = (data) => {
const alertContainer = document.querySelector('.alert-box');
const alertMsg = document.querySelector('.alert');
alertMsg.innerHTML = data;
alertContainer.style.top = `5%`;
setTimeout(() => {
alertContainer.style.top = null;
}, 5000);
}
</script>
</body>
</html>