mirror of https://git.48k.eu/ogcp
client_search: hide results when the search is empty
Check if the search fields are empty and clear the results if no data is provided.master v1.1.3-39
parent
89cc9d3f9f
commit
b2aa0e3dbb
|
@ -56,6 +56,12 @@
|
|||
const nameFilter = document.getElementById('name-filter').value.toLowerCase();
|
||||
const ipFilter = document.getElementById('ip-filter').value;
|
||||
|
||||
// If both filters are empty, don't display any clients
|
||||
if (!nameFilter && !ipFilter) {
|
||||
document.getElementById('clients-container').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
const filtered = clients.filter(client => {
|
||||
const matchesName = nameFilter ? client.name.toLowerCase().includes(nameFilter) : true;
|
||||
const matchesIP = ipFilter ? client.ip.some(ip => ip.includes(ipFilter)) : true;
|
||||
|
@ -65,7 +71,7 @@
|
|||
renderClients(filtered);
|
||||
}
|
||||
|
||||
renderClients(clients);
|
||||
filterClients();
|
||||
document.getElementById('search-button').addEventListener('click', filterClients);
|
||||
|
||||
// Search on Enter key press
|
||||
|
|
Loading…
Reference in New Issue