-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaskdoctor.js
152 lines (136 loc) · 4.55 KB
/
askdoctor.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
import { topHeader } from "../components/header/navbar.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(".login-overlay").innerHTML = await login();
document.querySelector(".#-overlay").innerHTML = await #();
window.loginOn = loginOn;
window.#On = #On;
window.loginOff = loginOff;
window.#Off = #Off;
// Body section
changeLinkColor();
// var slideI=1;
// var prev=document.querySelectorAll('.prev');
// prev[0].addEventListener('click',function(){
// viewSlide(slideI +=(-1));
// });
// var next=document.querySelectorAll(".next");
// next[0].addEventListener('click',function(){
// viewSlide(slideI +=(-1));
// });
// let alldots=document.querySelectorAll(".dot");
// let i=1;
// alldots.forEach(function(ele){
// ele.addEventListener('click',function(){
// viewSlide(slideI=i);
// });
// i++;
// });
// function cSlide(n){
// viewSlide(slideI=n);
// }
// function viewSlide(n){
// var slides = document.getElementsByClassName("h-customer-slide");
// var dots = document.getElementsByClassName("dot");
// if(n>slides.length){
// slideI=1;
// }
// if(n<1){
// slideI=slides.length;
// }
// for(let i=0;i<slides.length;i++){
// slides[i].style.display="none";
// dots[i].className = dots[i].className.replace("dot-active", "");
// }
// slides[slideI-1].style.display = "block";
// dots[slideI-1].className += "dot-active";
// }
// 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);
}
// 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}`;
}
}
var slides = document.getElementsByClassName("h-customer-slide");
var dots = document.getElementsByClassName("dot");
var prevDot = "";
var prevSlide = "";
for (let i = 0; i < dots.length; i++) {
console.log(dots[i].className);
dots[i].addEventListener("click", function () {
if (
prevDot.className == "dot dot-active" &&
prevSlide.style.display == "block"
) {
prevDot.className = prevDot.className.replace("dot-active", "");
prevSlide.style.display = "none";
}
dots[i].className = "dot dot-active";
slides[i].style.display = "block";
prevSlide = slides[i];
prevDot = dots[i];
});
}
// Footer section
document.querySelector(".footer").innerHTML = await footer();