diff options
Diffstat (limited to 'webAO')
| -rw-r--r-- | webAO/__tests__/tryBackgroundUrls.test.ts (renamed from webAO/__tests__/tryUrls.test.ts) | 8 | ||||
| -rw-r--r-- | webAO/dom/updateBackgroundPreview.ts | 4 | ||||
| -rw-r--r-- | webAO/packets/handlers/handleBN.ts | 22 | ||||
| -rw-r--r-- | webAO/utils/tryBackgroundUrls.ts (renamed from webAO/utils/tryUrls.ts) | 4 | ||||
| -rw-r--r-- | webAO/viewport/utils/setSide.ts | 4 |
5 files changed, 21 insertions, 21 deletions
diff --git a/webAO/__tests__/tryUrls.test.ts b/webAO/__tests__/tryBackgroundUrls.test.ts index 4a32f32..cfbf3f9 100644 --- a/webAO/__tests__/tryUrls.test.ts +++ b/webAO/__tests__/tryBackgroundUrls.test.ts @@ -1,11 +1,11 @@ import fileExists from "../utils/fileExists"; -import tryUrls from "../utils/tryUrls"; +import tryBackgroundUrls from "../utils/tryBackgroundUrls"; import transparentPng from "../constants/transparentPng"; jest.mock("../utils/fileExists"); const mockFileExists = fileExists as jest.MockedFunction<typeof fileExists>; -describe("tryUrls", () => { +describe("tryBackgroundUrls", () => { it("Should try multiple file extensions", async () => { const url = "localhost/stoneddiscord/assets"; mockFileExists @@ -13,7 +13,7 @@ describe("tryUrls", () => { .mockReturnValueOnce(Promise.resolve(false)) .mockReturnValueOnce(Promise.resolve(false)) .mockReturnValueOnce(Promise.resolve(true)); - const actual = await tryUrls(url); + const actual = await tryBackgroundUrls(url); const expected = "localhost/stoneddiscord/assets.apng"; expect(actual).toBe(expected); }); @@ -21,7 +21,7 @@ describe("tryUrls", () => { it("Should return a transparent png if it cant find any assets", async () => { const url = "localhost/stoneddiscord/assets"; mockFileExists.mockReturnValue(Promise.resolve(false)); - const actual = await tryUrls(url); + const actual = await tryBackgroundUrls(url); const expected = transparentPng; expect(actual).toBe(expected); }); diff --git a/webAO/dom/updateBackgroundPreview.ts b/webAO/dom/updateBackgroundPreview.ts index 61eec58..61186e0 100644 --- a/webAO/dom/updateBackgroundPreview.ts +++ b/webAO/dom/updateBackgroundPreview.ts @@ -1,5 +1,5 @@ import { AO_HOST } from "../client/aoHost"; -import tryUrls from "../utils/tryUrls"; +import tryBackgroundUrls from "../utils/tryBackgroundUrls"; /** * Update background preview. @@ -20,7 +20,7 @@ export function updateBackgroundPreview() { } else { background_filename.style.display = "none"; } - tryUrls( + tryBackgroundUrls( `${AO_HOST}background/${encodeURI( background_select.value.toLowerCase(), )}/defenseempty`, diff --git a/webAO/packets/handlers/handleBN.ts b/webAO/packets/handlers/handleBN.ts index aeea03b..5e9e8f8 100644 --- a/webAO/packets/handlers/handleBN.ts +++ b/webAO/packets/handlers/handleBN.ts @@ -5,7 +5,7 @@ import { updateBackgroundPreview } from "../../dom/updateBackgroundPreview"; import { getIndexFromSelect } from "../../dom/getIndexFromSelect"; import { switchPanTilt } from "../../dom/switchPanTilt"; import transparentPng from "../../constants/transparentPng"; -import tryUrls from "../../utils/tryUrls"; +import tryBackgroundUrls from "../../utils/tryBackgroundUrls"; /** * Handles a background change. @@ -28,21 +28,21 @@ export const handleBN = (args: string[]) => { client.viewport.getBackgroundName(); } - tryUrls( + tryBackgroundUrls( `${AO_HOST}background/${encodeURI(args[1].toLowerCase())}/defenseempty`, ).then((resp) => { (<HTMLImageElement>document.getElementById("bg_preview")).src = resp; }); - tryUrls(`${bgfolder}defensedesk`).then((resp) => { + tryBackgroundUrls(`${bgfolder}defensedesk`).then((resp) => { (<HTMLImageElement>document.getElementById("client_def_bench")).src = resp; }); - tryUrls(`${bgfolder}stand`).then((resp) => { + tryBackgroundUrls(`${bgfolder}stand`).then((resp) => { (<HTMLImageElement>document.getElementById("client_wit_bench")).src = resp; }); - tryUrls(`${bgfolder}prosecutiondesk`).then((resp) => { + tryBackgroundUrls(`${bgfolder}prosecutiondesk`).then((resp) => { (<HTMLImageElement>document.getElementById("client_pro_bench")).src = resp; }); - tryUrls(`${bgfolder}court`).then((resp) => { + tryBackgroundUrls(`${bgfolder}court`).then((resp) => { (<HTMLImageElement>document.getElementById("client_court")).src = resp; if (resp !== transparentPng) { (<HTMLInputElement>document.getElementById("client_pantilt")).checked = @@ -50,19 +50,19 @@ export const handleBN = (args: string[]) => { switchPanTilt(); } }); - tryUrls(`${bgfolder}defenseempty`).then((resp) => { + tryBackgroundUrls(`${bgfolder}defenseempty`).then((resp) => { (<HTMLImageElement>document.getElementById("client_court_def")).src = resp; }); - tryUrls(`${bgfolder}transition_def`).then((resp) => { + tryBackgroundUrls(`${bgfolder}transition_def`).then((resp) => { (<HTMLImageElement>document.getElementById("client_court_deft")).src = resp; }); - tryUrls(`${bgfolder}witnessempty`).then((resp) => { + tryBackgroundUrls(`${bgfolder}witnessempty`).then((resp) => { (<HTMLImageElement>document.getElementById("client_court_wit")).src = resp; }); - tryUrls(`${bgfolder}transition_pro`).then((resp) => { + tryBackgroundUrls(`${bgfolder}transition_pro`).then((resp) => { (<HTMLImageElement>document.getElementById("client_court_prot")).src = resp; }); - tryUrls(`${bgfolder}prosecutorempty`).then((resp) => { + tryBackgroundUrls(`${bgfolder}prosecutorempty`).then((resp) => { (<HTMLImageElement>document.getElementById("client_court_pro")).src = resp; }); diff --git a/webAO/utils/tryUrls.ts b/webAO/utils/tryBackgroundUrls.ts index 127bc5b..154978b 100644 --- a/webAO/utils/tryUrls.ts +++ b/webAO/utils/tryBackgroundUrls.ts @@ -1,7 +1,7 @@ import fileExists from "./fileExists"; import transparentPng from "../constants/transparentPng"; const urlExtensionsToTry = [".png", ".gif", ".webp", ".apng"]; -const tryUrls = async (url: string) => { +const tryBackgroundUrls = async (url: string) => { for (let i = 0; i < urlExtensionsToTry.length; i++) { const extension = urlExtensionsToTry[i]; const fullFileUrl = url + extension; @@ -12,4 +12,4 @@ const tryUrls = async (url: string) => { } return transparentPng; }; -export default tryUrls; +export default tryBackgroundUrls; diff --git a/webAO/viewport/utils/setSide.ts b/webAO/viewport/utils/setSide.ts index fd229e1..5966a52 100644 --- a/webAO/viewport/utils/setSide.ts +++ b/webAO/viewport/utils/setSide.ts @@ -1,7 +1,7 @@ import { positions } from "../constants/positions"; import { AO_HOST } from "../../client/aoHost"; import { client } from "../../client"; -import tryUrls from "../../utils/tryUrls"; +import tryBackgroundUrls from "../../utils/tryBackgroundUrls"; import findImgSrc from "../../utils/findImgSrc"; /** @@ -55,7 +55,7 @@ export const set_side = async ({ if (showSpeedLines === true) { court.src = `${AO_HOST}themes/default/${encodeURI(speedLines)}`; } else { - court.src = await tryUrls(client.viewport.getBackgroundFolder() + bg); + court.src = await tryBackgroundUrls(client.viewport.getBackgroundFolder() + bg); } if (showDesk === true && desk) { |
