From d4465c20a8774f9d5170d34ce411c4f75fb2625e Mon Sep 17 00:00:00 2001 From: Kobe Date: Wed, 28 May 2025 10:05:00 +0200 Subject: [PATCH] rooms list separation --- static/js/rooms-list.js | 26 ++++++++++++++++++++++++++ templates/rooms/rooms.html | 29 +---------------------------- 2 files changed, 27 insertions(+), 28 deletions(-) create mode 100644 static/js/rooms-list.js diff --git a/static/js/rooms-list.js b/static/js/rooms-list.js new file mode 100644 index 0000000..f78b858 --- /dev/null +++ b/static/js/rooms-list.js @@ -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('roomSearchInput'); + const form = document.getElementById('roomFilterForm'); + if (searchInput && form) { + searchInput.addEventListener('input', debounce(function() { + form.submit(); + }, 300)); + } + // Clear button logic + const clearBtn = document.getElementById('clearRoomsFilter'); + if (clearBtn && searchInput) { + clearBtn.addEventListener('click', function() { + searchInput.value = ''; + form.submit(); + }); + } +}); \ No newline at end of file diff --git a/templates/rooms/rooms.html b/templates/rooms/rooms.html index 13f7425..5d1f29c 100644 --- a/templates/rooms/rooms.html +++ b/templates/rooms/rooms.html @@ -133,33 +133,6 @@ {% block extra_js %} - + {% endblock %} {% endblock %} \ No newline at end of file