-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
43 lines (31 loc) · 1.42 KB
/
main.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
const userIsSignedIn = false; // Change this to `true` or `false` to simulate whether a user is signed in
const loginButtonContainer = document.getElementById('login-button');
if (userIsSignedIn) {
const profileContainer = document.createElement('div');
profileContainer.className = 'profile-container';
const profileImage = document.createElement('img');
profileImage.src = '../images/profile-icon.png';
profileImage.alt = 'Profile Icon';
profileImage.className = 'profileIcon';
const dropdownMenu = document.createElement('div');
dropdownMenu.className = 'dropdown-menu';
const profileLink = document.createElement('a');
profileLink.href = '../profile/profile.php';
profileLink.textContent = 'Profile';
const listingsLink = document.createElement('a');
listingsLink.href = '../listings/listings.html';
listingsLink.textContent = 'My Listings';
dropdownMenu.appendChild(profileLink);
dropdownMenu.appendChild(listingsLink);
profileContainer.appendChild(profileImage);
profileContainer.appendChild(dropdownMenu);
loginButtonContainer.appendChild(profileContainer);
} else {
const signInButton = document.createElement('button');
signInButton.textContent = 'Sign In';
signInButton.className = 'headerbutton';
signInButton.addEventListener('click', function() {
window.location.href = './login/login.php';
});
loginButtonContainer.appendChild(signInButton);
}