Skip to content
Andy Herbert edited this page Dec 1, 2025 · 1 revision

app.js is the main script for LaserGraph.

LaserTagApp

Base class for controlling the app. Interacts between the HTML view, and the model, binding controls as needed. This class is unique to the Laser Games data and LaserGraph website.

Class variables

data

JSON data loaded directly from a file.

processor

A LaserTagDataProcessor (see dataProcessor.js) containing processed data and functions to read data.

currentFile

The currently viewed file

Other variables

Visualization classes are stored in class variables- see the source file lines 14-19.

Class functions

async init()

Initializes elements prior to data upload

initFileUpload()

Sets up the file upload element which is shown upon initially loading the page.

handleFile(file)

Called on a file upload event, expects a file from event.target.files[0], stores the file within this.currentFile. Additional functions clearFile(), displayFileInfo(file), and formatFileSize(bytes) are provided to work with files as well, see the source code for info.

processUploadedFile()

After a file is uploaded, this function is called to create this.data and this.processor by reading this.currentFile. If successful, calls this.processAndVisualize().

processAndVisualize()

Calls functions to process data, update text and filtered elements, create visualizations, and update metrics. Sets the time range viewed from 0 to data end.

processData()

Converts this.data into this.processor (new LaserTagDataProcessor).

updateFilterElements()

Updates filter dropdowns with players and teams as appropriate.

showError(message)

Shows an error pop up and logs the message in the log.

refresh()

Calls await this.init()

onTeamSelect(e)

todo

onPlayerSelect(e)

todo

Other functions

toggleUpload()

Shows/hides the file upload element. If shown, sets the document scroll to the top of the page.

resetTimeRange()

Resets the app's viewed range to the entire match.

Clone this wiki locally