forked from GCA-Classroom/WD-LL16-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
20 lines (18 loc) · 743 Bytes
/
script.js
File metadata and controls
20 lines (18 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Get chatbot elements
const chatbotToggleBtn = document.getElementById('chatbotToggleBtn');
const chatbotPanel = document.getElementById('chatbotPanel');
if (chatbotToggleBtn && chatbotPanel) {
// Toggle chat open/closed when clicking the button
chatbotToggleBtn.addEventListener('click', () => {
chatbotPanel.classList.toggle('open');
});
// Close chat when clicking anywhere except the chat panel or button
document.addEventListener('click', (e) => {
// If chat is open AND user clicked outside chat area, close it
if (chatbotPanel.classList.contains('open') &&
!chatbotPanel.contains(e.target) &&
!chatbotToggleBtn.contains(e.target)) {
chatbotPanel.classList.remove('open');
}
});
}