$(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_players_count); $(".players-private").text(data.private_players_count); $(".players-total").text(data.total_players_count); $(".games-public").text(data.public_games_count); $(".games-private").text(data.private_games_count); $(".games-total").text(data.total_games_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.game_name + ' ' + this.title_id + ' v' + this.title_version + '
' + '
' + this.player_count + '/' + this.max_player_count + ' Players
' + '
' + this.players.map(player => encode(player)).join(', ') + '
'); }); }); });