Repository navigation
Expand file tree
/
Copy pathslides.js
More file actions
26 lines (22 loc) · 5.92 KB
/
Copy pathslides.js
File metadata and controls
26 lines (22 loc) · 5.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const slides=[...document.querySelectorAll('.slide')],toc=document.getElementById('toc');let index=0;
function show(n){index=Math.max(0,Math.min(slides.length-1,n));slides.forEach((s,i)=>{if(i!==index)s.querySelectorAll('video').forEach(v=>v.pause());s.hidden=i!==index;});slides[index].scrollTop=0;document.getElementById('slide-count').textContent=`${index+1} / ${slides.length}`;document.getElementById('chapter-label').textContent=`Section ${slides[index].dataset.chapter} of 5`;document.getElementById('prev').disabled=index===0;document.getElementById('next').disabled=index===slides.length-1;document.getElementById('progress-bar').style.width=`${(index+1)/slides.length*100}%`;history.replaceState(null,'','#'+slides[index].id);window.dispatchEvent(new CustomEvent('workshop-slide',{detail:slides[index].id}));}
function fromHash(){const n=slides.findIndex(s=>'#'+s.id===location.hash);show(n<0?0:n);}
document.getElementById('prev').addEventListener('click',()=>show(index-1));document.getElementById('next').addEventListener('click',()=>show(index+1));document.getElementById('contents').addEventListener('click',()=>toc.showModal());document.getElementById('close-contents').addEventListener('click',()=>toc.close());document.querySelectorAll('[data-index]').forEach(b=>b.addEventListener('click',()=>{show(Number(b.dataset.index));toc.close();}));
document.addEventListener('keydown',e=>{if(document.querySelector('dialog[open]')||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||['INPUT','TEXTAREA','SELECT','VIDEO'].includes(e.target.tagName)||e.target.isContentEditable)return;if(e.key==='ArrowRight'||e.key==='PageDown'){e.preventDefault();show(index+1);}if(e.key==='ArrowLeft'||e.key==='PageUp'){e.preventDefault();show(index-1);}if(e.key==='Home'){e.preventDefault();show(0);}if(e.key==='End'){e.preventDefault();show(slides.length-1);}});
document.getElementById('fullscreen').addEventListener('click',async()=>{try{if(document.fullscreenElement)await document.exitFullscreen();else await document.documentElement.requestFullscreen();}catch{message('Use your browser’s fullscreen command.');}});
let timer;function message(s){const el=document.getElementById('copy-message');el.textContent=s;el.classList.add('visible');clearTimeout(timer);timer=setTimeout(()=>el.classList.remove('visible'),3500);}
document.querySelectorAll('[data-copy],[data-copy-text]').forEach(b=>b.addEventListener('click',async()=>{const source=document.getElementById(b.dataset.copy);const text=b.dataset.copyText||source.value;if(window.GTMWorkshop?.validatePrompt(text,source?.closest('dialog,.slide'))===false)return;try{await navigator.clipboard.writeText(text);message('Copied. Paste into your local Codex or Claude Code project.');}catch{message('Select the full prompt and copy it.');}}));
window.addEventListener('hashchange',fromHash);fromHash();
const promptDialog=document.getElementById('prompt-dialog');let promptOpener;
document.querySelectorAll('[data-open-prompt]').forEach(b=>b.addEventListener('click',e=>{e.preventDefault();const source=document.getElementById('prompt-'+b.dataset.openPrompt);if(!source)return;promptOpener=b;document.getElementById('modal-prompt').value=source.value;const template=source.dataset.sourceTemplate||source.defaultValue;window.GTMWorkshop?.attachPrompt(document.getElementById('modal-prompt'),template);const fields=promptDialog.querySelector('.company-inputs:not(.target-inputs)');fields.hidden=!template.includes('[YOUR_COMPANY_WEBSITE]');const targets=promptDialog.querySelector('.target-inputs');targets.hidden=template.includes('[YOUR_COMPANY_WEBSITE]')||!template.includes('[TARGET_');targets.querySelectorAll('[data-target-row]').forEach(row=>{row.hidden=!template.includes(row.dataset.targetRow==='targetOne'?'[TARGET_1_DOMAIN]':'[TARGET_2_DOMAIN]');});targets.querySelector('.target-input-hint').textContent='Your selected company domains fill this prompt. Copy it into the same local agent.';targets.querySelector('.target-input-title').textContent=template.includes('[TARGET_1_DOMAIN]')&&template.includes('[TARGET_2_DOMAIN]')?'Confirm your two target companies':'Confirm the company for this page';document.getElementById('prompt-title').textContent=source.closest('.slide').querySelector('h1').textContent;promptDialog.showModal();promptDialog.querySelector('[data-close-dialog]').focus();}));
promptDialog.querySelector('[data-close-dialog]').addEventListener('click',()=>promptDialog.close());
promptDialog.addEventListener('close',()=>promptOpener?.focus());
// Pause the page preview and read the exact redacted email without leaving the deck.
document.querySelectorAll('[data-scroll-toggle]').forEach(b=>b.addEventListener('click',()=>{const preview=b.closest('.zuora-browser');const paused=preview.dataset.paused!=='true';preview.dataset.paused=String(paused);b.setAttribute('aria-pressed',String(paused));b.textContent=paused?'Resume scroll':'Pause scroll';}));
const zuoraEmailDialog=document.getElementById('zuora-email-dialog');let zuoraEmailOpener;
document.querySelectorAll('[data-open-email]').forEach(b=>b.addEventListener('click',()=>{zuoraEmailOpener=b;zuoraEmailDialog.showModal();zuoraEmailDialog.querySelector('[data-close-email]').focus();}));
zuoraEmailDialog?.querySelector('[data-close-email]').addEventListener('click',()=>zuoraEmailDialog.close());
zuoraEmailDialog?.addEventListener('close',()=>zuoraEmailOpener?.focus());
document.querySelectorAll("video").forEach(v=>v.addEventListener("error",()=>{const p=v.nextElementSibling;if(p?.classList.contains("media-caption"))p.classList.add("media-error");}));
document.querySelectorAll("details").forEach(d=>d.addEventListener("toggle",()=>{if(!d.open)d.querySelectorAll("video").forEach(v=>v.pause());}));
document.querySelectorAll('[data-jump]').forEach(b=>b.addEventListener('click',()=>{const v=document.getElementById(b.dataset.video);if(!v)return;const seek=()=>{v.currentTime=Number(b.dataset.jump);v.play().catch(()=>{});};if(v.readyState>=1)seek();else{v.addEventListener('loadedmetadata',seek,{once:true});v.load();}}));