Searching...
-
- {{ game }}
+
+ {{ soundtrack }}
No results found
@@ -38,6 +48,7 @@ export default {
results: [],
loading: false,
searchTimeout: null,
+ searchType: "fuzzy",
};
},
methods: {
@@ -45,6 +56,7 @@ export default {
this.show = true;
this.searchTerm = "";
this.results = [];
+ this.searchType = "fuzzy";
},
closeModal() {
this.show = false;
@@ -78,49 +90,70 @@ export default {
}
this.loading = true;
try {
+ const endpoint = this.searchType === 'fuzzy' ? '/findfuzzy' : '/find';
const response = await this.axios({
method: "post",
- url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/find`,
+ url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}${endpoint}`,
data: new URLSearchParams({ search_term: this.searchTerm }),
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
});
- // Parse games from HTML response
- this.results = this.parseGamesFromResponse(response.data);
+ // Parse soundtracks from HTML response
+ this.results = this.parseSoundtracksFromResponse(response.data);
} catch (error) {
- console.error("Error searching games:", error);
+ console.error("Error searching soundtracks:", error);
this.results = [];
} finally {
this.loading = false;
}
},
- parseGamesFromResponse(htmlData) {
- // The server returns HTML from FoundGames templ component
- // It generates divs containing game names in
tags
- const games = [];
+ parseSoundtracksFromResponse(htmlData) {
+ // The server returns HTML from FoundSoundtracks templ component
+ // It generates divs containing soundtrack names in
tags
+ const soundtracks = [];
const parser = new DOMParser();
const doc = parser.parseFromString(htmlData, "text/html");
- // Find all p tags inside divs (the templ generates
)
+ // Find all p tags inside divs (the templ generates
)
const pTags = doc.querySelectorAll("div p");
for (const p of pTags) {
- const gameName = p.textContent.trim();
- if (gameName) {
- games.push(gameName);
+ const soundtrackName = p.textContent.trim();
+ if (soundtrackName) {
+ soundtracks.push(soundtrackName);
}
}
- return games;
+ return soundtracks;
},
},
};