fix search on rooms
This commit is contained in:
@@ -1836,5 +1836,64 @@ function navigateToParent() {
|
||||
const parentPath = parts.join('/');
|
||||
navigateTo(parentPath);
|
||||
}
|
||||
|
||||
// Add debounce function
|
||||
function debounce(func, wait) {
|
||||
let timeout;
|
||||
return function executedFunction(...args) {
|
||||
const later = () => {
|
||||
clearTimeout(timeout);
|
||||
func(...args);
|
||||
};
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
};
|
||||
}
|
||||
|
||||
// Add search functionality
|
||||
function performSearch(searchTerm) {
|
||||
if (!window.currentFiles) return;
|
||||
|
||||
const filteredFiles = window.currentFiles.filter(file => {
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
return file.name.toLowerCase().includes(searchLower) ||
|
||||
(file.type && file.type.toLowerCase().includes(searchLower));
|
||||
});
|
||||
|
||||
renderFiles(filteredFiles);
|
||||
}
|
||||
|
||||
// Add event listeners for search
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const searchInput = document.getElementById('quickSearchInput');
|
||||
const clearSearchBtn = document.getElementById('clearSearchBtn');
|
||||
|
||||
if (searchInput) {
|
||||
// Create debounced search function
|
||||
const debouncedSearch = debounce((searchTerm) => {
|
||||
if (searchTerm) {
|
||||
performSearch(searchTerm);
|
||||
clearSearchBtn.style.display = 'block';
|
||||
} else {
|
||||
fetchFiles(); // Reset to show all files
|
||||
clearSearchBtn.style.display = 'none';
|
||||
}
|
||||
}, 300);
|
||||
|
||||
searchInput.addEventListener('input', function(e) {
|
||||
const searchTerm = e.target.value.trim();
|
||||
debouncedSearch(searchTerm);
|
||||
});
|
||||
|
||||
// Add clear search button functionality
|
||||
if (clearSearchBtn) {
|
||||
clearSearchBtn.addEventListener('click', function() {
|
||||
searchInput.value = '';
|
||||
fetchFiles(); // Reset to show all files
|
||||
clearSearchBtn.style.display = 'none';
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user