mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
function typeText(textParts: string[], header: HTMLHeadingElement) {
|
|
var currentText = textParts[0];
|
|
textParts[0] = currentText.slice(1);
|
|
|
|
if (currentText.length > 0) {
|
|
if (currentText.split('').some(x => x != " ")) {
|
|
header.innerHTML += currentText.charAt(0);
|
|
window.setTimeout(() => {
|
|
typeText(textParts, header);
|
|
}, 100)
|
|
}
|
|
else {
|
|
header.innerHTML = header.innerHTML.slice(0, -1);
|
|
window.setTimeout(() => {
|
|
typeText(textParts, header);
|
|
}, 50)
|
|
}
|
|
}
|
|
else {
|
|
textParts.shift();
|
|
|
|
if (textParts.length > 0) {
|
|
var timeout = 100;
|
|
|
|
if (textParts[0].split('').every(x => x == " ")) {
|
|
timeout = 800;
|
|
}
|
|
console.log(timeout);
|
|
window.setTimeout(() => {
|
|
typeText(textParts, header);
|
|
}, timeout);
|
|
}
|
|
}
|
|
}
|
|
|
|
var text = [
|
|
"Remote desktop",
|
|
" ",
|
|
" scripting",
|
|
" ",
|
|
"ly"
|
|
];
|
|
|
|
var header = document.getElementById("remotelyHeader") as HTMLHeadingElement;
|
|
|
|
typeText(text, header); |