aboutsummaryrefslogtreecommitdiff
path: root/webAO/client/fetchLists.ts
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2022-09-10 14:12:53 +0200
committerGitHub <noreply@github.com>2022-09-10 14:12:53 +0200
commitabba7630e13f7e5269c14c2c43b66b03559ddfe3 (patch)
tree4770a2375d594ef080aa4ad8262aa2df42831c26 /webAO/client/fetchLists.ts
parent09a23ea9d7ee37d8e2dfb036786c41ce37496c51 (diff)
parent93979636fb5d1c60f0da3290e80eb3ca9ead992f (diff)
Merge pull request #173 from caleb-mabry/trying-to-minimize
Client at 297 lines
Diffstat (limited to 'webAO/client/fetchLists.ts')
-rw-r--r--webAO/client/fetchLists.ts60
1 files changed, 60 insertions, 0 deletions
diff --git a/webAO/client/fetchLists.ts b/webAO/client/fetchLists.ts
new file mode 100644
index 0000000..e9772cb
--- /dev/null
+++ b/webAO/client/fetchLists.ts
@@ -0,0 +1,60 @@
+import { AO_HOST } from "./aoHost";
+import { request } from "../services/request.js";
+
+export const fetchBackgroundList = async () => {
+ try {
+ const bgdata = await request(`${AO_HOST}backgrounds.json`);
+ const bg_array = JSON.parse(bgdata);
+ // the try catch will fail before here when there is no file
+
+ const bg_select = <HTMLSelectElement>document.getElementById("bg_select");
+ bg_select.innerHTML = "";
+
+ bg_select.add(new Option("Custom", "0"));
+ bg_array.forEach((background: string) => {
+ bg_select.add(new Option(background));
+ });
+ } catch (err) {
+ console.warn("there was no backgrounds.json file");
+ }
+}
+
+export const fetchCharacterList = async () => {
+ try {
+ const chardata = await request(`${AO_HOST}characters.json`);
+ const char_array = JSON.parse(chardata);
+ // the try catch will fail before here when there is no file
+
+ const char_select = <HTMLSelectElement>(
+ document.getElementById("client_ininame")
+ );
+ char_select.innerHTML = "";
+
+ char_array.forEach((character: string) => {
+ char_select.add(new Option(character));
+ });
+ } catch (err) {
+ console.warn("there was no characters.json file");
+ }
+}
+
+
+export const fetchEvidenceList = async () => {
+ try {
+ const evidata = await request(`${AO_HOST}evidence.json`);
+ const evi_array = JSON.parse(evidata);
+ // the try catch will fail before here when there is no file
+
+ const evi_select = <HTMLSelectElement>(
+ document.getElementById("evi_select")
+ );
+ evi_select.innerHTML = "";
+
+ evi_array.forEach((evi: string) => {
+ evi_select.add(new Option(evi));
+ });
+ evi_select.add(new Option("Custom", "0"));
+ } catch (err) {
+ console.warn("there was no evidence.json file");
+ }
+} \ No newline at end of file