frontend side of handling specific games
This commit is contained in:
parent
e3bb2f5d8c
commit
b69f42cb7e
1 changed files with 18 additions and 16 deletions
|
@ -4,28 +4,30 @@ import { ConfigIniParser } from 'config-ini-parser'
|
||||||
|
|
||||||
const OPTIONS = document.getElementById("options");
|
const OPTIONS = document.getElementById("options");
|
||||||
|
|
||||||
|
|
||||||
const game_location = LOCATION + "static/games/mod.ini";
|
const game_location = LOCATION + "static/games/mod.ini";
|
||||||
|
|
||||||
if (OPTIONS) {
|
async function on_load() {
|
||||||
fetch(game_location)
|
if (OPTIONS) {
|
||||||
.then((r) => r.text())
|
const r = await fetch(game_location);
|
||||||
.then((response) => {
|
const response = await r.text();
|
||||||
parse_ini(response);
|
parse_ini(response);
|
||||||
}).catch(console.error);
|
} else {
|
||||||
} else {
|
const options = document.getElementsByClassName("options");
|
||||||
const options = document.getElementsByClassName("options");
|
const urlVars = new URLSearchParams(window.location.search);
|
||||||
if (options[0]) {
|
|
||||||
const options_div = <HTMLDivElement> options[0];
|
if (urlVars.get("game") && urlVars.get("name")) {
|
||||||
if (options_div.children[0]) {
|
handle(urlVars.get("game"),urlVars.get("name"))
|
||||||
setTimeout(
|
} else if (options[0]) {
|
||||||
() => options_div.children[0].dispatchEvent(new Event('click')),
|
const options_div = <HTMLDivElement> options[0];
|
||||||
200,
|
if (options_div.children[0]) {
|
||||||
);
|
options_div.children[0].dispatchEvent(new Event('click'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener("load", on_load);
|
||||||
|
|
||||||
export function handle(location, name: string) {
|
export function handle(location, name: string) {
|
||||||
set_loading(true);
|
set_loading(true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue