Started room separation

This commit is contained in:
2025-05-28 11:37:25 +02:00
parent 11446e00db
commit 9b98370989
11 changed files with 1905 additions and 1813 deletions

View File

@@ -0,0 +1,61 @@
export class SearchManager {
constructor(roomManager) {
this.roomManager = roomManager;
this.searchInput = document.getElementById('quickSearchInput');
this.clearSearchBtn = document.getElementById('clearSearchBtn');
}
initialize() {
if (!this.searchInput) return;
// Create debounced search function
const debouncedSearch = this.debounce((searchTerm) => {
if (searchTerm) {
this.performSearch(searchTerm);
this.clearSearchBtn.style.display = 'block';
} else {
this.roomManager.fileManager.fetchFiles(); // Reset to show all files
this.clearSearchBtn.style.display = 'none';
}
}, 300);
// Add input event listener
this.searchInput.addEventListener('input', (e) => {
const searchTerm = e.target.value.trim();
debouncedSearch(searchTerm);
});
// Add clear search button functionality
if (this.clearSearchBtn) {
this.clearSearchBtn.addEventListener('click', () => {
this.searchInput.value = '';
this.roomManager.fileManager.fetchFiles(); // Reset to show all files
this.clearSearchBtn.style.display = 'none';
});
}
}
performSearch(searchTerm) {
if (!this.roomManager.fileManager.currentFiles) return;
const filteredFiles = this.roomManager.fileManager.currentFiles.filter(file => {
const searchLower = searchTerm.toLowerCase();
return file.name.toLowerCase().includes(searchLower) ||
(file.type && file.type.toLowerCase().includes(searchLower));
});
this.roomManager.viewManager.renderFiles(filteredFiles);
}
debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
}