-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
106 lines (84 loc) · 2.84 KB
/
script.js
File metadata and controls
106 lines (84 loc) · 2.84 KB
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
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
function performSearch() {
var query = document.getElementById('search').value.trim();
if (query) {
window.location.href = `search.html?query=${encodeURIComponent(query)}`;
} else {
alert("Please enter a search term.");
}
}
function toggleNotification() {
var dropdown = document.getElementById("notificationDropdown");
if (dropdown.style.display === "none" || dropdown.style.display === "") {
dropdown.style.display = "block";
} else {
dropdown.style.display = "none";
}
}
document.querySelectorAll('.nav-button').forEach(button => {
button.addEventListener('click', function() {
document.querySelectorAll('.nav-button').forEach(btn => btn.classList.remove('active'));
this.classList.add('active');
});
});
function toggleProfile() {
var profileContent = document.getElementById("profileContent");
if (profileContent.style.display === "none" || profileContent.style.display === "") {
profileContent.style.display = "block";
} else {
profileContent.style.display = "none";
}
}
document.addEventListener('DOMContentLoaded', function () {
const loginButton = document.getElementById('loginButton');
const isUserLoggedIn = localStorage.getItem('userEmail');
if (isUserLoggedIn) {
loginButton.textContent = 'Go to Profile';
loginButton.addEventListener('click', function () {
window.location.href = 'profile.html';
});
} else {
loginButton.addEventListener('click', function () {
window.location.href = 'login.html';
});
}
});
function savePin(pinId) {
const savedPins = JSON.parse(localStorage.getItem('savedPins')) || [];
if (!savedPins.includes(pinId)) {
savedPins.push(pinId);
localStorage.setItem('savedPins', JSON.stringify(savedPins));
alert('Pin saved to your profile!');
} else {
alert('This pin is already saved.');
}
}
function hidePin(pinId) {
const pinCard = document.getElementById(pinId);
if (pinCard) {
pinCard.style.display = 'none';
}
}
function hidePin(pinId) {
document.getElementById(pinId).style.display = 'none';
}
function toggleNotification() {
var dropdown = document.getElementById('notificationDropdown');
if (dropdown.style.display === 'block') {
dropdown.style.display = 'none';
} else {
dropdown.style.display = 'block';
}
}
document.querySelectorAll('.hide-button').forEach(button => {
button.addEventListener('click', (e) => {
e.currentTarget.closest('.pin-card').style.display = 'none';
});
});