modified: static/js/game.js
This commit is contained in:
@@ -76,6 +76,7 @@
|
||||
|
||||
// ---------- Suche / Autocomplete ----------
|
||||
let searchTimer = null;
|
||||
let searchSeq = 0;
|
||||
let suggestions = [];
|
||||
let selectedIndex = -1;
|
||||
|
||||
@@ -84,7 +85,10 @@
|
||||
const q = searchInput.value.trim();
|
||||
if (!q) { closeAutocomplete(); return; }
|
||||
searchTimer = setTimeout(async () => {
|
||||
const mySeq = ++searchSeq;
|
||||
const res = await fetch(`/api/search?q=${encodeURIComponent(q)}`);
|
||||
// Nur die aktuellste Anfrage uebernehmen (Race vermeiden)
|
||||
if (mySeq !== searchSeq) return;
|
||||
suggestions = await res.json();
|
||||
renderAutocomplete();
|
||||
}, 200);
|
||||
|
||||
Reference in New Issue
Block a user