summaryrefslogtreecommitdiffstats
path: root/assets/js/typing.js
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-04-22 12:42:56 +0200
committerDanilo M. <danix@danix.xyz>2026-04-22 12:42:56 +0200
commit631547a75142326a7c71bdf123e1475217a5ad73 (patch)
treef3cfef6b3c5b42bf626fc823ddcf63b8dcf4cdbb /assets/js/typing.js
parent77ccbe72fad5a4870185fff374f75471c16a9043 (diff)
downloaddanixxyz-theme-631547a75142326a7c71bdf123e1475217a5ad73.tar.gz
danixxyz-theme-631547a75142326a7c71bdf123e1475217a5ad73.zip
chore: replace with extracted danix.xyz-hacker theme (danix2-hugo-theme)
Diffstat (limited to 'assets/js/typing.js')
-rw-r--r--assets/js/typing.js69
1 files changed, 0 insertions, 69 deletions
diff --git a/assets/js/typing.js b/assets/js/typing.js
deleted file mode 100644
index 369fed7..0000000
--- a/assets/js/typing.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * typing.js
- * Typing animation for .hero-role / #typed element
- */
-
-export function initTyping() {
- 'use strict';
-
- const typedElement = document.getElementById('typed');
- if (!typedElement) return;
-
- const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
- const phrasesJson = typedElement.getAttribute('data-phrases');
- let phrases = [];
-
- if (phrasesJson) {
- try {
- phrases = JSON.parse(phrasesJson);
- } catch (e) {
- console.warn('Failed to parse typing phrases:', e);
- phrases = ['Security & Web Dev', 'WordPress Developer'];
- }
- }
-
- if (!phrases.length) return;
-
- let currentPhraseIndex = 0;
- let currentCharIndex = 0;
- let isDeleting = false;
-
- function type() {
- const phrase = phrases[currentPhraseIndex];
- const speed = isDeleting ? 50 : 100;
-
- if (isDeleting) {
- currentCharIndex--;
- } else {
- currentCharIndex++;
- }
-
- typedElement.textContent = phrase.substring(0, currentCharIndex);
-
- // Add cursor
- if (!isDeleting && currentCharIndex === phrase.length) {
- typedElement.innerHTML += '<span class="cursor"></span>';
- } else if (isDeleting && currentCharIndex === 0) {
- currentPhraseIndex = (currentPhraseIndex + 1) % phrases.length;
- isDeleting = false;
- setTimeout(type, 500);
- return;
- } else {
- typedElement.innerHTML = phrase.substring(0, currentCharIndex) + '<span class="cursor"></span>';
- }
-
- if (!isDeleting && currentCharIndex === phrase.length) {
- isDeleting = true;
- setTimeout(type, 2000);
- } else {
- setTimeout(type, prefersReducedMotion ? 0 : speed);
- }
- }
-
- if (prefersReducedMotion) {
- // Just show the first phrase without animation
- typedElement.textContent = phrases[0];
- } else {
- type();
- }
-}