class StatisticsPage { constructor() { this.userMode = StatisticsUser != null; } openSocket() { this.socket = new Socket('/ws').onMessage(this.onSocketMessage.bind(this)); } onSocketMessage(e) { this.statistics.load(); } start() { this.openSocket(); this.statistics = Statistics.init(DOM.get('#statistics>.content'), this.userMode ? Statistics.Modes.USER : Statistics.Modes.ALL); return this; } } window_.on('load', (e) => { window.page = new StatisticsPage().start(); });