fix json parsing. Also: global variables solve problems :-)
This commit is contained in:
parent
3d9da1ec9e
commit
66ae4deb2a
|
@ -216,17 +216,17 @@ pong.prototype.socketstart = function(uri){
|
||||||
$('#socket').html(data);
|
$('#socket').html(data);
|
||||||
if(data.slice(0,1)=="{"){
|
if(data.slice(0,1)=="{"){
|
||||||
var result=JSON.parse(data);
|
var result=JSON.parse(data);
|
||||||
if (result.right){
|
if ("right" in result){
|
||||||
this.setright(result.right);
|
game.setright(result.right);
|
||||||
} ;
|
} ;
|
||||||
if (result.left){
|
if ("left" in result){
|
||||||
this.setleft(result.left);
|
game.setleft(result.left);
|
||||||
};
|
};
|
||||||
if (result.cntl){
|
if ("cntl" in result){
|
||||||
this.cnt.left.avatar.html(result.cntl);
|
game.cnt.left.avatar.html(result.cntl);
|
||||||
};
|
};
|
||||||
if (result.cntr){
|
if ("cntr" in result){
|
||||||
this.cnt.right.avatar.html(result.cntr);
|
game.cnt.right.avatar.html(result.cntr);
|
||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
// unknown non-json input
|
// unknown non-json input
|
||||||
|
|
Loading…
Reference in New Issue