2024-03-18 15:04:04 +00:00
|
|
|
import "./header.js";
|
2024-04-16 16:53:24 +00:00
|
|
|
import "./config.js";
|
2024-03-18 10:34:43 +00:00
|
|
|
|
|
|
|
function type_out(e) {
|
2024-08-23 22:08:28 +00:00
|
|
|
const text = e.innerText;
|
|
|
|
const original = e.innerHTML;
|
|
|
|
const delay = 25;
|
|
|
|
let chars = 0;
|
2024-03-18 10:34:43 +00:00
|
|
|
|
2024-08-23 22:08:28 +00:00
|
|
|
function insert_char(character, parent) {
|
|
|
|
if (chars == 0) parent.innerHTML = "";
|
|
|
|
const c = document.createElement("span");
|
|
|
|
c.innerText = character;
|
|
|
|
parent.appendChild(c);
|
|
|
|
c.classList.add("newchar");
|
|
|
|
}
|
2024-03-18 10:34:43 +00:00
|
|
|
|
2024-08-23 22:08:28 +00:00
|
|
|
function normalize() {
|
|
|
|
e.innerHTML = original;
|
|
|
|
}
|
2024-03-18 10:34:43 +00:00
|
|
|
|
2024-08-23 22:08:28 +00:00
|
|
|
function increment_char() {
|
|
|
|
const newchar = text.substring(chars, chars + 1);
|
|
|
|
insert_char(newchar, e);
|
|
|
|
chars++;
|
|
|
|
if (chars <= text.length) {
|
|
|
|
setTimeout(increment_char, delay);
|
|
|
|
} else {
|
|
|
|
setTimeout(normalize, 250);
|
2024-03-18 10:34:43 +00:00
|
|
|
}
|
2024-08-23 22:08:28 +00:00
|
|
|
}
|
2024-03-18 10:34:43 +00:00
|
|
|
|
2024-08-23 22:08:28 +00:00
|
|
|
increment_char();
|
2024-03-18 10:34:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function fill_list(list) {
|
2024-08-23 22:08:28 +00:00
|
|
|
const items = list.querySelectorAll("li a, li span");
|
|
|
|
items.innerText = "";
|
|
|
|
const delay = 100;
|
2024-03-18 10:34:43 +00:00
|
|
|
|
2024-08-23 22:08:28 +00:00
|
|
|
items.forEach((item, iter) => {
|
|
|
|
item.style.animationDelay = `${iter * delay}ms`;
|
|
|
|
item.style.animationPlayState = "playing";
|
|
|
|
});
|
2024-03-18 10:34:43 +00:00
|
|
|
}
|
|
|
|
|
2024-08-23 22:08:28 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
[...document.querySelectorAll(".typeout")]
|
|
|
|
.filter((e) => e.innerText != "")
|
|
|
|
.forEach((e) => {
|
|
|
|
type_out(e);
|
|
|
|
console.log(e);
|
|
|
|
});
|
|
|
|
[...document.querySelectorAll("ol, ul")]
|
|
|
|
.filter((e) => e.innerText != "")
|
|
|
|
.forEach((e) => {
|
|
|
|
fill_list(e);
|
2024-04-16 16:53:24 +00:00
|
|
|
});
|
2024-03-22 07:30:22 +00:00
|
|
|
|
2024-08-23 22:08:28 +00:00
|
|
|
const top_button = document.getElementById("backtotop");
|
|
|
|
window.onscroll = () => {
|
|
|
|
if (!top_button) return;
|
|
|
|
const btt_threshold = 100;
|
|
|
|
if (
|
|
|
|
document.body.scrollTop > btt_threshold ||
|
|
|
|
document.documentElement.scrollTop > btt_threshold
|
|
|
|
) {
|
|
|
|
top_button.classList.add("active");
|
|
|
|
} else {
|
|
|
|
top_button.classList.remove("active");
|
2024-03-22 07:30:22 +00:00
|
|
|
}
|
2024-08-23 22:08:28 +00:00
|
|
|
}
|
2024-04-16 20:24:05 +00:00
|
|
|
});
|