-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.html
272 lines (229 loc) · 6.98 KB
/
main.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
<div id="container">
<div id="tabs">
<p id="lt" class="tabs" onclick="loginTabFun()">Log in</p>
<p id="rt" class="tabs" onclick="regTabFun()">Register</p>
<div id="clear"></div>
</div>
<div id="cont">
<div id="login" class="comm">
<h3>Sign in</h3>
<input id="se" type="email" placeholder="Email" required/>
<input id="sp" type="password" placeholder="Password" required/>
<input type="submit" onclick="login()" value="Submit"/>
<p onclick="forTabFun()">Forgot Password?</p>
</div>
<div id="register" class="comm">
<h3>Register</h3>
<input id="re" type="email" placeholder="Email" required/>
<input id="rp" type="password" placeholder="Password" required/>
<input id="rrp" type="password" placeholder="Re write Password" required/>
<input type="submit" onclick="register()" value="Submit"/>
</div >
<div id="forgot" class="comm">
<h3>Forgot Password</h3>
<div>
<input id="fe" type="email" placeholder="Email" required/>
<input type="submit" onclick="forgot()" value="Submit"/>
</div>
</div>
</div>
</div>
<style>
* {
padding: 0;
margin: 0;
}
body {
background: rgba(255, 84, 151, 0.40);
}
#container {
width: 300px;
margin: 0 auto;
margin-top: 150px;
}
.tabs {
display: table-cell;
width: 30%;
background-color: rgba(11, 177, 224, 0.82);
padding: 10px;
float: left;
text-align: center;
vertical-align: middle;
border: 2px solid #ffffff;
border-bottom: 0px;
position: relative;
font-size: 1.3em;
color: #ffffff;
}
.tabs:hover, p{
cursor: pointer;
}
#lt {
background-color: rgb(12, 132, 189);
}
#cont {
width: 100%;
height: 300px;
background-color: rgba(11, 177, 224, 0.82);
border: 2px solid #ffffff;
}
input{
display: block;
width: 250px;
margin: 10px 13px;
padding: 10px;
font-size: 1.3em;
color: rgba(11, 177, 224, 0.82);
outline: 2px solid #ffffff;
}
input[type="submit"] {
width: 272px;
color: #6e6e6e;
}
#clear {
clear: both;
}
.comm {
position: absolute;
visibility: hidden;
}
#login {
visibility: visible;
}
h3 {
display: table-cell;
vertical-align: middle;
padding: 10px 15px;
font-size: 1.5em;
color: #ffffff;
}
#forgot h3 {
display: block;
margin-top: 30px;
text-align: center;
}
#forgot div {
margin-top: 30px;
}
p {
padding: 10px 15px;
font-size: 1.3em;
color: #ffffff;
}
/*#footer {
width: 300px;
margin: 10px auto;
text-align: center;
color: rgba(9, 118, 155, 0.91);
}*/
</style>
<script>
var emailArray=[];
var passwordArray=[];
var loginBox = document.getElementById("login");
var regBox = document.getElementById("register");
var forgetBox = document.getElementById("forgot");
var loginTab = document.getElementById("lt");
var regTab = document.getElementById("rt");
function regTabFun(){
event.preventDefault();
regBox.style.visibility="visible";
loginBox.style.visibility="hidden";
forgetBox.style.visibility="hidden";
regTab.style.backgroundColor="rgb(12, 132, 189)";
loginTab.style.backgroundColor="rgba(11, 177, 224, 0.82)";
}
function loginTabFun(){
event.preventDefault();
regBox.style.visibility="hidden";
loginBox.style.visibility="visible";
forgetBox.style.visibility="hidden";
loginTab.style.backgroundColor="rgb(12, 132, 189)";
regTab.style.backgroundColor="rgba(11, 177, 224, 0.82)";
}
function forTabFun(){
event.preventDefault();
regBox.style.visibility="hidden";
loginBox.style.visibility="hidden";
forgetBox.style.visibility="visible";
regTab.style.backgroundColor="rgba(11, 177, 224, 0.82)";
loginTab.style.backgroundColor="rgba(11, 177, 224, 0.82)";
}
function register(){
event.preventDefault();
var email = document.getElementById("re").value;
var password = document.getElementById("rp").value;
var passwordRetype = document.getElementById("rrp").value;
if (email == ""){
alert("Email required.");
return ;
}
else if (password == ""){
alert("Password required.");
return ;
}
else if (passwordRetype == ""){
alert("Password required.");
return ;
}
else if ( password != passwordRetype ){
alert("Password don't match \n Pls retype your Password.");
return;
}
else if(emailArray.indexOf(email) == -1){
emailArray.push(email);
passwordArray.push(password);
alert(email + " Registered Succesfully. \n Login Now to Continue");
document.getElementById("re").value ="";
document.getElementById("rp").value="";
document.getElementById("rrp").value="";
}
else{
alert(email + " is already Registered.");
return ;
}
}
function login(){
event.preventDefault();
var email = document.getElementById("se").value;
var password = document.getElementById("sp").value;
var i = emailArray.indexOf(email);
if(emailArray.indexOf(email) == -1){
if (email == ""){
alert("Email required.");
return ;
}
alert("Email does not exist.");
return ;
}
else if(passwordArray[i] != password){
if (password == ""){
alert("Password required.");
return ;
}
alert("Password does not match.");
return ;
}
else {
alert(email + " logged in Succesfully \n Welcome to Student-Community-website.");
location.href = 'index.html?name='+email;
document.getElementById("se").value ="";
document.getElementById("sp").value="";
return ;
}
}
function forgot(){
event.preventDefault();
var email = document.getElementById("fe").value;
if(emailArray.indexOf(email) == -1){
if (email == ""){
alert("Email required.");
return ;
}
alert("Email does not exist.");
return ;
}
alert("Email sent to your registered mail check it in 24hr. \n Thanks");
document.getElementById("fe").value ="";
}
</script>