INNER CODE UNIT · JavaScript
escapeHtml
LeyckerS/moondownloader · web/app.js:190
const escapeHtml = (s) => s.replace(/[&<>]/g, (c) => ({ "&": "&", "<": "<", ">": ">" }[c]));
/* Middle ellipsis: these filenames differ only in the last few characters, so
clipping the tail would make every row look identical. */
function elide(name, head = 34, tail = 22) {
if (name.length <= head + tail + 1) return name;
return name.slice(0, head) + "…" + name.slice(-tail);
}
/* Animated counter. The number is the thing the operator stares at; snapping it
between two values hides how fast it is actually moving. */
function roll(el, to, fmt) {
const from = Number(el.dataset.v || 0);
if (!isFinite(to)) return;
if (Math.abs(to - from) < 1e-4) { el.textContent = fmt(to); return; }
cancelAnimationFrame(el._raf);
const t0 = performance.now();
const dur = 340;