2021-01-02 11:21:53 +00:00
|
|
|
$(document).ready(function (){
|
|
|
|
var socket = io.connect();
|
|
|
|
|
|
|
|
socket.on('connect', function () {
|
|
|
|
console.log("connected")
|
|
|
|
socket.emit('recieved', {});
|
|
|
|
});
|
|
|
|
|
|
|
|
socket.on("states_update", function (json) { //json is an object containing all game updates
|
|
|
|
var searchparams = new URLSearchParams(window.location.search);
|
|
|
|
var exists = false;
|
|
|
|
for (game of json) {
|
|
|
|
if (searchparams.get('timestamp') == game.timestamp) {
|
|
|
|
$('.game').html(game.html);
|
|
|
|
exists = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!exists) {
|
2021-01-02 22:36:19 +00:00
|
|
|
$('game').remove()
|
|
|
|
$('#game_container').text("The game you're looking for either doesn't exist or has already ended.")
|
2021-01-02 11:21:53 +00:00
|
|
|
}
|
2021-01-02 22:36:19 +00:00
|
|
|
|
|
|
|
twemoji.parse(document.body);
|
2021-01-02 11:21:53 +00:00
|
|
|
});
|
|
|
|
});
|