From 66ae4deb2a45a2049134ec0513d74ae97e6bc8c2 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Tue, 27 Dec 2011 16:59:24 +0100 Subject: [PATCH] fix json parsing. Also: global variables solve problems :-) --- tools/game/bong/bong.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/game/bong/bong.js b/tools/game/bong/bong.js index bfe79ea..4d58046 100644 --- a/tools/game/bong/bong.js +++ b/tools/game/bong/bong.js @@ -216,17 +216,17 @@ pong.prototype.socketstart = function(uri){ $('#socket').html(data); if(data.slice(0,1)=="{"){ var result=JSON.parse(data); - if (result.right){ - this.setright(result.right); + if ("right" in result){ + game.setright(result.right); } ; - if (result.left){ - this.setleft(result.left); + if ("left" in result){ + game.setleft(result.left); }; - if (result.cntl){ - this.cnt.left.avatar.html(result.cntl); + if ("cntl" in result){ + game.cnt.left.avatar.html(result.cntl); }; - if (result.cntr){ - this.cnt.right.avatar.html(result.cntr); + if ("cntr" in result){ + game.cnt.right.avatar.html(result.cntr); }; }else{ // unknown non-json input