-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlabtest.js
102 lines (93 loc) · 3.4 KB
/
labtest.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
import { topHeader, searchBox } from "../components/header/navbar.js";
import showList from "../components/header/index.js";
import changeLinkColor from "../scripts/changeLinkColor.js";
import footer from "../components/footer/footer.js";
import { login, # } from "../components/#/#.js";
import {
loginOn,
#On,
loginOff,
#Off,
} from "../scripts/##.js";
// Navbar Import section
document.querySelector(".header-sec-1").innerHTML = await topHeader();
document.querySelector(".search-box").innerHTML = await searchBox();
document.querySelector(".login-overlay").innerHTML = await login();
document.querySelector(".#-overlay").innerHTML = await #();
window.loginOn = loginOn;
window.#On = #On;
window.loginOff = loginOff;
window.#Off = #Off;
window.hide = hide;
changeLinkColor();
document.getElementById("location").addEventListener("click", showList);
// CArt Section
update_cart_count();
function update_cart_count() {
if (localStorage.getItem("cart-count") == null) {
document.getElementById("cart_count").innerHTML = ` 0 Item`;
} else {
let cart_count = localStorage.getItem("cart-count");
console.log(cart_count);
document.getElementById("cart_count").innerHTML = `${cart_count} Item`;
document.getElementById("cart-icon").innerHTML = `${cart_count}`;
}
}
function hide() {
let container = document.querySelector(".location-selection ");
document.addEventListener("mouseup", function (e) {
if (!container.contains(e.target)) {
container.style.visibility = "hidden";
}
});
}
// Body section
// Login Part
let login_area = document.querySelector(".login");
updateLoginArea();
let login_btn = document.querySelector(".login-btn");
login_btn.addEventListener("click", loginUser);
function loginUser() {
let login_usernames = document.querySelector("#login-username").value;
let username = localStorage.getItem("username");
if (login_usernames == username) {
alert("Login Done");
let flag = localStorage.getItem("isUserLogin");
flag = true;
localStorage.setItem("isUserLogin", JSON.stringify(flag));
loginOff();
login_area.innerHTML = `<span><img style="width: 20px" src="../image/user.svg" alt=""></span> <span id="logout">LogOut</span>`;
} else {
alert("Invalid Email Please # first!!");
loginOff();
#On();
}
}
let #_btn = document.querySelector("##-btn");
#_btn.addEventListener("click", #User);
function #User() {
let #_usernames = document.querySelector("##-email").value;
localStorage.setItem("username", #_usernames);
alert("# Done. Please Login");
#Off();
}
function updateLoginArea() {
// console.log();
let flag = localStorage.getItem("isUserLogin");
console.log(flag);
if (flag == "false") {
login_area.innerHTML = `<span onclick="loginOn()">Login</span> | <span onclick="#On()">#</span>`;
} else if (flag == "true") {
login_area.innerHTML = `<span><img style="width: 20px" src="../image/user.svg" alt=""></span> <span id="logout">LogOut</span>`;
document.getElementById("logout").addEventListener("click", logoutUser);
}
}
function logoutUser() {
login_area.innerHTML = `<span onclick="loginOn()">Login</span> | <span onclick="#On()">#</span>`;
let flag = localStorage.getItem("isUserLogin");
flag = "false";
localStorage.setItem("isUserLogin", flag);
}
// Footer section
// Footer section
document.querySelector(".footer").innerHTML = await footer();