refactor: make styles, js common for posts

This commit is contained in:
Barrett Ruth 2024-06-15 14:35:39 -05:00
parent 3865436f75
commit 2a8c3194d1
7 changed files with 143 additions and 87 deletions

View file

@ -19,31 +19,6 @@ const postMapping = new Map([
["Algorithms", [{ name: "two pointers" }, { name: "convex hull" }]],
]);
const TERMINAL_PROMPT = "barrett@ruth:~$ ";
let clearing = false;
function clearPrompt(delay, callback) {
if (clearing) return;
clearing = true;
const terminalPrompt = document.querySelector(".terminal-prompt");
const topicLength = terminalPrompt.innerHTML.length - TERMINAL_PROMPT.length;
let i = 0;
function removeChar() {
if (i++ < topicLength) {
terminalPrompt.textContent = terminalPrompt.textContent.slice(0, -1);
setTimeout(removeChar, delay / topicLength);
} else {
i = 0;
clearing = false;
callback && callback();
}
}
removeChar();
}
function refresh(e) {
e.preventDefault();