-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
59 lines (48 loc) · 1.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
const texts = ["Computer Science Undergraduate", "Tech Enthusiatic", "Aspiring DSA and MERN Stack"];
const speed = 50; // milliseconds per character
let textIndex = 0;
let charIndex = 0;
function typeText() {
const currentText = texts[textIndex];
const textContainer = document.getElementById('text-container');
if (charIndex < currentText.length) {
textContainer.innerHTML = currentText.substring(0, charIndex + 1);
charIndex++;
setTimeout(typeText, speed);
} else {
// Move to the next text or loop back to the beginning
textIndex = (textIndex + 1) % texts.length;
charIndex = 0;
// Clear the border for the next text
textContainer.className = "";
// Add a delay before typing the next text
setTimeout(() => {
// Add the border class back before typing
textContainer.className = "border";
typeText();
}, 1000);
}
}
// Call the typing function when the page loads
window.onload = typeText;
var tablinks=document.getElementsByClassName("tab-links");
var tabcontents=document.getElementsByClassName("tab-contents");
function opentab(tabname){
for(tablink of tablinks){
tablink.classList.remove("active-link");
}
for(tabcontent of tabcontents){
tabcontent.classList.remove("active-tab");
}
event.currentTarget.classList.add("active-link");
document.getElementById(tabname).classList.add("active-tab")
}
var icon=document.getElementById("icon");
icon.onclick=function(){
document.body.classList.toggle("dark-theme");
if(document.body.classList.contains("dark-theme")){
icon.src="assets/sun.png";}
else{
icon.src="assets/moon.png";
}
}