Skip to content

Commit

Permalink
Use content.warframe.com for higher-quality images when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Nov 28, 2024
1 parent ded7aa8 commit 943da49
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
21 changes: 21 additions & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ if (localStorage.getItem("lang"))
setLanguageIndicator(localStorage.getItem("lang"));
}

// Images

function setImageSource(img, icon)
{
if (icon in ExportImages)
{
img.src = "https://content.warframe.com/PublicExport" + icon + "!" + ExportImages[icon].contentHash;

// Fix for /Lotus/Interface/Icons/Player/ContentCreators/DeathMa666ot.png
img.onerror = function()
{
console.warn("Failed to load icon from content.warframe.com:", icon);
img.src = "https://browse.wf" + icon;
};
}
else
{
img.src = "https://browse.wf" + icon;
}
}

// Text icons

function resolveTextIcons(text)
Expand Down
6 changes: 4 additions & 2 deletions glyphs.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@
Promise.all([
getDictPromise(),
fetch("https://browse.wf/warframe-public-export-plus/ExportFlavour.json").then(res => res.json()),
fetch("https://browse.wf/warframe-public-export-plus/ExportImages.json").then(res => res.json()),
fetch("supplemental-data/glyphs.json").then(res => res.json())
]).then(([ dict, ExportFlavour, supplementalGlyphData ]) =>
]).then(([ dict, ExportFlavour, ExportImages, supplementalGlyphData ]) =>
{
window.dict = dict;
window.ExportFlavour = ExportFlavour;
window.ExportImages = ExportImages;
window.supplementalGlyphData = supplementalGlyphData;

updateList();
Expand Down Expand Up @@ -113,7 +115,7 @@ function updateList()
{
const img = document.createElement("img");
img.alt = img.title = (dict[item.name] ?? b[1].name);
img.src = "https://browse.wf" + item.icon;
setImageSource(img, item.icon);
glyph.appendChild(img);
}
document.getElementById("list").appendChild(glyph);
Expand Down
5 changes: 4 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
fetch("https://browse.wf/warframe-public-export-plus/ExportRegions.json").then(res => res.json()),
fetch("https://browse.wf/warframe-public-export-plus/ExportEnemies.json").then(res => res.json()),
fetch("https://browse.wf/warframe-public-export-plus/ExportRecipes.json").then(res => res.json()),
fetch("https://browse.wf/warframe-public-export-plus/ExportImages.json").then(res => res.json()),
fetch("https://browse.wf/warframe-public-export-plus/ExportTextIcons.json").then(res => res.json()),
fetch("supplemental-data/glyphs.json").then(res => res.json())
]).then(([
Expand All @@ -68,6 +69,7 @@
ExportRegions,
ExportEnemies,
ExportRecipes,
ExportImages,
ExportTextIcons,
supplementalGlyphData
]) =>
Expand All @@ -86,6 +88,7 @@
window.ExportRewards = ExportRewards;
window.ExportRegions = ExportRegions;
window.ExportEnemies = ExportEnemies;
window.ExportImages = ExportImages;
window.ExportTextIcons = ExportTextIcons;
window.supplementalGlyphData = supplementalGlyphData;

Expand Down Expand Up @@ -237,7 +240,7 @@ function doQuery(query)
{
const img = document.createElement("img");
img.className = "img-fluid rounded-start";
img.src = "https://browse.wf" + result.value.icon;
setImageSource(img, result.value.icon);
col.appendChild(img);
}
row.appendChild(col);
Expand Down

0 comments on commit 943da49

Please sign in to comment.