Something went wrong. Try again.
My website, danielmorrisey.com. Written in HTML, CSS and javascript, by hand. danielmorrisey.com
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364(() => { const THEME_COOKIE_NAME = 'site_theme'; const THEME_OPTIONS = ['default', 'black'];
const getCookie = (name) => { const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`)); return match ? decodeURIComponent(match[1]) : ''; };
const setThemeCookie = (theme) => { const expires = new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toUTCString(); document.cookie = `${THEME_COOKIE_NAME}=${encodeURIComponent(theme)}; expires=${expires}; path=/; SameSite=Lax`; };
const applyTheme = (theme) => { const normalizedTheme = THEME_OPTIONS.includes(theme) ? theme : 'default'; document.body.dataset.theme = normalizedTheme;
document.querySelectorAll('[data-theme-option]').forEach((option) => { const isActive = option.getAttribute('data-theme-option') === normalizedTheme; option.classList.toggle('active', isActive); option.setAttribute('aria-pressed', isActive ? 'true' : 'false'); });
const themeToggle = document.getElementById('theme-toggle'); if (themeToggle) { themeToggle.setAttribute('data-active-theme', normalizedTheme); }
setThemeCookie(normalizedTheme); };
const getHeroEyebrowLabel = () => { const { hostname, pathname, port } = window.location; const normalizedHost = hostname.replace(/^www\./, ''); const hostLabel = normalizedHost === 'hostname is not in hostLable list' ? 'danielmorrisey.com' : ['localhost', '127.0.0.1', '[::1]'].includes(normalizedHost) && port ? `${normalizedHost}:${port}` : normalizedHost;
const normalizedPath = pathname .replace(/\/index\.html$/i, '/') .replace(/\.html$/i, '') .replace(/\/+$/, '');
const pathLabel = normalizedPath && normalizedPath !== '/' ? normalizedPath : '/';
return `${hostLabel}${pathLabel === '/' ? '/' : pathLabel.startsWith('/') ? pathLabel : `/${pathLabel}`}`; };
const getHeroSubtitle = () => { const subtitles = [ 'Welcome to my site', '"Do not throw away your shot" ~ Lin-Manuel Miranda', ]; return subtitles[Math.floor(Math.random() * subtitles.length)]; };
const init = () => { if (window.__siteCoreLoaded) return; window.__siteCoreLoaded = true;
const showAnnouncement = window.location.pathname === '/' || window.location.pathname === '/index.html'; const announcementHtml = showAnnouncement ? ` <div class="site-announcement"> <p> <b><a href="/cdn.html"><i class="fa-solid fa-database" style="color: rgb(212, 165, 116);"></i> MBD CDN:</a></b> A simple, fast CDN powered by Cloudflare R2</p> </div> ` : '';
const heroEyebrow = document.querySelector('.hero-eyebrow'); if (heroEyebrow) { heroEyebrow.textContent = getHeroEyebrowLabel(); } else { const hero = document.querySelector('.hero'); if (hero) { const eyebrow = document.createElement('p'); eyebrow.className = 'hero-eyebrow'; eyebrow.textContent = getHeroEyebrowLabel(); hero.insertBefore(eyebrow, hero.firstChild); } }
const addHeroSubtitle = () => { const isTitlePage = window.location.pathname === '/' || window.location.pathname === '/index.html'; if (!isTitlePage) return;
const heroTitle = document.querySelector('.hero-title'); if (!heroTitle) return;
let subtitle = document.querySelector('.hero-subtitle'); if (!subtitle) { subtitle = document.createElement('p'); subtitle.className = 'hero-subtitle'; heroTitle.insertAdjacentElement('afterend', subtitle); } subtitle.textContent = getHeroSubtitle(); };
addHeroSubtitle();
if (!document.querySelector('header.site-header')) { const headerHtml = ` <header class="site-header">${announcementHtml} <nav class="nav-container"> <a href="/" class="nav-logo"><i class="fa-brands fa-apple"></i>Daniel Morrisey<i>.com</i></a> <button class="nav-toggle" type="button" aria-label="Menu" aria-expanded="false" aria-controls="nav-menu"><i class="fa-solid fa-bars" aria-hidden="true"></i></button> <ul class="nav-menu" id="nav-menu"> <li class="nav-dropdown"> <details> <summary><a href="/index.html#projects">Projects <span aria-hidden="true"><i class="fa-solid fa-caret-down"></i></span></a></summary> <ul class="dropdown-menu"> <li><a href="/cdn.html">MBD CDN</a></li> <li><a href="/imrs.html">IMRS</a></li> <li><a href="/favfinder.html">Favfinder</a></li> <li><a href="/privo.html">Privo<i>.fyi</i></a></li> <li><span class="dropdown-disabled">Luna (soon™)</span></li> <li><span class="dropdown-disabled">mbdio.uk (soon™)</span></li> </ul> </details> </li> <li class="nav-dropdown"> <details> <summary><a href="/pages/index.html">Slash Pages<span aria-hidden="true"><i class="fa-solid fa-caret-down"></i></span></a></summary> <ul class="dropdown-menu"> <li><a href="/pages/changelog.html">/changelog</a></li> <li><a href="/pages/blank.html">/blank</a></li> <li><a href="/pages/chipotle.html">/chipotle</a></li> </ul> </details> </li> <li><a href="/cdn.html">CDN</a></li> <li><a href="/index.html#contact">Contact</a></li> <li><a href="https://daniel.offprint.app">Blog</a></li> <li><a href="https://bsky.app/profile/danielmorrisey.com" target="_blank" aria-label="Visit my Bluesky Profile"><i class="fa-brands fa-bluesky" aria-hidden="true"></i></a></li> </ul> </nav> </header> `; document.body.insertAdjacentHTML('afterbegin', headerHtml); }
if (!document.querySelector('footer.site-footer')) { const footerHtml = ` <footer class="site-footer"> © 2024-<span id="current-year"></span> Daniel Morrisey · <a href="https://bsky.app/profile/danielmorrisey.com" target="_blank" rel="noopener noreferrer">@danielmorrisey.com</a> · <a href="https://tangled.org/danielmorrisey.com/website">Source Code</a> <br> <span id="commit-hash">loading...</span> Secured by <a href="https://cloudflare.com">Cloudflare</a></p> </footer> `; document.body.insertAdjacentHTML('beforeend', footerHtml); }
if (!document.getElementById('privacy-notice')) { const privacyNoticeHtml = ` <div id="privacy-notice" class="privacy-notice" role="region" aria-label="Privacy notice"> <p>We use <a href="https://umami.is" target="_blank" rel="noopener noreferrer">Umami</a> and <a href="https://statcounter.com" target="_blank" rel="noopener noreferrer">Statcounter</a> for site analytics. More infomation can be found in our <a href="/privacy.html">Privacy Policy</a>.</p> <button id="privacy-close" class="privacy-close" aria-label="Close privacy notice"><i class="fa-regular fa-x"></i></button> </div> `; document.body.insertAdjacentHTML('beforeend', privacyNoticeHtml); }
if (!document.getElementById('statcounter-script')) { const statcounterMarkup = ` <!-- Default Statcounter code for Personal Website https://danielmorrisey.com --> <script id="statcounter-script" type="text/javascript"> var sc_project=13337858; var sc_invisible=1; var sc_security="ef3f3a53"; </script> <script type="text/javascript" src="https://www.statcounter.com/counter/counter.js" async></script> <noscript><div class="statcounter"><a title="Web Analytics" href="https://statcounter.com/" target="_blank"><img class="statcounter" src="https://c.statcounter.com/13337858/0/ef3f3a53/1/" alt="Web Analytics" referrerPolicy="no-referrer-when-downgrade"></a></div></noscript> <!-- End of Statcounter Code --> `; document.body.insertAdjacentHTML('beforeend', statcounterMarkup); }
if (!document.getElementById('theme-toggle-wrap')) { const themeToggleHtml = ` <div id="theme-toggle-wrap" class="theme-toggle-wrap"> <button id="theme-toggle" class="theme-toggle" type="button" aria-haspopup="menu" aria-expanded="false" aria-controls="theme-menu"> <span class="theme-toggle-icon" aria-hidden="true"><i class="fa-solid fa-palette"></i></span> </button> <div id="theme-menu" class="theme-menu" role="menu" aria-label="Theme selector"> <button type="button" class="theme-option" data-theme-option="default" role="menuitem" aria-pressed="false">Default</button> <button type="button" class="theme-option" data-theme-option="black" role="menuitem" aria-pressed="false">Black</button> </div> </div> `; document.body.insertAdjacentHTML('beforeend', themeToggleHtml); }
const savedTheme = getCookie(THEME_COOKIE_NAME) || 'default'; applyTheme(savedTheme);
const themeToggleWrap = document.getElementById('theme-toggle-wrap'); const themeToggle = document.getElementById('theme-toggle'); const themeMenu = document.getElementById('theme-menu'); const themeOptions = themeMenu ? themeMenu.querySelectorAll('[data-theme-option]') : [];
if (themeToggle && themeMenu && themeToggleWrap) { themeToggle.addEventListener('click', (event) => { event.stopPropagation(); const isOpen = themeToggleWrap.classList.toggle('open'); themeToggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false'); });
themeOptions.forEach((option) => { option.addEventListener('click', () => { applyTheme(option.getAttribute('data-theme-option')); themeToggleWrap.classList.remove('open'); themeToggle.setAttribute('aria-expanded', 'false'); }); });
document.addEventListener('click', (event) => { if (!themeToggleWrap.contains(event.target)) { themeToggleWrap.classList.remove('open'); themeToggle.setAttribute('aria-expanded', 'false'); } }); }
const isCompactNav = () => window.matchMedia('(max-width: 600px)').matches;
const navToggle = document.querySelector('.nav-toggle'); const navMenu = document.querySelector('.nav-menu');
if (navToggle && navMenu) { const setNavOpen = (open) => { navMenu.classList.toggle('open', open); navToggle.setAttribute('aria-expanded', open ? 'true' : 'false'); const icon = navToggle.querySelector('i'); if (icon) { icon.className = open ? 'fa-solid fa-xmark' : 'fa-solid fa-bars'; } if (!open) { navMenu.querySelectorAll('.nav-dropdown details[open]').forEach((d) => d.removeAttribute('open')); } };
navToggle.addEventListener('click', () => { setNavOpen(!navMenu.classList.contains('open')); });
navMenu.addEventListener('click', (event) => { // close the panel once a real destination is picked const link = event.target.closest('a'); if (link && !link.closest('summary')) setNavOpen(false); });
window.addEventListener('resize', () => { if (!isCompactNav()) setNavOpen(false); }); }
document.querySelectorAll('.nav-dropdown').forEach((dropdown) => { const details = dropdown.querySelector('details'); const summary = dropdown.querySelector('summary'); const menu = dropdown.querySelector('.dropdown-menu');
if (!details || !summary || !menu) return;
let hideTimer;
const openMenu = () => { if (isCompactNav()) return; clearTimeout(hideTimer); details.setAttribute('open', ''); };
const closeMenu = () => { if (isCompactNav()) return; clearTimeout(hideTimer); hideTimer = window.setTimeout(() => { details.removeAttribute('open'); }, 120); };
dropdown.addEventListener('mouseenter', openMenu); dropdown.addEventListener('mouseleave', closeMenu); summary.addEventListener('mouseenter', openMenu); menu.addEventListener('mouseenter', openMenu); menu.addEventListener('mouseleave', closeMenu);
dropdown.addEventListener('focusin', () => { if (isCompactNav()) return; details.setAttribute('open', ''); });
dropdown.addEventListener('focusout', (event) => { if (isCompactNav()) return; if (!dropdown.contains(event.relatedTarget)) { details.removeAttribute('open'); } });
summary.addEventListener('click', (event) => { const clickedLink = event.target.closest('a');
// in the compact menu the summary is a section toggle, not a link — // otherwise its sub-items would be unreachable if (isCompactNav()) { event.preventDefault(); details.toggleAttribute('open'); return; }
if (clickedLink) { return; }
if (window.matchMedia('(hover: hover)').matches) { event.preventDefault(); } }); });
const yearEl = document.getElementById('current-year'); if (yearEl) { yearEl.textContent = new Date().getFullYear(); }
const commitEl = document.getElementById('commit-hash'); if (commitEl) { fetch('https://tangled-hash.danielmorrisey.com/commit') .then((r) => r.json()) .then((data) => { const short = data.commit_hash.slice(0, 7); const date = new Date(data.deployed_at).toLocaleDateString(); const url = `https://tangled.org/danielmorrisey.com/website/commit/${data.commit_hash}`; commitEl.innerHTML = `last updated: ${date} · commit <a href="${url}">${short}</a>`; }) .catch(() => { commitEl.textContent = 'unknown'; }); }
const privacyNotice = document.getElementById('privacy-notice'); const privacyClose = document.getElementById('privacy-close');
if (privacyNotice && privacyClose) { const privacyDismissedKey = 'privacy_notice_dismissed';
if (localStorage.getItem(privacyDismissedKey)) { privacyNotice.classList.add('hidden'); }
privacyClose.addEventListener('click', () => { privacyNotice.classList.add('hidden'); localStorage.setItem(privacyDismissedKey, 'true'); }); } };
if (document.body) { init(); } else { document.addEventListener('DOMContentLoaded', init, { once: true }); }})();