-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (30 loc) · 1.23 KB
/
Copy pathscript.js
File metadata and controls
34 lines (30 loc) · 1.23 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
document.addEventListener('DOMContentLoaded', () => {
const themeToggleButton = document.getElementById('theme-toggle');
const body = document.body;
const contactFormButton = document.getElementById('contact-form-button');
const contactModal = document.getElementById('contact-modal');
const closeModalButton = document.getElementById('close-modal');
// Toggle dark/light mode
themeToggleButton.addEventListener('click', () => {
body.classList.toggle('dark-mode');
if (body.classList.contains('dark-mode')) {
themeToggleButton.textContent = 'Switch to Light Mode';
} else {
themeToggleButton.textContent = 'Switch to Dark Mode';
}
});
// Open contact form modal
contactFormButton.addEventListener('click', () => {
contactModal.style.display = 'block';
});
// Close contact form modal
closeModalButton.addEventListener('click', () => {
contactModal.style.display = 'none';
});
// Close modal when clicking outside of it
window.addEventListener('click', (event) => {
if (event.target === contactModal) {
contactModal.style.display = 'none';
}
});
});