Do a new getContents if the search field is cleared

This commit is contained in:
Junior 2024-12-16 11:19:39 -05:00
parent 851b5156d7
commit 7b7f866582

View File

@ -2,6 +2,7 @@
var kindlemail = "";
var currentpath = "";
var searchTimeout = null;
var lastSearch = "";
$(document).ready(function() {
getContents();
@ -35,6 +36,10 @@ $(document).ready(function() {
$("#search").on("change keyup", function() {
if ( searchTimeout ) clearTimeout(searchTimeout);
if ( $("#search").val().length > 2 ) searchTimeout = setTimeout(getContents, 500);
if ( ($("#search").val() == "") && (lastSearch != "") ) {
lastSearch = "";
getContents();
}
});
});
@ -50,7 +55,10 @@ function redirectToLogin() {
function getContents() {
if ( searchTimeout ) clearTimeout(searchTimeout);
var data = {};
if ( $("#search").val() != "" ) data.search = $("#search").val();
if ( $("#search").val() != "" ) {
data.search = $("#search").val();
lastSearch = data.search;
}
$.ajax({
url : 'ajax/getcontents.php',
data : data,