diff options
| author | stonedDiscord <Tukz@gmx.de> | 2025-09-03 12:20:42 +0200 |
|---|---|---|
| committer | stonedDiscord <Tukz@gmx.de> | 2025-09-03 12:20:42 +0200 |
| commit | 183fd0fdddbcf194eec08f8e79e6a1709e18d3a9 (patch) | |
| tree | 733426bb0261d3d0593b7739166ea9ab578564b9 /webAO/dom | |
| parent | d8d2fbc8b7bf91dbedc7042daa1081ebd0d1330f (diff) | |
also do bgs
Diffstat (limited to 'webAO/dom')
| -rw-r--r-- | webAO/dom/updateBackgroundPreview.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/webAO/dom/updateBackgroundPreview.ts b/webAO/dom/updateBackgroundPreview.ts index 61186e0..2b8a18b 100644 --- a/webAO/dom/updateBackgroundPreview.ts +++ b/webAO/dom/updateBackgroundPreview.ts @@ -1,5 +1,20 @@ import { AO_HOST } from "../client/aoHost"; -import tryBackgroundUrls from "../utils/tryBackgroundUrls"; +import fileExists from "../utils/fileExists"; +import transparentPng from "../constants/transparentPng"; + +const urlExtensionsToTry = [".png", ".gif", ".webp", ".apng"]; +const tryBackgroundUrls = async (url: string) => { + for (let i = 0; i < urlExtensionsToTry.length; i++) { + const extension = urlExtensionsToTry[i]; + const fullFileUrl = url + extension; + const exists = await fileExists(fullFileUrl); + if (exists) { + return fullFileUrl; + } + } + return transparentPng; +}; +export default tryBackgroundUrls; /** * Update background preview. |
