This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
}).listen(3000, '127.0.0.1'); | |
console.log('Server running at http://127.0.0.1:3000/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "wine-cellar", | |
"description": "Wine Cellar Application", | |
"version": "0.0.1", | |
"private": true, | |
"dependencies": { | |
"express": "3.x" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'), | |
wines = require('./routes/wines'); | |
var app = express(); | |
app.get('/wines', wines.findAll); | |
app.get('/wines/:id', wines.findById); | |
app.listen(3000); | |
console.log('Listening on port 3000...'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'), | |
wine = require('./routes/wines'); | |
var app = express(); | |
app.configure(function () { | |
app.use(express.logger('dev')); /* 'default', 'short', 'tiny', 'dev' */ | |
app.use(express.bodyParser()); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h1>Real Time Page Views</h1> | |
<ul id="pageViews"></ul> | |
<script src="socket.io.min.js"></script> | |
<script src="jquery-1.8.2.min.js"></script> | |
<script> | |
var socket = io.connect('http://localhost:3000'); | |
socket.on('connect', function () { | |
socket.on('pageview', function (msg) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script> | |
var socket = io.connect(); | |
socket.on('connect', function () { | |
socket.send(window.location.href); | |
}); | |
window.onhashchange = function () { | |
socket.send(window.location.href); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script id="home-tpl" type="text/x-handlebars-template"> | |
<div class='header'> | |
<h1>Home</h1> | |
</div> | |
<div class='search-view'> | |
<input class='search-key'/> | |
<ul class='employee-list'></ul> | |
</div> | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<script src="lib/jquery-1.9.1.min.js"></script> | |
<script src="lib/underscore-min.js"></script> | |
<script src="lib/parse-1.2.2.min.js"></script> | |
<script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = { | |
findByName: function() { | |
this.store.findByName($('.search-key').val()).done(function(employees) { | |
var l = employees.length; | |
var e; | |
$('.employee-list').empty(); | |
for (var i=0; i<l; i++) { | |
e = employees[i]; | |
$('.employee-list').append('<li><a href="#employees/' + e.id + '">' + e.firstName + ' ' + e.lastName + '</a></li>'); |
OlderNewer