File size: 2,194 Bytes
7caded9 | 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | document.addEventListener('DOMContentLoaded', function() {
// Search functionality for sidebar
const searchInput = document.querySelector('.search-input input');
const navItems = document.querySelectorAll('.nav-item');
searchInput.addEventListener('input', function() {
const searchTerm = this.value.toLowerCase();
navItems.forEach(item => {
const label = item.querySelector('.nav-label').textContent.toLowerCase();
if (label.includes(searchTerm)) {
item.style.display = 'flex';
} else {
item.style.display = 'none';
}
});
});
// Active state for nav items
navItems.forEach(item => {
item.addEventListener('click', function() {
navItems.forEach(i => i.classList.remove('active'));
this.classList.add('active');
});
});
// Input bar functionality
const messageInput = document.querySelector('.text-input input');
const sendBtn = document.querySelector('.send-btn');
function updateSendButton() {
sendBtn.disabled = messageInput.value.trim() === '';
}
messageInput.addEventListener('input', updateSendButton);
messageInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !sendBtn.disabled) {
e.preventDefault();
// Here you would handle sending the message
console.log('Message sent:', this.value);
this.value = '';
updateSendButton();
}
});
sendBtn.addEventListener('click', function() {
if (!this.disabled) {
// Here you would handle sending the message
console.log('Message sent:', messageInput.value);
messageInput.value = '';
updateSendButton();
}
});
// Microphone button placeholder
const micBtn = document.querySelector('.input-btn:nth-child(3)');
micBtn.addEventListener('click', function() {
alert('Microphone functionality would be implemented here');
});
// Initialize
updateSendButton();
feather.replace();
}); |