From e50167a8077b0ada769cdf785971972c3ad865f7 Mon Sep 17 00:00:00 2001 From: Caleb Date: Fri, 9 Sep 2022 18:30:07 -0400 Subject: Pulled out everything I wanted --- webAO/client/fetchLists.ts | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 webAO/client/fetchLists.ts (limited to 'webAO/client/fetchLists.ts') 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 = 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 = ( + 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 = ( + 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 -- cgit From fbb4ce9fafab3183e27204eccad73c542cb684c8 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 17 Nov 2022 22:51:24 +0100 Subject: custom is entry 0 --- webAO/client/fetchLists.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'webAO/client/fetchLists.ts') diff --git a/webAO/client/fetchLists.ts b/webAO/client/fetchLists.ts index e9772cb..7f0104e 100644 --- a/webAO/client/fetchLists.ts +++ b/webAO/client/fetchLists.ts @@ -26,7 +26,7 @@ export const fetchCharacterList = async () => { // the try catch will fail before here when there is no file const char_select = ( - document.getElementById("client_ininame") + document.getElementById("client_iniselect") ); char_select.innerHTML = ""; @@ -50,10 +50,12 @@ export const fetchEvidenceList = async () => { ); evi_select.innerHTML = ""; + evi_select.add(new Option("Custom", "0")); + 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"); } -- cgit From fa9ca955b10bb272cdc0a1f803efbdd768111c60 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 17 Nov 2022 22:51:58 +0100 Subject: add custom ini --- webAO/client/fetchLists.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'webAO/client/fetchLists.ts') diff --git a/webAO/client/fetchLists.ts b/webAO/client/fetchLists.ts index 7f0104e..bf4fd1b 100644 --- a/webAO/client/fetchLists.ts +++ b/webAO/client/fetchLists.ts @@ -30,6 +30,8 @@ export const fetchCharacterList = async () => { ); char_select.innerHTML = ""; + char_select.add(new Option("Custom", "0")); + char_array.forEach((character: string) => { char_select.add(new Option(character)); }); -- cgit From 14dd6bf87f05a411b4eadcb4f6f37f726341a800 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 17 Nov 2022 23:29:17 +0100 Subject: still have custom if request fails --- webAO/client/fetchLists.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'webAO/client/fetchLists.ts') diff --git a/webAO/client/fetchLists.ts b/webAO/client/fetchLists.ts index bf4fd1b..704c889 100644 --- a/webAO/client/fetchLists.ts +++ b/webAO/client/fetchLists.ts @@ -21,10 +21,6 @@ export const fetchBackgroundList = async () => { 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 = ( document.getElementById("client_iniselect") ); @@ -32,6 +28,10 @@ export const fetchCharacterList = async () => { char_select.add(new Option("Custom", "0")); + 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 + char_array.forEach((character: string) => { char_select.add(new Option(character)); }); @@ -43,10 +43,6 @@ export const fetchCharacterList = async () => { 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 = ( document.getElementById("evi_select") ); @@ -54,6 +50,10 @@ export const fetchEvidenceList = async () => { evi_select.add(new Option("Custom", "0")); + 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 + evi_array.forEach((evi: string) => { evi_select.add(new Option(evi)); }); -- cgit From 0dfae205629db81833ab6281c87fc23fc7e2c33e Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 17 Nov 2022 23:30:02 +0100 Subject: not even gonna try, just do it --- webAO/client/fetchLists.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'webAO/client/fetchLists.ts') diff --git a/webAO/client/fetchLists.ts b/webAO/client/fetchLists.ts index 704c889..38c3236 100644 --- a/webAO/client/fetchLists.ts +++ b/webAO/client/fetchLists.ts @@ -20,14 +20,14 @@ export const fetchBackgroundList = async () => { } export const fetchCharacterList = async () => { - try { - const char_select = ( - document.getElementById("client_iniselect") - ); - char_select.innerHTML = ""; - - char_select.add(new Option("Custom", "0")); + const char_select = ( + document.getElementById("client_iniselect") + ); + char_select.innerHTML = ""; + char_select.add(new Option("Custom", "0")); + + 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 @@ -42,14 +42,14 @@ export const fetchCharacterList = async () => { export const fetchEvidenceList = async () => { - try { - const evi_select = ( - document.getElementById("evi_select") - ); - evi_select.innerHTML = ""; + const evi_select = ( + document.getElementById("evi_select") + ); + evi_select.innerHTML = ""; - evi_select.add(new Option("Custom", "0")); + evi_select.add(new Option("Custom", "0")); + 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 -- cgit From b570cfa8c9a8c878b0112d5b93d884e3eb3a28ef Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sun, 11 Dec 2022 13:39:54 +0100 Subject: grab manifest file --- webAO/client/fetchLists.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'webAO/client/fetchLists.ts') diff --git a/webAO/client/fetchLists.ts b/webAO/client/fetchLists.ts index 38c3236..cedd744 100644 --- a/webAO/client/fetchLists.ts +++ b/webAO/client/fetchLists.ts @@ -61,4 +61,16 @@ export const fetchEvidenceList = async () => { } catch (err) { console.warn("there was no evidence.json file"); } +} + + +export const fetchManifest = async () => { + try { + const manifestdata = await request(`${AO_HOST}manifest.txt`); + const manifest_array = manifestdata.split(/\r\n|\n\r|\n|\r/); + // the try catch will fail before here when there is no file + + } catch (err) { + console.warn("there was no manifest.txt file"); + } } \ No newline at end of file -- cgit From 74f4a34a8c8173863f96fbc03bb9026930219623 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sun, 11 Dec 2022 16:28:42 +0100 Subject: store manifest in client --- webAO/client/fetchLists.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'webAO/client/fetchLists.ts') diff --git a/webAO/client/fetchLists.ts b/webAO/client/fetchLists.ts index cedd744..9efd181 100644 --- a/webAO/client/fetchLists.ts +++ b/webAO/client/fetchLists.ts @@ -1,3 +1,4 @@ +import { client } from "../client"; import { AO_HOST } from "./aoHost"; import { request } from "../services/request.js"; @@ -67,7 +68,7 @@ export const fetchEvidenceList = async () => { export const fetchManifest = async () => { try { const manifestdata = await request(`${AO_HOST}manifest.txt`); - const manifest_array = manifestdata.split(/\r\n|\n\r|\n|\r/); + client.manifest = manifestdata.split(/\r\n|\n\r|\n|\r/); // the try catch will fail before here when there is no file } catch (err) { -- cgit