-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
103 lines (95 loc) · 2.8 KB
/
app.js
File metadata and controls
103 lines (95 loc) · 2.8 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
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
function login() {
location.href = "email.html";
}
// ========login/logout on single page=========
// var flag = sessionStorage.getItem("mail");
// const element = document.getElementById("log");
// if (flag) {
// if (element) element.innerText = "LogOut";
// } else {
// if (element) element.innerText = "LogIn";
// }
var allmail = [];
var userMailData = localStorage.getItem("UserDataEmail");
if (userMailData !== null) {
allmail = JSON.parse(userMailData);
}
function genMail() {
var mail = document.getElementById("mail");
// console.log(mail.value);
if (mail.value === "") {
alert("Please enter email");
} else if (!mail.value.includes("@")) {
alert("please includes '@' in the email adrress");
} else if (!mail.value.includes(".com")) {
alert("please enter a part following '@'");
} else {
sessionStorage.setItem("mail", mail.value);
var isEmailExist = allmail.includes(mail.value);
if (!isEmailExist) {
// email = mail.value;
console.log(mail.value);
allmail.push(mail.value);
localStorage.setItem("UserDataEmail", JSON.stringify(allmail));
}
if (isEmailExist) {
location.href = "passlogin.html";
} else {
location.href = "PassCreate.html";
}
}
}
var allpass = [];
var userPassData = localStorage.getItem("UserDataPass");
if (userPassData !== null) {
allpass = JSON.parse(userPassData);
}
function createpass() {
var newPass = document.getElementById("newPass").value;
var conPass = document.getElementById("conPass").value;
if (newPass === "") {
alert("All field Required");
} else {
if (newPass !== conPass) {
alert("Password not match, \nEnter same password on both field ");
} else {
allpass.push(newPass);
localStorage.setItem("UserDataPass", JSON.stringify(allpass));
location.href = "user.html";
var logvalue = document.getElementById("log").innerText;
console.log(logvalue);
}
}
}
function loginpass() {
var mail = sessionStorage.getItem("mail");
var pass = document.getElementById("pass").value;
var isPassExist = allpass.includes(pass);
var match = true;
if (isPassExist) {
for (var i = 0; i < allmail.length; i++) {
if (allpass[i] === pass && allmail[i] === mail) {
location.href = "user.html";
var logvalue = document.getElementById("log");
console.log(logvalue);
match = false;
}
}
if (match === true) {
alert("Password is incorrect");
}
} else {
alert("Password is incorrect");
}
}
function loadfun() {
var mail = sessionStorage.getItem("mail");
document.getElementById("para").childNodes[1].innerText = mail;
// var log = sessionStorage.getItem("log");
}
function sell() {
location.href = "sell.html";
}
function forSell() {
alert("SignIn Required to post your product ads");
}