convo-list separation
This commit is contained in:
26
static/js/conversations-list.js
Normal file
26
static/js/conversations-list.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// Debounce function
|
||||
function debounce(func, wait) {
|
||||
let timeout;
|
||||
return function(...args) {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => func.apply(this, args), wait);
|
||||
};
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const searchInput = document.getElementById('conversationSearchInput');
|
||||
const form = document.getElementById('conversationFilterForm');
|
||||
if (searchInput && form) {
|
||||
searchInput.addEventListener('input', debounce(function() {
|
||||
form.submit();
|
||||
}, 300));
|
||||
}
|
||||
// Clear button logic
|
||||
const clearBtn = document.getElementById('clearConversationsFilter');
|
||||
if (clearBtn && searchInput) {
|
||||
clearBtn.addEventListener('click', function() {
|
||||
searchInput.value = '';
|
||||
form.submit();
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -122,33 +122,6 @@
|
||||
</div>
|
||||
|
||||
{% block extra_js %}
|
||||
<script>
|
||||
// Debounce function
|
||||
function debounce(func, wait) {
|
||||
let timeout;
|
||||
return function(...args) {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => func.apply(this, args), wait);
|
||||
};
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const searchInput = document.getElementById('conversationSearchInput');
|
||||
const form = document.getElementById('conversationFilterForm');
|
||||
if (searchInput && form) {
|
||||
searchInput.addEventListener('input', debounce(function() {
|
||||
form.submit();
|
||||
}, 300));
|
||||
}
|
||||
// Clear button logic
|
||||
const clearBtn = document.getElementById('clearConversationsFilter');
|
||||
if (clearBtn && searchInput) {
|
||||
clearBtn.addEventListener('click', function() {
|
||||
searchInput.value = '';
|
||||
form.submit();
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/conversations-list.js') }}"></script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user