$(document).ready(function () { function encode(r) { return r.replace(/[\x26\x0A\<>'"]/g, function (r) { return "" + r.charCodeAt(0) + ";" }) } $.getJSON("/api", function (data) { $(".players-public").text(data.public_player_count); $(".players-private").text(data.private_player_count); $(".players-total").text(data.total_player_count); $(".games-public").text(data.public_game_count); $(".games-private").text(data.private_game_count); $(".games-total").text(data.total_game_count); $(".in-progress-total").text(data.in_progress_count); $(".proxy-server-total").text(data.master_proxy_count); }); $.getJSON("/api/public_games", function (data) { $.each(data, function () { $(".public-games").append('
' + this.players.map(player => encode(player)).join(', ') + '