summaryrefslogtreecommitdiff
path: root/public/js/game.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2013-02-22 11:50:49 -0800
committerJules Laplace <jules@okfoc.us>2013-02-22 11:50:49 -0800
commit6a8ae720310021b13f8aec447482f05641c8f908 (patch)
treeb03e301b1d58811967524938ca1cc7c49ca114b5 /public/js/game.js
parent1938bceb0a478358897371c235860397ae2e3e5c (diff)
dirs
Diffstat (limited to 'public/js/game.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--;
+ }
+}
+