From 6a8ae720310021b13f8aec447482f05641c8f908 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 22 Feb 2013 11:50:49 -0800 Subject: dirs --- public/js/game.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 public/js/game.js (limited to 'public/js') diff --git a/public/js/game.js b/public/js/game.js new file mode 100644 index 0000000..d7c96dc --- /dev/null +++ b/public/js/game.js @@ -0,0 +1,26 @@ +var socket = io.connect(window.location.hostname); + + + +var imageCount = 0; +socket.on('join', function(json) { + var data = JSON.parse(json); + for (var i in data) { + appendImage(data[i]); + } +}); +socket.on('url', function(json) { + var data = JSON.parse(json); + appendImage(data); +}); +function appendImage(img) { + var image = new Image(); + image.src = img.url; + $("#images").prepend(image); + imageCount++; + while (imageCount > 20) { + $("#images").children().last().remove(); + imageCount--; + } +} + -- cgit v1.2.3-70-g09d2