mirror of
https://github.com/yv1ing/MollyBlog.git
synced 2025-09-16 14:53:45 +08:00
25 lines
653 B
JavaScript
25 lines
653 B
JavaScript
function search() {
|
|
const keyword = document.getElementById("index-search-input").value;
|
|
window.location.href = "/search?keyword=" + keyword;
|
|
}
|
|
|
|
function typeWriter(element_id, text) {
|
|
const element = document.getElementById(element_id);
|
|
let i = 0;
|
|
|
|
element.innerHTML = '';
|
|
function type() {
|
|
if (i < text.length) {
|
|
const minSpeed = 50;
|
|
const maxSpeed = 200;
|
|
const randomSpeed = Math.floor(Math.random() * (maxSpeed - minSpeed + 1)) + minSpeed;
|
|
|
|
element.innerHTML += text.charAt(i);
|
|
|
|
i++;
|
|
setTimeout(type, randomSpeed);
|
|
}
|
|
}
|
|
|
|
type();
|
|
} |