Skip to content
Browse files

WE LOST, first commit after the deadline :( -- We'll get it done anyway.

  • Loading branch information...
1 parent 1be0734 commit b9f53d8bc73304c091ff58ab626e40a01537566e Jonas Galvez committed Aug 29, 2010
Showing with 25 additions and 14 deletions.
  1. +1 −4 client/voting-room.html
  2. +12 −4 pagetalk.js
  3. +12 −6 static/js/voting-room.js
View
5 client/voting-room.html
@@ -6,15 +6,12 @@
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.custom.min.js"></script>
<script type="text/javascript" src="/js/socket.io.js"></script>
+<script type="text/javascript">io.setPath('/js/');</script>
<script type="text/javascript" src="/js/voting-room.js"></script>
<script type="text/javascript">nodevote.voting_room_id = '<%= voting_room_id %>';</script>
</head>
<body>
<div id="column-b">
- <div class="bar" style="height: 50px; background-color: #545454;"></div>
- <div class="bar" style="height: 30px; background-color: #c2c2c2;"></div>
- <div class="bar" style="height: 80px; background-color: #545454;"></div>
- <div class="bar" style="height: 120px; background-color: #c2c2c2;"></div>
</div>
<div id="column-a">
<div id="column-a-container">
View
16 pagetalk.js
@@ -54,8 +54,6 @@ http_server.post('/voting-room', function(req, res) {
res.redirect('/voting-room/' + voting_room_id);
});
-http_server.listen(80);
-
socket_server = io.listen(http_server);
socket_server.on('connection', function(client) {
@@ -69,8 +67,7 @@ socket_server.on('connection', function(client) {
}
poorsman_mongodb.voting_rooms[voting_room_id][message.pick]++;
}
- console.log('poorsman_mongodb.voting_rooms[voting_room_id]: ' + poorsman_mongodb.voting_rooms[voting_room_id]);
- client.broadcast({'omg': 1});
+ client.broadcast({'options': poorsman_mongodb.voting_rooms[voting_room_id]});
});
client.on('disconnect', function() {
var message = poorsman_mongodb.connected_clients[client.sessionId];
@@ -80,4 +77,15 @@ socket_server.on('connection', function(client) {
}
client.broadcast(poorsman_mongodb.voting_rooms[voting_room_id]);
});
+ for(var voting_room_id in poorsman_mongodb.voting_rooms) {
+ socket_server.broadcast({'options': poorsman_mongodb.voting_rooms[voting_room_id]});
+ }
});
+
+setInterval(function() {
+ for(var voting_room_id in poorsman_mongodb.voting_rooms) {
+ socket_server.broadcast({'options': poorsman_mongodb.voting_rooms[voting_room_id]});
+ }
+}, 10000)
+
+http_server.listen(80);
View
18 static/js/voting-room.js
@@ -2,18 +2,24 @@ nodevote = {};
nodevote.ui = {};
nodevote.ui.handlers = {};
+nodevote.ui.create_bar = function(height, color) {
+ return $(
+ '<div class="bar" style="height: ' + height + 'px; background-color: #' + color + ';">' +
+ '</div>'
+ );
+}
+
$(document).ready(function() {
- io.setPath('/voting-room/' + nodevote.voting_room_id);
socket_client = new io.Socket(null, {port: 80});
- socket_client.on('message', function(options) {
- console.log(options);
- options = JSON.parse(options);
- });
+ socket_client.connect();
+ on_message = function(options) {
+
+ }
+ socket_client.on('message', on_message);
nodevote.ui.handlers['freeze'] = {
'click': function() {
}
}
- socket_client.connect();
socket_client.send({'voting_room_id': nodevote.voting_room_id});
$('#freeze').click(nodevote.ui.handlers['freeze'].click);
});

0 comments on commit b9f53d8

Please sign in to comment.
Something went wrong with that request. Please try again.