summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js')
-rw-r--r--public/js/game.js26
1 files changed, 26 insertions, 0 deletions
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--;
+ }
+}
+