Spaces:
Running

File size: 1,952 Bytes
5e1643b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Add links only when a verified scene exists in the published release index.
(()=>{
  const own=document.currentScript?.src;if(!own)return;
  const site=new URL('../../',own),url=(cid,key)=>{const u=new URL('gallery/explore.html',site);if(cid)u.searchParams.set('case',cid);if(key)u.searchParams.set('model',key);return u.href;};
  const make=(href,label,className='explore-link')=>{const a=document.createElement('a');a.href=href;a.textContent=label;a.className=className;a.dataset.exploreAdded='true';return a;};
  fetch(new URL('data/explore-scenes.json?v=20261019explore1',site)).then(r=>{if(!r.ok)throw new Error('No scene index');return r.json();}).then(data=>{
    const cases=new Map(data.cases.map(c=>[c.slug,c]));
    for(const nav of document.querySelectorAll('.gal-switch'))if(!nav.querySelector('[data-explore-added]'))nav.append(make(url(),'Explore in 3D',''));
    for(const figure of document.querySelectorAll('figure.gal-tile')){
      const group=figure.querySelector('[data-group]')?.dataset.group;if(!group)continue;
      const [model,slug]=group.split('/');if(cases.get(slug)?.models[model])figure.append(make(url(slug,model),'Explore in 3D ↗'));
    }
    for(const section of document.querySelectorAll('.gal-case')){
      const group=section.querySelector('.gal-views [data-group]')?.dataset.group;if(!group)continue;
      const [model,slug]=group.split('/');if(cases.get(slug)?.models[model])section.querySelector('.gal-case-head')?.append(make(url(slug,model),'Explore in 3D ↗'));
    }
    const crumb=document.querySelector('.gal-crumb'),key=location.pathname.match(/\/model\/([^/]+)\.html$/)?.[1];
    if(crumb&&key&&data.models.some(m=>m.key===key))crumb.append(make(url(null,key),'Explore this agent in 3D ↗','explore-crumb-link'));
    const label=document.querySelector('[data-explore-count]');if(label)label.textContent=data.ready_scenes+' scenes · '+data.models.length+' agents';
  }).catch(()=>{});
})();