-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnavbar.js
147 lines (123 loc) · 4.19 KB
/
navbar.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
let nav_parent = document.getElementById("nav_parent")
let foot_parent = document.getElementById("foot_parent")
function addNavbarToPage() {
const isLoggedIn = localStorage.getItem("isLoggedIn");
const currentUser = localStorage.getItem("currentUser");
let loginSectionHTML = "";
if (isLoggedIn === "true") {
loginSectionHTML = `
<div class="profile-nav-btn flex-div">
<span>${currentUser}</span>
<button onclick="logout()" id= "logout">Logout</button>
</div>
`;
} else {
loginSectionHTML = `
<a href="login.html" class="login-nav-btn flex-div">
<i class="fa-solid fa-box-open"></i>
<span>Login</span>
</a>
`;
}
nav_parent.innerHTML = `
<div class="logo"> <a href="/index.html"><img src="assets/logo-home.svg" alt=""></a></div>
<ul class="nav-menu">
<a href="/index.html"><i class="fa-solid fa-box-open"></i> Home</a>
<a href="/destination.html"><i class="fa-solid fa-car"></i> Destination</a>
<a href=""><i class="fa-solid fa-info-circle"></i> About</a>
</ul>
<div class="login-nav-cont">
<div id="search-data-div"></div>
${loginSectionHTML} <!-- Here the loginSectionHTML variable is used -->
<div class="flex-div">
<img src="assets/man.png" alt="">
<span class="Name"></span>
</div>
<i class="fa-solid fa-bars close" id="nav-toggle"></i>
</div>`;
if (foot_parent) {
foot_parent.innerHTML = `
<div class="footer-info">
<div class="footer-social">
<div class="contact">
<img class="abs" src="assets/abs2.png" alt="" />
<a href="https://www.facebook.com/" target="_blank"><i class="fa-brands fa-square-facebook"></i></a>
<a href="#" target="_blank"><i class="fa-brands fa-instagram"></i></a>
<a href="https://github.com/mohdadil12345" target="_blank"><i class="fa-brands fa-square-github"></i></a>
<a href="#" target="_blank"><i class="fa-brands fa-linkedin"></i></a>
</div>
<div class="search">
<input type="text" placeholder="Enter your email" />
<button><i class="fa-solid fa-magnifying-glass"></i></button>
</div>
</div>
<div class="footer-details">
<div>
<h4>SOLUTIONS</h4>
<p>Pluralsight Skills</p>
<p>Pluralsight Flow</p>
<p>Government</p>
<p>Gift of Pluralsight</p>
<p>View Pricing</p>
<p>Contact Sales</p>
<p>Skill up for free</p>
</div>
<div>
<h4>COMPANY</h4>
<p>About us</p>
<p>Customer stories</p>
<p>Careers</p>
<p>Blog</p>
<p>Newsroom</p>
<p>Resource center</p>
<p>Guides</p>
</div>
<div>
<h4>RESOURCES</h4>
<p>Download Pluralsight</p>
<p>Events</p>
<p>Teach</p>
<p>Partners</p>
<p>Affiliate Partners</p>
<p>PluralsightOne.org</p>
<p>Subscribe</p>
</div>
<div>
<h4>SUPPORT</h4>
<p>Contact</p>
<p>Help center</p>
<p>IP whitelist</p>
<p>Sitemap</p>
</div>
</div>
</div>`
}
}
function logout() {
localStorage.setItem("isLoggedIn", "false");
localStorage.setItem("currentUser", "");
window.location.reload();
}
addNavbarToPage()
let a = document.getElementById("nav_parent").offsetHeight
document.querySelector("body").style.marginTop = `${a}px`
let nav_toggle = document.getElementById("nav-toggle")
let nav_menu = document.querySelector(".nav-menu")
let navbar2 = document.querySelector(".navbar2")
nav_toggle.addEventListener("click" , ()=>{
console.log(nav_menu.style.right);
if (nav_menu.style.right == "0px") {
nav_menu.style.right = "100%"
console.log('hell');
if (navbar2) {
navbar2.style.left = "100%"
}
}
else {
nav_menu.style.right = "0px"
console.log('hell1');
if (navbar2) {
navbar2.style.left = "0px"
}
}
})