diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2023-12-29 07:53:18 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2023-12-29 07:53:18 +0800 |
| commit | 8a5c0f459be8244c896f668518bf774a69b38860 (patch) | |
| tree | f65cf0e98c61c1f38d04ee9d549c221c51e78615 /src | |
| parent | 8b2924acbc4397509524d27d84d6b5ee0382ebf8 (diff) | |
reformat
Diffstat (limited to 'src')
| -rw-r--r-- | src/js/hacktype.js | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/js/hacktype.js b/src/js/hacktype.js index 4ff0463a..44553b29 100644 --- a/src/js/hacktype.js +++ b/src/js/hacktype.js @@ -5,46 +5,46 @@ const special = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; let interval = null; function hackType() { -const elements = document.querySelectorAll(".hacktype"); -const intervals = []; + const elements = document.querySelectorAll(".hacktype"); + const intervals = []; -elements.forEach((element) => { - let iteration = 0; + elements.forEach((element) => { + let iteration = 0; - const interval = setInterval(() => { - element.innerText = element.innerText - .split("") - .map((letter, index) => { - if (index < iteration) { - return element.dataset.value[index]; - } + const interval = setInterval(() => { + element.innerText = element.innerText + .split("") + .map((letter, index) => { + if (index < iteration) { + return element.dataset.value[index]; + } - return letters[Math.floor(Math.random() * 26)]; - }) - .join(""); + return letters[Math.floor(Math.random() * 26)]; + }) + .join(""); - if (iteration >= element.dataset.value.length) { - clearInterval(interval); - } + if (iteration >= element.dataset.value.length) { + clearInterval(interval); + } - iteration += 1 / 5; - }, 20); + iteration += 1 / 5; + }, 20); - intervals.push(interval); -}); + intervals.push(interval); + }); } hackType(); // Call hackType initially setInterval(() => { const elements = document.querySelectorAll(".hacktype"); -elements.forEach((element) => clearInterval(interval)); // Clear existing intervals -hackType(); // Call hackType again + elements.forEach((element) => clearInterval(interval)); // Clear existing intervals + hackType(); // Call hackType again }, 10000); // Repeat every 10 seconds // Check if the document becomes visible again document.addEventListener("visibilitychange", () => { -if (!document.hidden) { - hackType(); // Call hackType when the user comes back from being away -} + if (!document.hidden) { + hackType(); // Call hackType when the user comes back from being away + } });
\ No newline at end of file |
