yayy now it works
This commit is contained in:
@@ -18,8 +18,7 @@ public class WebServer {
|
||||
|
||||
@GetMapping("/api/fuzzy")
|
||||
@ResponseBody
|
||||
public ArrayList<BonusItem> index(@RequestParam(value = "q", required = true) String fuzzySearch, Model model){
|
||||
// Call your BonusManager or service to get items
|
||||
public ArrayList<BonusItem> fuzzySearch(@RequestParam(value = "q", required = false, defaultValue = "") String fuzzySearch){
|
||||
ArrayList<BonusItem> items = BonusManager.getBonusItems(fuzzySearch);
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -134,18 +134,16 @@
|
||||
const resultCount = document.getElementById('resultCount');
|
||||
let debounceTimer;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
performFuzzySearch('');
|
||||
});
|
||||
|
||||
searchInput.addEventListener('input', (e) => {
|
||||
clearTimeout(debounceTimer);
|
||||
const query = e.target.value.trim();
|
||||
|
||||
// Debounce: wait 300ms before searching
|
||||
debounceTimer = setTimeout(() => {
|
||||
if (query.length === 0) {
|
||||
// Reset to all items
|
||||
location.reload();
|
||||
} else {
|
||||
performFuzzySearch(query);
|
||||
}
|
||||
performFuzzySearch(query); // Always call API, even for empty string
|
||||
}, 300);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user