-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (49 loc) · 1.57 KB
/
Copy pathscript.js
File metadata and controls
61 lines (49 loc) · 1.57 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
function changeAboutMeText() {
const aboutMeTexts = [
"BCA (Science) Student",
"Full Stack Web Developer",
"Good Programmer"
];
const typingSpeed = 100;
const eraseSpeed = 50;
const pauseTime = 1500;
const aboutMeElement = document.querySelector(".about-me");
let textIndex = 0;
let charIndex = 0;
let isDeleting = false;
function type() {
const currentText = aboutMeTexts[textIndex];
if (!isDeleting) {
aboutMeElement.textContent = currentText.substring(0, charIndex + 1);
charIndex++;
if (charIndex < currentText.length) {
setTimeout(type, typingSpeed);
} else {
isDeleting = true;
setTimeout(type, pauseTime);
}
} else {
aboutMeElement.textContent = currentText.substring(0, charIndex - 1);
charIndex--;
if (charIndex > 0) {
setTimeout(type, eraseSpeed);
} else {
isDeleting = false;
textIndex = (textIndex + 1) % aboutMeTexts.length;
charIndex = 0;
setTimeout(type, typingSpeed);
}
}
}
type();
}
window.onload = changeAboutMeText;
const toggleBtn = document.getElementById("theme-toggle");
toggleBtn.addEventListener("click", () => {
document.body.classList.toggle("dark-mode");
if (document.body.classList.contains("dark-mode")) {
toggleBtn.textContent = "☀️";
} else {
toggleBtn.textContent = "🌙";
}
});