-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
44 lines (40 loc) · 1.53 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
document.addEventListener("DOMContentLoaded", function() {
const subtitleElement = document.querySelector('.subtitle');
const textArray = ["Femboy-", "Catboy-", "Developer-","Boykisser-"];
let index = 0;
let charIndex = 0;
const typingSpeed = 300;
const eraseSpeed = 150;
function animateText() {
const currentWord = textArray[index];
if (charIndex === currentWord.length) {
setTimeout(eraseText, eraseSpeed);
return;
}
const currentText = currentWord.slice(0, charIndex) + '|';
if (currentText !== subtitleElement.innerText) {
subtitleElement.innerText = currentText;
}
charIndex++;
setTimeout(animateText, typingSpeed);
}
function eraseText() {
if (charIndex === 0) {
index = (index + 1) % textArray.length;
setTimeout(animateText, typingSpeed);
return;
}
const currentWord = textArray[index];
const currentText = currentWord.slice(0, charIndex - 1) + '|';
if (currentText !== subtitleElement.innerText) {
subtitleElement.innerText = currentText;
}
charIndex--;
setTimeout(eraseText, eraseSpeed);
}
let counterLabel = document.querySelector('.counter-text')
fetch('https://nyawtism.com/counters/inc/nyawaiGithubVisitorCounter')
.then(response => response.json())
.then(data => { counterLabel.innerHTML = data.visitors })
animateText();
});