Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
3 lines (3 loc) · 2.29 KB
/
Copy pathscript.js
File metadata and controls
3 lines (3 loc) · 2.29 KB
1
2
3
const menu=document.querySelector('.menu');const nav=document.querySelector('.site-header nav');menu?.addEventListener('click',()=>{const open=nav.classList.toggle('open');menu.setAttribute('aria-expanded',open)});document.querySelectorAll('.site-header nav a').forEach(link=>link.addEventListener('click',()=>nav.classList.remove('open')));
const themeButton=document.querySelector('.theme-toggle');const systemTheme=window.matchMedia('(prefers-color-scheme: dark)');const themeNames={system:['☼','System'],light:['☀','Light'],dark:['☾','Dark']};function applyTheme(mode){const dark=mode==='dark'||(mode==='system'&&systemTheme.matches);document.body.classList.toggle('theme-light',!dark);document.querySelectorAll('.brand img').forEach(img=>{img.src=dark?'KirnOS-logos/icon-on-dark-mode.svg':'KirnOS-logos/icon-on-light-mode.svg'});const [icon,label]=themeNames[mode];themeButton?.querySelector('.theme-icon').replaceChildren(icon);themeButton?.querySelector('.theme-label').replaceChildren(label);themeButton?.setAttribute('aria-label',`Theme: ${label}. Click to change.`);themeButton?.setAttribute('title',`Theme: ${label}. Click to change.`);document.documentElement.style.colorScheme=dark?'dark':'light'}let theme=localStorage.getItem('kirnos-theme')||'system';applyTheme(theme);themeButton?.addEventListener('click',()=>{theme=theme==='system'?'light':theme==='light'?'dark':'system';localStorage.setItem('kirnos-theme',theme);applyTheme(theme)});const onSystemThemeChange=()=>{if(theme==='system')applyTheme(theme)};systemTheme.addEventListener?.('change',onSystemThemeChange);systemTheme.addListener?.(onSystemThemeChange);
const typingText=document.querySelector('#typing-text');const typingPhrases=['feel intentional.','stay close to the machine.','make complexity legible.','protect the future.','boot a better idea.'];let phraseIndex=0;let charIndex=0;let deleting=false;function typePhrase(){if(!typingText)return;const phrase=typingPhrases[phraseIndex];if(!deleting){charIndex++;typingText.textContent=phrase.slice(0,charIndex);if(charIndex===phrase.length){deleting=true;setTimeout(typePhrase,1800);return}}else{charIndex--;typingText.textContent=phrase.slice(0,charIndex);if(charIndex===0){deleting=false;phraseIndex=(phraseIndex+1)%typingPhrases.length}}setTimeout(typePhrase,deleting?45:85)}setTimeout(typePhrase,1600);