-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
129 lines (105 loc) · 4.79 KB
/
script.js
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Simple click event for the menu items
document.querySelectorAll('.menu-item').forEach(item => {
item.addEventListener('click', (event) => {
const itemName = event.target.innerText.trim(); // Make sure there's no extra space
if (itemName === 'Projects') {
window.location.href = 'projects.html'; // Example for "Projects" page
} else if (itemName === 'Resume') {
window.location.href = 'resume.html'; // Example for "Resume" page
} else if (itemName === 'Contact') {
window.location.href = 'contact.html'; // Example for "Contact" page
} else if (itemName === 'About Me') {
window.location.href = 'about.html'; // Navigate to "About Me" page
} else if (itemName === 'Archive') {
window.location.href = 'archive.html'; // Navigate to Archive page
}
});
});
// Flashing "Press Start" - stop blinking when clicked
const startText = document.querySelector('.start-text');
startText.addEventListener('click', () => {
startText.style.animation = 'none'; // Stop the blinking when "Press Start" is clicked
});
// Function to open a specific tab
function openTab(tabName) {
var i, tabcontent, tabbuttons;
tabcontent = document.getElementsByClassName("tab-content");
tabbuttons = document.getElementsByClassName("tab-button");
// Hide all tab content
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Remove the active class from all buttons
for (i = 0; i < tabbuttons.length; i++) {
tabbuttons[i].className = tabbuttons[i].className.replace(" active", "");
}
// Show the specific tab and make the button active
document.getElementById(tabName).style.display = "block";
event.currentTarget.className += " active";
}
// Set the default tab to open
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("skills").style.display = "block";
document.querySelector(".tab-button").classList.add("active");
});
// Function to toggle experience items
function toggleExperience(expId) {
var i, experienceItems, toggleButtons;
experienceItems = document.getElementsByClassName("experience-item");
toggleButtons = document.getElementsByClassName("toggle-button");
// Hide all experience items
for (i = 0; i < experienceItems.length; i++) {
experienceItems[i].style.display = "none";
toggleButtons[i].classList.remove("active");
}
// Show the selected experience item
document.getElementById(expId).style.display = "block";
event.currentTarget.classList.add("active");
}
// Function to toggle between Master's and Undergraduate education
function toggleEducation(educationLevel) {
var i, educationContent, educationButtons;
educationContent = document.getElementsByClassName("education-content");
educationButtons = document.getElementsByClassName("education-button");
// Hide all education content
for (i = 0; i < educationContent.length; i++) {
educationContent[i].style.display = "none";
}
// Remove the active class from all buttons
for (i = 0; i < educationButtons.length; i++) {
educationButtons[i].className = educationButtons[i].className.replace(" active", "");
}
// Show the selected education content and add the active class to the button
document.getElementById(educationLevel).style.display = "block";
event.currentTarget.className += " active";
}
// Set default education to Master's on page load
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("masters").style.display = "block"; // Show Master's content
document.querySelector(".education-button").classList.add("active"); // Set Master's button as active
});
let currentSlideIndex = 0; // Start with the first slide (index 0)
// Function to change the slide when navigating (next/prev buttons)
function changeSlide(n) {
showSlide(currentSlideIndex += n);
}
// Function to display the current slide
function showSlide(n) {
let slides = document.getElementsByClassName("slider-item");
// Loop back to first or last slide if out of bounds
if (n >= slides.length) {
currentSlideIndex = 0; // If it's the last slide, go back to the first
} else if (n < 0) {
currentSlideIndex = slides.length - 1; // If it's the first slide, go to the last
}
// Hide all slides initially
for (let i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
// Show the current slide
slides[currentSlideIndex].style.display = "block";
}
// Initialize by displaying the first slide on page load
document.addEventListener("DOMContentLoaded", function () {
showSlide(currentSlideIndex); // Display the first slide
});