-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
62 lines (49 loc) · 2.04 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
console.log("Welcome to Console");
// Define the arrow function to toggle light mode
const mode = () => {
// Toggle the 'light-mode' class on the body element
const body = document.body;
const changeIcon = document.getElementById("icon");
body.classList.toggle("light-mode");
const isLightMode = body.classList.contains("light-mode");
changeIcon.classList = isLightMode
? "bi bi-moon-stars-fill"
: "bi bi-brightness-high";
menuChangeIcon.classList = isLightMode
? "bi bi-moon-stars-fill"
: "bi bi-brightness-high";
changeIcon.style.transition = "1s ease";
};
// Define the arrow function to toggle open navigation
const toggleNav = () => {
const toggleNav = document.getElementById("toggle-nav");
const isOpen = toggleNav.classList.toggle("open");
toggleMenu.classList = isOpen ? "bi bi-x-lg" : "bi bi-list-nested";
toggleMenu.style.transition = "2s ease";
};
// Add a click event listener to the icon element
const icon = document.getElementById("icon");
icon.addEventListener("click", mode);
// Add a click event listener to the toggle menu element
const toggleMenu = document.getElementById("toggle-menu");
toggleMenu.addEventListener("click", toggleNav);
// Loop Typing Text
const texts = ["Developer", "IT Specialist", "UI/UX Designer", "IT Technician"];
const typingSpeed = 100; // Adjust this value to control the typing speed (in milliseconds)
const typingElement = document.getElementById("typing-text");
// Define function typeText
function typeText(text, index) {
if (index < text.length) {
typingElement.textContent += text.charAt(index);
index++;
setTimeout(() => typeText(text, index), typingSpeed);
} else {
setTimeout(() => {
typingElement.textContent = ""; // Clear the text content after the whole text is typed
// Move to the next text in the array
const nextIndex = (texts.indexOf(text) + 1) % texts.length;
typeText(texts[nextIndex], 0);
}, 1000); // Add a delay before starting the next loop
}
}
typeText(texts[0], 0); // Start the typing animation with the first text