first organize the code with comments
This commit is contained in:
parent
a0b947b19e
commit
08f86a0566
2 changed files with 51 additions and 53 deletions
|
@ -19,7 +19,7 @@
|
||||||
"sanitizer": "~0.1.1",
|
"sanitizer": "~0.1.1",
|
||||||
"socket.io": "0.8.x",
|
"socket.io": "0.8.x",
|
||||||
"simplesets": "~1.2.0",
|
"simplesets": "~1.2.0",
|
||||||
"express": "2.4.x",
|
"express": "4.x",
|
||||||
"jade": "~1.5.0"
|
"jade": "~1.5.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
74
server.js
74
server.js
|
@ -1,20 +1,29 @@
|
||||||
var http = require('http'),
|
/**************
|
||||||
express = require('express');
|
SYSTEM INCLUDES
|
||||||
|
**************/
|
||||||
|
var http = require('http');
|
||||||
var sys = require('sys');
|
var sys = require('sys');
|
||||||
|
|
||||||
var app = express.createServer();
|
|
||||||
|
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
|
var sanitizer = require('sanitizer');
|
||||||
|
var express = require('express');
|
||||||
|
|
||||||
|
/**************
|
||||||
|
LOCAL INCLUDES
|
||||||
|
**************/
|
||||||
var rooms = require('./lib/rooms.js');
|
var rooms = require('./lib/rooms.js');
|
||||||
var data = require('./lib/data.js').db;
|
var data = require('./lib/data.js').db;
|
||||||
|
|
||||||
var sanitizer = require('sanitizer');
|
/**************
|
||||||
|
GLOBALS
|
||||||
|
**************/
|
||||||
//Map of sids to user_names
|
//Map of sids to user_names
|
||||||
var sids_to_user_names = [];
|
var sids_to_user_names = [];
|
||||||
|
|
||||||
|
/**************
|
||||||
|
SETUP
|
||||||
|
**************/
|
||||||
|
var app = express();
|
||||||
|
|
||||||
app.configure( function(){
|
app.configure( function(){
|
||||||
app.use(express.static(__dirname + '/client'));
|
app.use(express.static(__dirname + '/client'));
|
||||||
app.use(express.bodyParser());
|
app.use(express.bodyParser());
|
||||||
|
@ -34,6 +43,12 @@ app.configure( function(){
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.listen(process.argv[2] || 8124);
|
||||||
|
|
||||||
|
|
||||||
|
/**************
|
||||||
|
ROUTES
|
||||||
|
**************/
|
||||||
app.get('/', function(req, res) {
|
app.get('/', function(req, res) {
|
||||||
//console.log(req.header('host'));
|
//console.log(req.header('host'));
|
||||||
url = req.header('host');
|
url = req.header('host');
|
||||||
|
@ -56,19 +71,10 @@ app.get('/:id', function(req, res){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//SETUP ROUTES
|
|
||||||
app.post('/edit-card/:id', function(req, res){
|
|
||||||
//do nothing
|
|
||||||
res.send(req.body.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.post('/edit-column', function(req, res) {
|
|
||||||
//do nothing
|
|
||||||
res.send(req.body.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.listen(process.argv[2] || 8124);
|
|
||||||
|
|
||||||
|
/**************
|
||||||
|
SOCKET.I0
|
||||||
|
**************/
|
||||||
//I limit the number of potential transports because xhr was causing trouble
|
//I limit the number of potential transports because xhr was causing trouble
|
||||||
//with frequent disconnects
|
//with frequent disconnects
|
||||||
var socketio_options = {
|
var socketio_options = {
|
||||||
|
@ -88,22 +94,8 @@ io.configure(function () {
|
||||||
io.set('log level', 1);
|
io.set('log level', 1);
|
||||||
});
|
});
|
||||||
io.sockets.on('connection', function (client) {
|
io.sockets.on('connection', function (client) {
|
||||||
// new client is here!
|
//santizes text
|
||||||
//console.dir(client.request.headers);
|
function scrub( text ) {
|
||||||
//
|
|
||||||
// var cookie_string = client.request.headers.cookie;
|
|
||||||
// var parsed_cookies = connect.utils.parseCookie(cookie_string);
|
|
||||||
// console.log('parsed:'); console.dir(parsed_cookies);
|
|
||||||
// var connect_sid = parsed_cookies['scrumscrum-sid'];
|
|
||||||
// if (connect_sid) {
|
|
||||||
// session_store.get(connect_sid, function (error, session) {
|
|
||||||
// console.log('cookie:');
|
|
||||||
// console.dir(session);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
//santizes text
|
|
||||||
function scrub( text ) {
|
|
||||||
if (typeof text != "undefined" && text !== null)
|
if (typeof text != "undefined" && text !== null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -119,7 +111,7 @@ function scrub( text ) {
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -336,7 +328,9 @@ function scrub( text ) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**************
|
||||||
|
FUNCTIONS
|
||||||
|
**************/
|
||||||
function initClient ( client )
|
function initClient ( client )
|
||||||
{
|
{
|
||||||
//console.log ('initClient Started');
|
//console.log ('initClient Started');
|
||||||
|
@ -505,6 +499,10 @@ function cleanAndInitializeDemoRoom()
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
|
/**************
|
||||||
|
SETUP DATABASE ON FIRST RUN
|
||||||
|
**************/
|
||||||
|
// (runs only once on startup)
|
||||||
var db = new data(function() {
|
var db = new data(function() {
|
||||||
cleanAndInitializeDemoRoom();
|
cleanAndInitializeDemoRoom();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue