Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
/**
* Page Title Animation
* Creates a dynamic typing and loading animation for the page title
*/
(function() {
const fullText = "Ingmar van Rheenen - IVR";
const typingSpeed = 80; // Typing speed in ms
const loadingSpeed = 200; // Loading spinner speed in ms
const pauseDuration = 800; // Pause between animations
const cursor = " |"; // Blinking cursor character
// Enhanced spinner characters with more variety
const spinnerChars = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
let spinnerIndex = 0;
let displayText = "";
let index = 0;
let isAdding = true;
let isTyping = false;
let loadingTime = 0;
let cursorVisible = true;
function updateTitle() {
document.title = displayText;
}
// Enhanced cursor blinking effect
function blinkCursor() {
if (isTyping) {
const baseText = isAdding
? fullText.substring(0, index)
: fullText.substring(0, index);
displayText = baseText + (cursorVisible ? cursor : '');
cursorVisible = !cursorVisible;
updateTitle();
setTimeout(blinkCursor, 500); // Blink every 500ms
}
}
function animateLoading() {
// Enhanced loading animation with progress indication
const progressDots = '.'.repeat((loadingTime / 500) % 4);
displayText = `Loading ${spinnerChars[spinnerIndex]}${progressDots}`;
updateTitle();
spinnerIndex = (spinnerIndex + 1) % spinnerChars.length;
loadingTime += loadingSpeed;
if (loadingTime < 3000) { // 3 seconds for loading
setTimeout(animateLoading, loadingSpeed);
} else {
isTyping = true;
blinkCursor();
setTimeout(animateTitle, pauseDuration);
}
}
function animateTitle() {
if (isTyping) {
if (isAdding) {
if (index < fullText.length) {
index++;
} else {
isAdding = false;
setTimeout(() => {
// Brief pause before starting delete animation
displayText = fullText; // Remove cursor temporarily
updateTitle();
setTimeout(animateTitle, pauseDuration);
}, pauseDuration * 2); // Longer pause when fully typed
return;
}
} else {
if (index > 0) {
index--;
} else {
isAdding = true;
setTimeout(() => {
// Brief pause before retyping
setTimeout(animateTitle, pauseDuration);
}, pauseDuration);
return;
}
}
// Update without cursor during typing animation
const baseText = isAdding
? fullText.substring(0, index)
: fullText.substring(0, index);
displayText = baseText + cursor;
updateTitle();
setTimeout(animateTitle, typingSpeed);
}
}
// Start the animation on page load
document.addEventListener('DOMContentLoaded', function() {
animateLoading();
});
})();