-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (36 loc) · 1.47 KB
/
index.js
File metadata and controls
40 lines (36 loc) · 1.47 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
// Selecting the button and icon
const themeToggleBtn = document.getElementById('theme-toggle');
const themeIcon = document.getElementById('theme-icon');
// Check for saved theme in localStorage
const currentTheme = localStorage.getItem('theme');
if (currentTheme === 'dark') {
document.body.classList.add('dark-theme');
themeIcon.classList.remove('fa-moon');
themeIcon.classList.add('fa-sun');
}
// Theme toggle function
themeToggleBtn.addEventListener('click', () => {
document.body.classList.toggle('dark-theme');
// Change the icon and save theme to localStorage
if (document.body.classList.contains('dark-theme')) {
themeIcon.classList.remove('fa-moon');
themeIcon.classList.add('fa-sun');
localStorage.setItem('theme', 'dark');
} else {
themeIcon.classList.remove('fa-sun');
themeIcon.classList.add('fa-moon');
localStorage.setItem('theme', 'light');
}
});
function openModal(imageSrc) {
const modal = document.getElementById("modal");
const modalImg = document.getElementById("modal-img");
modal.style.display = "flex"; // Set modal display to flex to center content
modalImg.src = imageSrc; // Set the source of the modal image
modalImg.alt = "Certificate Image"; // Add alt text for accessibility
}
function closeModal(event) {
event.stopPropagation(); // Prevent triggering closeModal on modal click
const modal = document.getElementById("modal");
modal.style.display = "none"; // Hide modal
}