aboutsummaryrefslogtreecommitdiff
path: root/webAO/utils/fileExists.ts
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2023-11-30 02:35:02 +0100
committerGitHub <noreply@github.com>2023-11-30 02:35:02 +0100
commit4435a4014c0a68fc156a29f83e01cbfab4912794 (patch)
tree3c4f6927ae2c515dca1585430aca6cd7f1bf8874 /webAO/utils/fileExists.ts
parent92aa1322f8b086484a74f40619cf60b4b702720c (diff)
parent90ed4b74cac7e8e410175cc3445d7140671e221f (diff)
Merge pull request #205 from Troid-Tech/fix-missing-desks
Fix missing desks
Diffstat (limited to 'webAO/utils/fileExists.ts')
-rw-r--r--webAO/utils/fileExists.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/webAO/utils/fileExists.ts b/webAO/utils/fileExists.ts
new file mode 100644
index 0000000..abb2928
--- /dev/null
+++ b/webAO/utils/fileExists.ts
@@ -0,0 +1,19 @@
+export default async function fileExists(url: string): Promise<boolean> {
+ return new Promise((resolve) => {
+ const xhr = new XMLHttpRequest();
+ xhr.open('HEAD', url);
+ xhr.onload = function checkLoad() {
+ if (xhr.readyState === 4) {
+ if (xhr.status === 200) {
+ resolve(true);
+ } else {
+ resolve(false);
+ }
+ }
+ };
+ xhr.onerror = function checkError() {
+ resolve(false);
+ };
+ xhr.send(null);
+ });
+}