-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
77 lines (67 loc) · 2.39 KB
/
script.js
File metadata and controls
77 lines (67 loc) · 2.39 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
// Toggle theme between dark and light
function toggleTheme() {
const body = document.body;
const themeToggleButton = document.querySelector('.theme-toggle button');
if (body.classList.contains('dark-theme')) {
body.classList.remove('dark-theme');
body.classList.add('light-theme');
themeToggleButton.innerText = '🌛';
} else {
body.classList.remove('light-theme');
body.classList.add('dark-theme');
themeToggleButton.innerText = '🌞';
}
}
// Open section and close others
function openSection(sectionId) {
const sections = document.querySelectorAll('.content-section');
sections.forEach(section => {
if (section.id === sectionId) {
section.classList.toggle('show');
// Close the nav when a section is opened
if (window.innerWidth <= 768) {
toggleNav(); // Toggle nav if on mobile
}
} else {
section.classList.remove('show');
}
});
}
// Activate the first section by default
document.addEventListener('DOMContentLoaded', () => {
openSection('about');
});
// Event listener for download button
document.getElementById('download-btn').addEventListener('click', function() {
alert('Your CV is downloading!');
});
// Function to show the popup
function showPopup(event, popupId) {
event.preventDefault();
const popup = document.getElementById(popupId);
popup.style.display = 'block';
// Add event listener for 'Esc' key
document.addEventListener('keydown', handleEscClose);
}
// Function to hide the popup
function hidePopup(popupId) {
const popup = document.getElementById(popupId);
popup.style.display = 'none';
// Remove event listener for 'Esc' key
document.removeEventListener('keydown', handleEscClose);
}
// Handle 'Esc' key to close the popup
function handleEscClose(event) {
if (event.key === 'Escape') {
const openPopup = document.querySelector('.popup[style*="display: block"]');
if (openPopup) {
openPopup.style.display = 'none';
document.removeEventListener('keydown', handleEscClose);
}
}
}
// Function to toggle the navigation menu visibility on mobile
function toggleNav() {
const nav = document.getElementById('vertical-nav');
nav.classList.toggle('show');
}