-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrouter.js
47 lines (39 loc) · 1.35 KB
/
router.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
//for testing puposes
// localStorage.removeItem('isLoggedIn');
function checkAuthentication() {
const isLoggedIn = localStorage.getItem('isLoggedIn') === 'true';
return isLoggedIn;
}
const isLoggedIn = checkAuthentication();
function navigate(route) {
switch (route) {
case 'Home':
window.location.href = isLoggedIn ? 'Gagan/explorer.html' : 'Raj/form.html';
break;
case 'Developers':
window.location.href = isLoggedIn ? 'Riya/dashboard.html' : 'Raj/form.html';
break;
case 'Podcasts':
window.location.href = 'Raj/podcastPage/Spotify/spotify.html';
break;
case 'Contact':
window.location.href = 'Siri/contactus.html';
break;
case 'About':
window.location.href = 'Siri/aboutus.html';
break;
case 'Signup':
if (isLoggedIn) {
alert(`Logged in as ${localStorage.getItem('username')}`);
} else {
window.location.href = 'Shreya/signup.html';
}
break;
default:
console.error('Invalid route');
}
}
//changing the signup button innerhtml is the user is signed up
if(isLoggedIn){
document.getElementsByClassName('register')[0].innerHTML=`Hello , ${localStorage.getItem('username')}`
}