added loading to script fetch

This commit is contained in:
Miodec 2022-08-28 16:56:29 +02:00
parent b123bde96e
commit 1605cccc8c

View file

@ -7,6 +7,7 @@ import Config, * as UpdateConfig from "../config";
import * as TestUI from "../test/test-ui";
import * as ConfigEvent from "../observables/config-event";
import * as TestState from "../test/test-state";
import * as Loader from "../elements/loader";
let challengeLoading = false;
@ -204,7 +205,9 @@ export async function setup(challengeName: string): Promise<boolean> {
UpdateConfig.setMode("custom", true);
UpdateConfig.setDifficulty("normal", true);
} else if (challenge.type === "script") {
Loader.show();
const response = await fetch("/challenges/" + challenge.parameters[0]);
Loader.hide();
const scriptdata = await response.text();
let text = scriptdata.trim();
text = text.replace(/[\n\r\t ]/gm, " ");