summaryrefslogtreecommitdiff
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
parent1938bceb0a478358897371c235860397ae2e3e5c (diff)
dirs
-rw-r--r--README.md3
-rw-r--r--public/css/drawdrawdraw.css1
-rw-r--r--public/index.html37
-rw-r--r--public/js/game.js26
-rw-r--r--server.js21
5 files changed, 44 insertions, 44 deletions
diff --git a/README.md b/README.md
index 42f4b01..8c059f7 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1 @@
-dumpphone-server
-================ \ No newline at end of file
+DRAW DRAW DRAW \ No newline at end of file
diff --git a/public/css/drawdrawdraw.css b/public/css/drawdrawdraw.css
new file mode 100644
index 0000000..20f548b
--- /dev/null
+++ b/public/css/drawdrawdraw.css
@@ -0,0 +1 @@
+html,body { padding: 0; margin: 0; width: 100%; height: 100%; }
diff --git a/public/index.html b/public/index.html
index 9fa2d48..2336d19 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1,46 +1,17 @@
<!doctype html>
<html>
<head>
-<title>dump2</title>
+<title>drawdrawdraw</title>
+<link rel="stylesheet" href="/css/drawdrawdraw.css" type="text/css">
<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>
+<script type="text/javascript" src="/js/game.js"></script>
+<script type="text/javascript" src="/js/draw.js"></script>
</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>
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--;
+ }
+}
+
diff --git a/server.js b/server.js
index 948bc9e..e8d0aec 100644
--- a/server.js
+++ b/server.js
@@ -20,6 +20,9 @@ app.configure(function(){
app.use(express.static(__dirname + '/public'));
});
+/******************************* ROUTES
+*/
+
app.get('/latest', function(req, res){
var data = { 'image_url': Images.latest() };
res.setHeader('Content-Type', 'application/json');
@@ -49,19 +52,14 @@ app.post('/upload', function(req, res) {
});
});
+/******************************* WEBSOCKETS
+*/
+
io.sockets.on( 'connection', function(socket){
socket.emit( 'join', Channel.join() );
function echo
});
-var port = process.env.PORT || 5000;
-server.listen(port);
-console.log('Listening on port ' + port);
-
-function timestamp() {
- return Math.round(new Date().getTime());
-}
-
var State = {
WAITING: 0,
DRAWING: 1,
@@ -77,7 +75,7 @@ function Channel() {
}
Channel.prototype.push = function(message){
if (this.messages.length > 20) this.messages.shift();
- var message = { id: ++this.message_id, content: message, user: username, faves: 0 };
+ var message = { id: ++this.message_id, content: message, user: username, faves: 0, time: Date.now() };
this.messages.push(message);
io.sockets.emit('message', JSON.stringify(message));
}
@@ -96,4 +94,9 @@ Channel.prototype.join = function(){
}
}
+/******************************* DONE
+*/
+var port = process.env.PORT || 5000;
+server.listen(port);
+console.log('Listening on port ' + port);