(function(){ // Copy-to-clipboard for code blocks function setupCopyButtons(){ document.querySelectorAll('[data-copy-target]').forEach(function(btn){ btn.addEventListener('click', async function(){ var sel = btn.getAttribute('data-copy-target'); var el = document.querySelector(sel); if(!el) return; var text = el.innerText || el.textContent || ''; try{ await navigator.clipboard.writeText(text.trim()); var old = btn.innerHTML; btn.innerHTML = 'Copied'; btn.classList.add('btn-success'); btn.classList.remove('btn-outline-secondary'); setTimeout(function(){ btn.innerHTML = old; btn.classList.remove('btn-success'); btn.classList.add('btn-outline-secondary'); }, 1200); }catch(e){ // Fallback var ta = document.createElement('textarea'); ta.value = text.trim(); document.body.appendChild(ta); ta.select(); try{ document.execCommand('copy'); }catch(_){} document.body.removeChild(ta); } }); }); } // Asciinema embed helper: // Put
// Or provide a self-hosted player by swapping the script URL. function setupAsciinema(){ document.querySelectorAll('.asciicast[data-asciinema-id]').forEach(function(el){ var id = el.getAttribute('data-asciinema-id'); if(!id || id === 'REPLACE_ME'){ el.innerHTML = '
Add your asciinema id here: data-asciinema-id.
'; return; } // Avoid injecting twice if(document.getElementById('asciinema-embed-'+id)) return; var s = document.createElement('script'); s.src = 'https://asciinema.org/a/' + encodeURIComponent(id) + '.js'; s.id = 'asciinema-embed-'+id; s.async = true; // The script replaces a placeholder div with the player if it's directly after it. el.appendChild(s); }); } document.addEventListener('DOMContentLoaded', function(){ setupCopyButtons(); setupAsciinema(); }); })();