Skip to content

Commit

Permalink
Search: Handle input being codename
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Oct 3, 2024
1 parent a3b4fa6 commit 8dd1c93
Showing 1 changed file with 74 additions and 4 deletions.
78 changes: 74 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@
{
window.dict = dict;
window.dict_entries = Object.entries(window.dict).sort(([key1, value1], [key2, value2]) => value1.length - value2.length);
window.ExportWarframes = ExportWarframes;
window.ExportWeapons = ExportWeapons;
window.ExportUpgrades = ExportUpgrades;
window.ExportArcanes = ExportArcanes;
window.ExportResources = ExportResources;
window.ExportFlavour = ExportFlavour;
window.ExportCustoms = ExportCustoms;
window.ExportGear = ExportGear;
window.ExportSentinels = ExportSentinels
window.ExportRewards = ExportRewards;
window.ExportRegions = ExportRegions;
window.ExportEnemies = ExportEnemies;
window.ExportTextIcons = ExportTextIcons;
window.supplementalGlyphData = supplementalGlyphData;

window.ExportWarframes_entries = Object.entries(ExportWarframes);
window.ExportWeapons_entries = Object.entries(ExportWeapons);
window.ExportUpgrades_entries = Object.entries(ExportUpgrades);
Expand All @@ -84,10 +99,6 @@
window.ExportGear_entries = Object.entries(ExportGear);
window.ExportSentinels_entries = Object.entries(ExportSentinels)
window.ExportRewards_entries = Object.entries(ExportRewards);
window.ExportRegions = ExportRegions;
window.ExportEnemies = ExportEnemies;
window.ExportTextIcons = ExportTextIcons;
window.supplementalGlyphData = supplementalGlyphData;

window.itemToRecipeMap = {};
Object.entries(ExportRecipes).forEach(([uniqueName, recipe]) => {
Expand Down Expand Up @@ -191,6 +202,16 @@ function doQuery(query)
});
console.timeEnd("Sort results");

console.time("Try for direct result");
{
const direct_result = getResultFromUniqueName(query);
if (direct_result)
{
results.unshift(direct_result);
}
}
console.timeEnd("Try for direct result");

const tags_shown = {};
document.getElementById("results").textContent = results.length == 0 ? "Found 0 results." : "";
results.forEach(result =>
Expand Down Expand Up @@ -679,6 +700,55 @@ function resolveTagsToUses(results)
}
return res;
}

function getResultFromUniqueName(uniqueName)
{
let entry = ExportWarframes[uniqueName];
if (entry)
{
return { type: "warframe", key: uniqueName, value: entry };
}
entry = ExportWeapons[uniqueName];
if (entry)
{
return { type: "weapon", key: uniqueName, value: entry };
}
entry = ExportUpgrades[uniqueName];
if (entry)
{
return { type: "upgrade", key: uniqueName, value: entry };
}
entry = ExportArcanes[uniqueName];
if (entry)
{
return { type: "arcane", key: uniqueName, value: entry };
}
entry = ExportResources[uniqueName];
if (entry)
{
return { type: "resource", key: uniqueName, value: entry };
}
entry = ExportFlavour[uniqueName];
if (entry)
{
return { type: "flavour", key: uniqueName, value: entry };
}
entry = ExportCustoms[uniqueName];
if (entry)
{
return { type: "custom", key: uniqueName, value: entry };
}
entry = ExportGear[uniqueName];
if (entry)
{
return { type: "gear", key: uniqueName, value: entry };
}
entry = ExportSentinels[uniqueName];
if (entry)
{
return { type: "sentinel", key: uniqueName, value: entry };
}
}
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
Expand Down

0 comments on commit 8dd1c93

Please sign in to comment.