-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
51 lines (45 loc) · 1.49 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
search = {};
found = {};
var restro = localStorage.getItem("append");
restro = JSON.parse(restro) || [];
console.log(restro);
function getName() {
var searchName = document.getElementById("restaurant").value;
search["searchName"] = searchName;
console.log(searchName, search);
localStorage.setItem("search", JSON.stringify(search));
for (var i = 0; i < restro.length; i++) {
if (restro[i].Name == search.searchName) {
console.log("Matched");
found["name"] = restro[i].Name;
found["address"] = restro[i].address;
console.log(found);
localStorage.setItem("found", JSON.stringify(found));
// matched(restro[i]);
location.href = "Restropage.html";
}
// else {
// alert("Sorry! This resturant is not avaliable here.");
// }
}
}
function account() {
console.log("account");
var Inputemail = document.getElementById("Inputemail").value;
var Inputpassword = document.getElementById("Inputpassword").value;
console.log(Inputemail, Inputpassword);
for (var i = 0; i < restro.length; i++) {
if (restro[i].email == Inputemail && restro[i].password == Inputpassword) {
console.log("right details");
location.href = "account.html";
} else if (Inputemail == "admin" && Inputpassword == "admin") {
location.href = "admin.html";
}
}
}
window.addEventListener("load", function () {
var searchBtn = document.getElementById("button-addon2");
searchBtn.addEventListener("click", getName);
var login = document.getElementById("login");
login.addEventListener("click", account);
});