Skip to content

Commit

Permalink
Merge pull request #43 from EXtremeExploit/medals-search-by-mods
Browse files Browse the repository at this point in the history
medals: Allow searching by mods
  • Loading branch information
Tanza3D authored Jun 1, 2023
2 parents dfd1206 + 68718cc commit caa1ebd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions medals/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,19 @@ async function requestMedals(init, strValue) {

let filteredMedalsArrayByGroup = [];
for (let v of Object.values(colMedals)) {
let doModsMatch = false;
for (const word of strValue.split(' ')) {
if (v.Mods == '' || v.Mods == null) break;
doModsMatch = v.Mods.replace(',', '').toUpperCase().includes(word.toUpperCase());
if (doModsMatch) break;
}

// Match Name, Solution, Description, Instructions and medal id
if (v.Name.toLowerCase().includes(strValue.toLowerCase()) ||
v.Solution?.toLowerCase().includes(strValue.toLowerCase()) ||
v.Description?.toLowerCase().includes(strValue.toLowerCase()) ||
v.Instructions?.toLowerCase().includes(strValue.toLowerCase()) ||
doModsMatch ||
v.MedalID == parseInt(strValue)) {
if (filteredMedalsArrayByGroup[v.Grouping] == null) filteredMedalsArrayByGroup[v.Grouping] = [];
filteredMedalsArrayByGroup[v.Grouping].push(v);
Expand Down

0 comments on commit caa1ebd

Please sign in to comment.