forked from QuantumLogicsLabs/DlsAIChatbot-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
46 lines (41 loc) · 1.24 KB
/
Copy pathscript.js
File metadata and controls
46 lines (41 loc) · 1.24 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Light interactivity for the DLS AI Chatbot project guide.
*/
document.querySelectorAll('.command-card code, .command-block code').forEach((el) => {
el.style.cursor = 'pointer';
el.title = 'Click to copy';
el.addEventListener('click', async () => {
const text = el.textContent.trim();
try {
await navigator.clipboard.writeText(text);
const original = el.textContent;
el.textContent = 'Copied!';
setTimeout(() => {
el.textContent = original;
}, 1200);
} catch {
/* clipboard not available — ignore */
}
});
});
const sections = document.querySelectorAll('.section[id]');
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
},
{ threshold: 0.08, rootMargin: '0px 0px -40px 0px' }
);
sections.forEach((section) => {
section.style.opacity = '0';
section.style.transform = 'translateY(12px)';
section.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
observer.observe(section);
});
document.head.insertAdjacentHTML(
'beforeend',
'<style>.section.visible { opacity: 1 !important; transform: translateY(0) !important; }</style>'
);