feat: Add client-side search, reading time estimates, and a reading progress bar, plus a clipboard copy fallback.

This commit is contained in:
2026-03-11 22:07:01 +03:00
parent 18cc61af31
commit 6c8776a4cc
12 changed files with 457 additions and 98 deletions
+34
View File
@@ -0,0 +1,34 @@
document.addEventListener('DOMContentLoaded', () => {
const progressBar = document.getElementById('reading-progress-bar');
if (!progressBar) return;
const updateProgress = () => {
// Calculate how far the user has scrolled down the page
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
// Calculate the total scrollable height
const scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
const clientHeight = document.documentElement.clientHeight || window.innerHeight;
const windowHeight = scrollHeight - clientHeight;
// Calculate percentage and update width
const scrollPercentage = windowHeight > 0 ? (scrollTop / windowHeight) * 100 : 0;
progressBar.style.width = scrollPercentage + '%';
};
// Update initially in case the user refreshes midway down the page
updateProgress();
// Throttle the scroll event listener a tiny bit for performance
let isTicking = false;
window.addEventListener('scroll', () => {
if (!isTicking) {
window.requestAnimationFrame(() => {
updateProgress();
isTicking = false;
});
isTicking = true;
}
});
});