summaryrefslogtreecommitdiff
path: root/public/index.html
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2013-02-22 09:59:20 -0800
committerJules Laplace <jules@okfoc.us>2013-02-22 09:59:20 -0800
commit1938bceb0a478358897371c235860397ae2e3e5c (patch)
treeead382ee9c38443c819bbdcb926ff35fb8255342 /public/index.html
basic chat app
Diffstat (limited to 'public/index.html')
-rw-r--r--public/index.html46
1 files changed, 46 insertions, 0 deletions
diff --git a/public/index.html b/public/index.html
new file mode 100644
index 0000000..9fa2d48
--- /dev/null
+++ b/public/index.html
@@ -0,0 +1,46 @@
+<!doctype html>
+<html>
+<head>
+<title>dump2</title>
+<script type="text/javascript" src="/js/zepto.js"></script>
+<script type="text/javascript" src="/socket.io/socket.io.js"></script>
+<style type="text/css">
+#images img { display: block; }
+</style>
+</head>
+<body>
+
+<form method="post" action="/upload" enctype="multipart/form-data">
+<input type="file" name="image">
+<input type="submit">
+</form>
+
+<div id="images"></div>
+
+</body>
+<script type="text/javascript">
+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--;
+ }
+}
+</script>
+</html>
+