diff --git a/web/khira/app.js b/web/khira/app.js index 6e24fec..8355f08 100644 --- a/web/khira/app.js +++ b/web/khira/app.js @@ -2925,3 +2925,61 @@ async function boot(u){ setupTurnstile(); } })(); + +/* ── Khira v12 visual enhancer (UI only — no API or state access) ── */ +(function(){ + 'use strict'; + const fine=matchMedia('(pointer:fine)').matches,calm=matchMedia('(prefers-reduced-motion:reduce)').matches; + if(fine&&!calm){ + let raf=0; + document.addEventListener('pointermove',e=>{ + if(raf)return; + raf=requestAnimationFrame(()=>{ + raf=0; + const el=e.target.closest&&e.target.closest('.tile,.card,.analytics-card'); + if(!el)return; + const r=el.getBoundingClientRect(); + el.style.setProperty('--mx',(e.clientX-r.left)+'px'); + el.style.setProperty('--my',(e.clientY-r.top)+'px'); + }); + },{passive:true}); + } + /* Count-up on stat tiles when their numbers change */ + const last=new WeakMap(); + function countUp(root){ + root.querySelectorAll('.tile strong').forEach(el=>{ + const to=parseInt(el.textContent,10); + if(isNaN(to))return; + const key=el.closest('.tile')?.dataset.k||''; + const from=last.get(root)?.[key]??0; + const map=last.get(root)||{};map[key]=to;last.set(root,map); + if(calm||from===to){el.textContent=to;return} + const t0=performance.now(),d=650; + const step=n=>{ + const p=Math.min(1,(n-t0)/d),k=1-Math.pow(1-p,4); + el.textContent=Math.round(from+(to-from)*k); + if(p<1)requestAnimationFrame(step); + }; + requestAnimationFrame(step); + }); + } + ['stats','estats','astats'].forEach(id=>{ + const el=document.getElementById(id); + if(!el)return; + new MutationObserver(()=>countUp(el)).observe(el,{childList:true}); + }); +})(); + +/* ── Sidebar collapse toggle (UI only; remembers choice) ── */ +(function(){ + 'use strict'; + const app=document.getElementById('app'),aside=document.getElementById('sidebar'); + if(!app||!aside)return; + let min=false;try{min=localStorage.getItem('khira_dock')==='min'}catch(e){} + const btn=document.createElement('button'); + btn.type='button';btn.className='dock-toggle'; + btn.innerHTML=''; + const sync=()=>{app.classList.toggle('dock-min',min);btn.setAttribute('aria-label',min?'Expand sidebar':'Collapse sidebar');btn.title=min?'Expand sidebar':'Collapse sidebar'}; + btn.onclick=()=>{min=!min;try{localStorage.setItem('khira_dock',min?'min':'full')}catch(e){}sync()}; + aside.appendChild(btn);sync(); +})(); diff --git a/web/khira/index.html b/web/khira/index.html index c8ca3d8..f5e6eee 100644 --- a/web/khira/index.html +++ b/web/khira/index.html @@ -3,13 +3,13 @@
- +