Skip to content
Liam Fruzyna edited this page Jan 27, 2024 · 1 revision

Config

The Config object loads in an stores all app configuration, both settings and game configs. The primary Config is created in init.js on page load. The constructor has just one parameter, the current game year. This parameter is used to determine which game configs to pull from the server.

Server Side Storage

Configuration files are stored on the server in the /config directory. Global app settings are stored in settings-config.json and annual game configs are stored in YEAR-config.json.

Settings Config

The settings config file stores the following configs:

  • settings
  • defaults
  • users
  • keys
  • theme
  • dark-theme

Game Config

The game config file stores the following configs for the given event year:

  • version
  • pit
  • match
  • smart_stats
  • coach
  • whiteboard

Provided Functions

load_configs(fetch_on_fail=0, on_load='')

Attempts to load in all configs from localStorage. If any configs fail it attempts to pull the source config file from the server. When it's complete a passed function reference is called.

  • fetch_on_fail
    • Used to determine if the config should be pulled from the server on a failure. 0 means fetch either, 1 fetch game config, 2 don't fetch.
  • on_load
    • Function reference used to execute next step on load complete.

load_config(name)

Used by load_configs to fetch a config from localStorage. Returns false if not found.

  • name
    • String name of the config to load, "config-" is prepended to this name.

validate_settings_configs()

Determines if all global app settings configurations are valid. Returns a boolean response, prints errors to console.

validate_game_configs()

Determines if all annual game configurations for the current year are valid. Returns a boolean response, prints errors to console.

validate_{config name}(config_name)

Determines if the config of a given name is valid to that config's expectations. Returns a boolean response, prints errors to console.

  • config_name
    • String name of the config.