typer fix

This commit is contained in:
Alfie King 2025-06-20 13:32:04 +01:00
parent e95e424a1e
commit 4a577e928a

View File

@ -20,12 +20,12 @@ const values = [
"Loud Music enjoyer",
"part time femboy :<",
];
var direction = 1;
var text = "";
var speed = 100;
var selectedValue = 0;
var currentValueIndex = 0;
var pause = false;
let typing_direction = 1;
let text = "";
let speed = 100;
let selectedValue = 0;
let currentValueIndex = 0;
let pause = false;
function randomValue() {
selectedValue = Math.floor(Math.random() * values.length);
@ -33,12 +33,12 @@ function randomValue() {
}
function type() {
if (direction == 1) {
if (typing_direction == 1) {
if (currentValueIndex < values[selectedValue].length) {
text += values[selectedValue][currentValueIndex];
currentValueIndex++;
} else {
direction = -1;
typing_direction = -1;
pause = true;
}
} else {
@ -46,7 +46,7 @@ function type() {
text = text.slice(0, -1);
currentValueIndex--;
} else {
direction = 1;
typing_direction = 1;
randomValue();
}
}
@ -55,7 +55,7 @@ function type() {
function typing() {
type();
document.getElementById("typing").innerHTML = "$ " + text;
if (direction == 1) {
if (typing_direction == 1) {
speed = 80 + Math.random() * 100;
} else {
speed = 60 + (Math.random() * 100) / 2;
@ -72,7 +72,7 @@ typing();
// HIDDEN STUFF (shh don't tell anyone >:3)
var last5Chars = "";
let last5Chars = "";
document.addEventListener('keydown', function(event) {
last5Chars += event.key;