initial commit
This commit is contained in:
commit
b3035dba55
|
@ -0,0 +1 @@
|
|||
node_modules
|
|
@ -0,0 +1,41 @@
|
|||
var express = require('express'),
|
||||
app = express.createServer(),
|
||||
io = require('socket.io').listen(app),
|
||||
routes = require('./routes');
|
||||
|
||||
// Configuration
|
||||
|
||||
app.configure(function() {
|
||||
app.set('views', __dirname + '/views');
|
||||
app.set('view engine', 'ejs');
|
||||
app.use(express.bodyParser());
|
||||
app.use(express.methodOverride());
|
||||
app.use(app.router);
|
||||
app.use(express.static(__dirname + '/public'));
|
||||
});
|
||||
|
||||
app.configure('development', function() {
|
||||
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
|
||||
});
|
||||
|
||||
app.configure('production', function() {
|
||||
app.use(express.errorHandler());
|
||||
});
|
||||
|
||||
// Routes
|
||||
|
||||
app.listen(3000, function() {
|
||||
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
|
||||
});
|
||||
|
||||
app.get('/', routes.index);
|
||||
|
||||
var status = "All is well.";
|
||||
|
||||
io.sockets.on('connection', function (socket) {
|
||||
socket.emit('status', { status: status });
|
||||
socket.on('reset', function (data) {
|
||||
status = "War is imminent!";
|
||||
socket.emit('status', { status: status });
|
||||
});
|
||||
});
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "application-name",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"express": "~2.5.8",
|
||||
"ejs": "~0.7.1",
|
||||
"socket.io": "~0.9.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": "0.6.x"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
body {
|
||||
padding: 50px;
|
||||
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #00B7FF;
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,9 @@
|
|||
var socket = io.connect('http://localhost');
|
||||
|
||||
socket.on('status', function (data) {
|
||||
$('#status').html(data.status);
|
||||
});
|
||||
|
||||
$('#reset').click(function() {
|
||||
socket.emit('reset');
|
||||
});
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* GET home page.
|
||||
*/
|
||||
|
||||
exports.index = function(req, res) {
|
||||
res.render('index')
|
||||
};
|
|
@ -0,0 +1,2 @@
|
|||
<div id="status"></div>
|
||||
<button id="reset">Reset!</button>
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Title</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<!-- HTML5 shim, for IE6-8 support of HTML elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<!-- styles -->
|
||||
<link href="/css/main.css" rel="stylesheet">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<%- body %>
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script src="/js/libs/jquery.js"></script>
|
||||
<script src="/js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue