init
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
const values = ["Web developer", "Pc games enjoyer", "Server backend survivor", "python programmer", "Javascript disliker"];
|
||||
var direction = 1;
|
||||
var text = "";
|
||||
var speed = 100;
|
||||
var selectedValue = 0;
|
||||
var currentValueIndex = 0;
|
||||
|
||||
function type() {
|
||||
if (direction == 1) {
|
||||
if (currentValueIndex < values[selectedValue].length) {
|
||||
text += values[selectedValue][currentValueIndex];
|
||||
currentValueIndex++;
|
||||
} else {
|
||||
direction = -1;
|
||||
speed = 1500;
|
||||
}
|
||||
} else {
|
||||
if (currentValueIndex > 0) {
|
||||
text = text.slice(0, -1);
|
||||
currentValueIndex--;
|
||||
} else {
|
||||
direction = 1;
|
||||
selectedValue++;
|
||||
if (selectedValue >= values.length) {
|
||||
selectedValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function typing() {
|
||||
type();
|
||||
document.getElementById("typing").innerHTML = "$ " + text;
|
||||
if (direction == 1) {
|
||||
speed = 80 + Math.random() * 100;
|
||||
} else {
|
||||
speed = 60 + (Math.random() * 100) / 2;
|
||||
}
|
||||
setTimeout(typing, speed);
|
||||
}
|
||||
|
||||
typing();
|
||||
Reference in New Issue
Block a user