-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyscript.js
More file actions
52 lines (47 loc) · 1.7 KB
/
Copy pathmyscript.js
File metadata and controls
52 lines (47 loc) · 1.7 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
47
48
49
50
51
// Navbar scroll effect
const navbar = document.querySelector('.navbar');
function handleScroll() {
if (window.scrollY > 0) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
}
window.addEventListener('scroll', handleScroll);
// Auto-scrolling review cards (if present)
let currentScroll = 0;
const cardWidth = 320; // width + gap
const reviewTrack = document.querySelector('.review-track');
if (reviewTrack) {
const totalCards = document.querySelectorAll('.review-card').length;
const maxScroll = (totalCards - 3) * cardWidth;
setInterval(() => {
currentScroll += cardWidth;
if (currentScroll > maxScroll) currentScroll = 0;
reviewTrack.style.transform = `translateX(-${currentScroll}px)`;
}, 3000);
}
// Chat input - submit on Enter
const chatInput = document.querySelector('.chat-input-area input');
if (chatInput) {
chatInput.addEventListener('keydown', function (e) {
if (e.key === 'Enter' && chatInput.value.trim() !== '') {
console.log("User asked:", chatInput.value); // Replace with actual handling
chatInput.value = '';
}
});
}
// Button group toggle - toggle on/off individually
const buttons = document.querySelectorAll('.button-group button');
buttons.forEach(btn => {
btn.addEventListener('click', () => {
// If already active, remove it
if (btn.classList.contains('active-toggle')) {
btn.classList.remove('active-toggle');
} else {
// Remove from others, then add to clicked one
buttons.forEach(b => b.classList.remove('active-toggle'));
btn.classList.add('active-toggle');
}
});
});