-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
166 lines (145 loc) · 4.98 KB
/
script.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
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
const container = document.getElementById("container");
const registerBtn = document.getElementById("register");
const loginBtn = document.getElementById("login");
registerBtn.addEventListener("click", () => {
container.classList.add("active");
document.querySelector("title").innerHTML = "CREATE ACCOUNT";
document.querySelector('link[rel="icon"]').href =
"Logo/Logo for create account.webp";
});
loginBtn.addEventListener("click", () => {
container.classList.remove("active");
document.querySelector("title").innerHTML = "SIGN IN";
document.querySelector('link[rel="icon"]').href =
"Logo/Logo for sign in.webp";
});
let newName = document.getElementById("name");
let newEmail = document.getElementById("email");
let newPW = document.getElementById("password");
let create_account = document.getElementById("create_account");
create_account.addEventListener("click", () => {
let name = newName.value;
let email = newEmail.value;
let password = newPW.value;
localStorage.setItem("Name", name);
localStorage.setItem("Email", email);
localStorage.setItem("Password", password);
if (name == "" || email == "" || password == "") {
alert("Please fill all the fields");
} else {
alert("Account created successfully");
window.location.href = "Dashboard/Dashboard.html";
}
});
let check_email = document.getElementById("check_email");
let check_password = document.getElementById("check_password");
let signin_btn = document.getElementById("sign-in_btn");
signin_btn.addEventListener("click", () => {
let email = check_email.value;
let password = check_password.value;
if (email == "" || password == "") {
alert("Please fill all the fields");
} else {
if (localStorage.getItem("Email") == email) {
if (localStorage.getItem("Password") == password) {
alert("Sign in successfully");
window.location.href = "Dashboard/Dashboard.html";
} else {
alert("Wrong password");
}
} else if (
localStorage.getItem(email) !== email &&
localStorage.getItem("Password") !== password
) {
alert("Please create a account");
container.classList.add("active");
} else {
alert("Wrong email");
}
}
});
// Forget Password
// styling
let FP = document.getElementById("fp");
let FF = document.getElementById("FF");
FP.addEventListener("click", () => {
document.querySelector("title").innerHTML = "FORGET PASSWORD";
document.querySelector('link[rel="icon"]').href =
"Logo/Logo for forget password.webp";
container.style.opacity = "0%";
FF.style.opacity = "100%";
currentPassword.innerHTML = " ";
newPassword.innerHTML = " ";
reenterPassword.innerHTML = " ";
});
// Change Password
let currentPassword = document.getElementById("cpass");
let newPassword = document.getElementById("npass");
let reenterPassword = document.getElementById("cnpass");
let confirms = document.getElementById("forget_btn");
confirms.addEventListener("click", () => {
let Current = currentPassword.value;
let New = newPassword.value;
let re_enter = reenterPassword.value;
if (Current == "" || New == "" || re_enter == "") {
alert("Please fill all the fields");
} else {
if (localStorage.getItem("Password") == Current) {
if (New == re_enter) {
localStorage.setItem("Password", New);
alert("Password changed successfully");
let ok = document.getElementById("okay");
ok.style.top = "-50px";
ok.style.left = "-50px";
ok.style.width = "400px";
ok.style.height = "500px";
ok.style.borderRadius = "30px";
// animation
var start = 100;
var mid = 145;
var end = 250;
var width = 20;
var leftX = start;
var leftY = start;
var rightX = mid - width / 2.7;
var rightY = mid + width / 2.7;
var animationSpeed = 20;
var ctx = document.getElementsByTagName("canvas")[0].getContext("2d");
ctx.lineWidth = width;
ctx.strokeStyle = "rgba(0, 150, 0, 1)";
for (i = start; i < mid; i++) {
var drawLeft = window.setTimeout(function () {
ctx.beginPath();
ctx.moveTo(start, start);
ctx.lineTo(leftX, leftY);
ctx.stroke();
leftX++;
leftY++;
}, 1 + (i * animationSpeed) / 3);
}
for (i = mid; i < end; i++) {
var drawRight = window.setTimeout(function () {
ctx.beginPath();
ctx.moveTo(leftX, leftY);
ctx.lineTo(rightX, rightY);
ctx.stroke();
rightX++;
rightY--;
}, 1 + (i * animationSpeed) / 3);
}
} else {
alert("Passwords do not match");
}
} else {
alert("Wrong password");
}
}
currentPassword.innerHTML = " ";
newPassword.innerHTML = " ";
reenterPassword.innerHTML = " ";
});
let okaybtn = document.getElementById("okaybtn")
okaybtn.addEventListener("click", ()=>{
container.style.opacity = "100%"
FF.style.opacity = "0%"
})