joshua.seigler.net/main-nXw2QMt0.js
Joshua Seigler e924ff4c36 Updates
2025-07-11 14:48:15 -04:00

1 line
2.5 KiB
JavaScript

(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))o(e);new MutationObserver(e=>{for(const n of e)if(n.type==="childList")for(const i of n.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function s(e){const n={};return e.integrity&&(n.integrity=e.integrity),e.referrerPolicy&&(n.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?n.credentials="include":e.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function o(e){if(e.ep)return;e.ep=!0;const n=s(e);fetch(e.href,n)}})();function l({target:t}){const r=document.querySelector("#effects");if(r==null)return;Array.from(r.children).filter(o=>o.__effectParent===t).forEach(o=>{o.getAnimations().forEach(e=>{if(+(e.currentTime??0)<100){e.pause(),r.removeChild(o);return}e.pause(),e.updatePlaybackRate(-.25),e.play(),e.addEventListener("finish",()=>{r.contains(o)&&r.removeChild(o)})})})}function u(t){return t!==null&&typeof t.matches=="function"}function f({target:t}){const r=document.querySelector("#effects");if(!u(t)||!t.matches("a[href],.nav-toggle-button,button,input[type='radio']"))return;const s=window.getComputedStyle(t).getPropertyValue("--glowColor"),o=Array.from(t.getClientRects());Array.from(t.children).forEach(e=>{o.push(...Array.from(e.getClientRects()))}),o.forEach(e=>{const{top:n,left:i,width:a,height:m}=e,c=document.createElement("div");c.__effectParent=t,c.classList.add("effect-instance");const d="10rem";c.style.top=`calc(${n+window.scrollY}px - ${d})`,c.style.left=`calc(${i+window.scrollX}px - ${d})`,c.style.width=`calc(${a}px + 2 * ${d})`,c.style.height=`calc(${m}px + 2 * ${d})`,c.style.setProperty("--glowColor",s),r==null||r.appendChild(c)})}function p(){document.querySelectorAll("pre[class^=language]").forEach(t=>{const r=document.createElement("button");r.classList.add("copy-button"),r.addEventListener("click",()=>{t instanceof HTMLElement&&navigator.clipboard.writeText(t.innerText)}),t.appendChild(r)})}function h({target:t}){!u(t)||!t.matches("a[href][target=_blank]")||umami==null||umami.track(`Link: ${t.innerText??t.getAttribute("href")}`,{from:document.location.href,destination:t.getAttribute("href")})}document.addEventListener("mouseenter",f,!0);document.addEventListener("focus",f,!0);document.addEventListener("mouseleave",l,!0);document.addEventListener("blur",l,!0);document.addEventListener("click",h,!0);document.addEventListener("DOMContentLoaded",p);