c.stupid.cat/js/ascii.js

20 lines
536 B
JavaScript

(async function () {
const el = document.getElementById('ascii-art');
try {
const res = await fetch('/ascii.txt', { cache: 'no-store' });
if (!res.ok) throw new Error('fetch failed: ' + res.status);
const raw = await res.text();
const ansi_up = new AnsiUp();
const html = ansi_up.ansi_to_html(raw);
el.innerHTML = html;
el.removeAttribute('aria-busy');
} catch (err) {
el.textContent = "couldn't load ascii.txt :(";
console.error(err);
}
})();