summaryrefslogtreecommitdiff
path: root/public/index.html
blob: 9fa2d486c0464d5c196f265336d3fe6d114bf8eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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>