Permalink
Browse files

Backend-wise, it already kinda works -- moving on to visualization now

  • Loading branch information...
1 parent 678b0ae commit 93165a731bcc43ee235fc9ea31a5af88c11fd322 Jonas Galvez committed Aug 29, 2010
Showing with 58 additions and 46 deletions.
  1. +28 −27 client/index.html
  2. +2 −1 client/voting-room.html
  3. +9 −7 pagetalk.js
  4. +11 −7 static/css/index.css
  5. +1 −0 static/js/index.js
  6. +7 −4 static/js/voting-room.js
View
@@ -1,30 +1,31 @@
<!doctype html>
<html>
-<head>
-<link type="text/css" href="/css/smoothness/jquery-ui-1.8.custom.css" rel="stylesheet" />
-<link type="text/css" href="/css/index.css" rel="stylesheet" />
-<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/index.js"></script>
-</head>
-<body>
-<form id="voting-room-form" style="display: none;" action="/voting-room" method="post">
-</form>
-<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">
-<div id="logo-box" class="">no•de•vote</div>
-<div class="info-box" style="margin-top: 30px;">
- <p>lets you capture an anonymous "show of hands" during a presentation.</p>
- <p style="margin-top: 25px;">create as many voting<br>options as you want, <br>hit 'create' and<br> that's it.</p>
-</div>
-<div id="create" class="side-button" style="margin-top: 25px;">create<div>
-</div>
-</div>
-</body>
+ <head>
+ <link type="text/css" href="/css/smoothness/jquery-ui-1.8.custom.css" rel="stylesheet" />
+ <link type="text/css" href="/css/index.css" rel="stylesheet" />
+ <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/index.js"></script>
+ </head>
+ <body>
+ <form id="voting-room-form" style="display: none;" action="/voting-room" method="post">
+ </form>
+ <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">
+ <div id="logo-box" class="">no•de•vote</div>
+ <div class="info-box" style="margin-top: 30px;">
+ <p>lets you capture an anonymous "show of hands" during a presentation.</p>
+ <p style="margin-top: 25px;">create as many voting<br>options as you want, <br>hit 'create' and<br> that's it.</p>
+ </div>
+ <div id="create" class="side-button" style="margin-top: 25px;">create<div>
+ </div>
+ </div>
+ </div>
+ </body>
</html>
View
@@ -5,8 +5,9 @@
<link type="text/css" href="/css/index.css" rel="stylesheet" />
<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" src="/js/voting-room.js"></script>
-<script type="text/javascript">nodevote.voting_room_id = <%= voting_room_id %>;</script>
+<script type="text/javascript">nodevote.voting_room_id = '<%= voting_room_id %>';</script>
</head>
<body>
<div id="column-b">
View
@@ -41,12 +41,8 @@ http_server.get('/voting-room/:id', function(req, res) {
});
http_server.post('/voting-room', function(req, res) {
- var options = JSON.parse(req.body);
var voting_room_id = create_random_id(10);
var vr = poorsman_mongodb.voting_rooms[voting_room_id] = {};
- for(var i = 0, len = options.length; i < len; i++) {
- vr[options[i]] = options[i];
- }
res.redirect('/voting-room/' + voting_room_id);
});
@@ -55,19 +51,25 @@ http_server.listen(80);
socket_server = SocketIO.listen(http_server);
socket_server.on('connection', function(client) {
+ poorsman_mongodb.connected_clients[client.sessionId] = {};
client.on('message', function(message) {
- var message = JSON.parse(message);
+ var message = JSON.parse(message) || {};
var voting_room_id = message.voting_room_id;
+ poorsman_mongodb.connected_clients[client.sessionId] = message;
if(message.pick) {
- poorsman_mongodb.connected_clients[client.sessionId] = message;
+ if(poorsman_mongodb.voting_rooms[voting_room_id][message.pick] == undefined) {
+ poorsman_mongodb.voting_rooms[voting_room_id][message.pick] = 0;
+ }
poorsman_mongodb.voting_rooms[voting_room_id][message.pick]++;
client.broadcast(poorsman_mongodb.voting_rooms[voting_room_id]);
}
});
client.on('disconnect', function() {
var message = poorsman_mongodb.connected_clients[client.sessionId];
var voting_room_id = message.voting_room_id;
- poorsman_mongodb.voting_rooms[voting_room_id][message.pick]--;
+ if(message.pick) {
+ poorsman_mongodb.voting_rooms[voting_room_id][message.pick]--;
+ }
client.broadcast(poorsman_mongodb.voting_rooms[voting_room_id]);
});
});
View
@@ -35,7 +35,6 @@ body:after {
}
#column-a {
- position: relative;
padding-top: 40px;
float: right;
z-index: -1;
@@ -47,8 +46,6 @@ body:after {
}
#logo-box {
- -webkit-user-select: none;
- -moz-user-select: none;
float: right;
background-color: #fc781a;
color: #5a2601;
@@ -65,12 +62,12 @@ body:after {
}
.side-button {
- -webkit-user-select: none;
+/* -webkit-user-select: none;
-moz-user-select: none;
- float: right;
+*/ float: right;
text-align: right;
- color: #5a2601;
font-family: 'Lobster', sans-serif;
+ color: #8c3b02;
font-size: 30px;
font-style: normal;
font-weight: 400;
@@ -79,8 +76,15 @@ body:after {
padding: 10px;
padding-top: 0px;
padding-bottom: 0px;
- height: 90px;
width: 230px;
+ color: #8c3b02;
+ cursor: pointer;
+}
+.side-button:hover {
+ color: #5a2601;
+}
+.side-button:active {
+ color: #5a2601;
}
.info-box {
View
@@ -1,6 +1,7 @@
nodevote = {'ui': {'handlers': {}}};
nodevote.ui.handlers['create'] = {
'click': function() {
+ console.log('foo');
$('#voting-room-form').submit();
}
}
View
@@ -1,12 +1,15 @@
+nodevote = {};
+nodevote.ui = {};
+nodevote.ui.handlers = {};
+
$(document).ready(function() {
io.setPath('/voting-room/' + nodevote.voting_room_id);
var socket_client = new io.Socket(null, {port: 80});
socket_client.connect();
- socket.on('message', function(options) {
+ socket_client.on('message', function(options) {
+ console.log(message);
options = JSON.parse(options);
- }});
- nodevote.ui = {};
- nodevote.ui.handlers = {};
+ });
nodevote.ui.handlers['freeze'] = {
'click': function() {
}

0 comments on commit 93165a7

Please sign in to comment.