-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript1.js
More file actions
51 lines (45 loc) · 1.99 KB
/
Copy pathscript1.js
File metadata and controls
51 lines (45 loc) · 1.99 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
document.addEventListener('DOMContentLoaded', () => {
const themeToggle = document.querySelector('#theme-switch');
const body = document.body;
const hamburgerMenu = document.querySelector('.hamburger-menu');
const mobileNav = document.querySelector('.mobile-nav');
// Theme Toggle Functionality
themeToggle.addEventListener('click', () => {
body.classList.toggle('dark-theme');
const theme = body.classList.contains('dark-theme') ? 'dark' : 'light';
localStorage.setItem('theme', theme);
updateThemeIcon();
});
function updateThemeIcon() {
const isDarkTheme = body.classList.contains('dark-theme');
themeToggle.innerHTML = isDarkTheme
? '<i class="fa-solid fa-sun"></i>'
: '<i class="fa-solid fa-moon"></i>';
}
// Check for saved theme preference
const savedTheme = localStorage.getItem('theme');
if (savedTheme === 'dark') {
body.classList.add('dark-theme');
}
updateThemeIcon();
// Mobile Navigation Toggle
hamburgerMenu.addEventListener('click', () => {
mobileNav.style.display = mobileNav.style.display === 'flex' ? 'none' : 'flex';
});
// Close mobile navigation when a link is clicked
mobileNav.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
mobileNav.style.display = 'none';
});
});
// Particles.js Configuration (if you're using the library)
if (window.particlesJS) {
particlesJS('particles-js', {
particles: {
number: { value: 80, density: { enable: true, value_area: 800 } },
color: { value: '#3498db' },
shape: { type: 'circle' },
opacity: { value: 0.5, random: false },
size: { value: 3, random: true },
line_linked: { enable: true, distance: 150, color: '#3498db', opacity: 0.4, width: 1 },
move: { enable: true, speed: 6, direction: 'none', random: