44 lines
5.1 KiB
HTML
44 lines
5.1 KiB
HTML
<script>
|
|
(() => {
|
|
const sections = [{"id": "current-supports", "label": "What supports demand", "color": "#434343", "ink": "#FFFFFF"}, {"id": "productivity-handoff", "label": "The productivity handoff", "color": "#00FF00", "ink": "#000000"}, {"id": "transition-pressure", "label": "The transition pressures", "color": "#980000", "ink": "#FFFFFF"}, {"id": "possible-responses", "label": "What could change the path", "color": "#00FFFF", "ink": "#000000"}, {"id": "business-agency", "label": "What businesses can do now", "color": "#93C47D", "ink": "#000000"}, {"id": "experience-trust", "label": "Experiences and trust", "color": "#FFFF00", "ink": "#000000"}];
|
|
function init() {
|
|
const reveal = window.Reveal;
|
|
if (!reveal || !reveal.isReady()) { setTimeout(init, 100); return; }
|
|
const slides = [...document.querySelectorAll('.reveal .slides section.slide')];
|
|
const nav = document.createElement('nav'); nav.id='es-outline'; nav.setAttribute('aria-label','Slide outline');
|
|
nav.innerHTML='<p class="outline-title">Emerging<br>Undercurrents</p><a href="#/title-slide">Cover</a><a href="#/contents">Table of Contents</a>';
|
|
let current=null, group=null;
|
|
slides.forEach(slide => {
|
|
const section=sections.find(s=>s.id===slide.id);
|
|
if(section) {
|
|
current=section;
|
|
group=document.createElement('details'); group.dataset.section=section.id;
|
|
group.style.setProperty('--section-color',section.color);
|
|
const summary=document.createElement('summary'); summary.textContent=section.label;
|
|
group.append(summary); nav.append(group);
|
|
const h=slide.querySelector('h1'); if(h) { const span=document.createElement('span');span.textContent=h.textContent;h.replaceChildren(span); }
|
|
}
|
|
if(slide.classList.contains('standalone')) {current=null;group=null;}
|
|
if(current) {
|
|
slide.dataset.esSection=current.id;
|
|
const back=document.createElement('a'); back.className='es-return'; back.href='#/contents';back.textContent='Go Back To Outline Page';slide.append(back);
|
|
const foot=document.createElement('div');foot.className='es-footer';foot.style.background=current.color;foot.style.color=current.ink;
|
|
const label=document.createElement('span');label.textContent=current.label.toUpperCase();foot.append(label);
|
|
const author=document.createElement('a');author.href='https://eddiesoehnel.com/';author.textContent='Copyright © Eddie Soehnel';author.target='_blank';author.rel='noopener';foot.append(author);slide.append(foot);
|
|
const a=document.createElement('a');a.href='#/'+slide.id;a.dataset.slideId=slide.id;a.textContent=slide.querySelector('h1,h2')?.textContent || slide.id;group.append(a);
|
|
} else if(slide.classList.contains('standalone')) {
|
|
const a=document.createElement('a');a.href='#/'+slide.id;a.dataset.slideId=slide.id;a.textContent=slide.querySelector('h2')?.textContent || slide.id;nav.append(a);
|
|
}
|
|
});
|
|
slides.filter(s=>s.classList.contains('evidence')).forEach(s=>{const img=s.querySelector('img');if(!img)return;const button=document.createElement('button');button.className='chart-open';button.textContent='Open chart at full size';button.onclick=()=>{const viewer=document.createElement('div');viewer.id='chart-viewer';viewer.setAttribute('role','dialog');viewer.setAttribute('aria-label',img.alt);viewer.setAttribute('aria-modal','true');const close=document.createElement('button');close.textContent='Close chart';close.onclick=()=>{viewer.remove();button.focus();};const full=document.createElement('img');full.src=img.src;full.alt=img.alt;viewer.append(close,full);document.body.append(viewer);close.focus();viewer.onkeydown=e=>{e.stopPropagation();if(e.key==='Escape'){e.preventDefault();close.click();}if(e.key==='Tab'){e.preventDefault();close.focus();}};};s.querySelector('figure')?.append(button);});
|
|
const help=document.createElement('p');help.className='outline-help';help.textContent='Expand a section to jump to any slide. M: menu · O: overview · S: notes · F: full screen';nav.append(help);document.body.append(nav);
|
|
const toggle=document.createElement('button');toggle.id='es-outline-toggle';toggle.textContent='Outline';toggle.setAttribute('aria-label','Show or hide slide outline');toggle.setAttribute('aria-expanded','true');
|
|
toggle.onclick=()=>{ if(window.innerWidth<=800){document.body.classList.toggle('mobile-outline');toggle.setAttribute('aria-expanded',document.body.classList.contains('mobile-outline'));}else{document.body.classList.toggle('outline-hidden');toggle.setAttribute('aria-expanded',!document.body.classList.contains('outline-hidden'));}reveal.layout();};document.body.append(toggle);
|
|
nav.addEventListener('click',e=>{const a=e.target.closest('a');if(!a)return;const id=a.hash.replace(/^#\/?/,'');const target=document.getElementById(id);if(target){e.preventDefault();const ix=reveal.getIndices(target);reveal.slide(ix.h,ix.v);}});
|
|
function update() {const s=reveal.getCurrentSlide();nav.querySelectorAll('a').forEach(a=>{if(a.hash==='#/'+s.id){a.setAttribute('aria-current','page');}else{a.removeAttribute('aria-current');}});nav.querySelectorAll('details').forEach(d=>{d.open=d.dataset.section===s.dataset.esSection;});}
|
|
reveal.on('slidechanged',update);update();reveal.layout();
|
|
}
|
|
window.addEventListener('load',init);
|
|
})();
|
|
</script>
|