From f646d83b0e90797dbdafc009cb01ed6c9cf8c7fa Mon Sep 17 00:00:00 2001 From: ajuvercr Date: Tue, 7 Apr 2020 14:13:38 +0200 Subject: [PATCH] visualizer show first game at start --- frontend/www/games.ts | 23 ++++++++++++++++------- frontend/www/index.ts | 21 +-------------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/frontend/www/games.ts b/frontend/www/games.ts index 8e0ae40..f460fb9 100644 --- a/frontend/www/games.ts +++ b/frontend/www/games.ts @@ -7,15 +7,24 @@ const OPTIONS = document.getElementById("options"); const game_location = LOCATION + "static/games/mod.ini"; -fetch(game_location) - .then((r) => r.text()) - .then((response) => { - if (OPTIONS) { +if (OPTIONS) { + fetch(game_location) + .then((r) => r.text()) + .then((response) => { parse_ini(response); - } else { - console.log("Options is not defined, tera?"); + }).catch(console.error); +} else { + const options = document.getElementsByClassName("options"); + if (options[0]) { + const options_div = options[0]; + if (options_div.children[0]) { + setTimeout( + () => options_div.children[0].dispatchEvent(new Event('click')), + 200, + ); } - }).catch(console.error); + } +} export function handle(location, name: string) { set_loading(true); diff --git a/frontend/www/index.ts b/frontend/www/index.ts index a34d535..af6578b 100644 --- a/frontend/www/index.ts +++ b/frontend/www/index.ts @@ -373,25 +373,6 @@ function step(time: number) { requestAnimationFrame(step); } -set_loading(true); +// set_loading(false); requestAnimationFrame(step); - - -// import { voronoi, Point } from './voronoi' -// function test() { -// const points = [ -// new Point(14, 6), -// new Point(13, 11), -// new Point(8, 7.5), -// new Point(7, 4), -// new Point(4, 11), -// ]; - -// console.log(voronoi(points)); -// } - -// import { test as dcelt_test } from './dcel'; -// // dcelt_test(); - -// test();