Add additional actions and a short timer
Modify to fit the needs of Openfest: - lecture time of 45 min - lightning talks time of 5 min - multiple halls - more control actions
This commit is contained in:
parent
dac0ea9241
commit
98c7db08b0
49
app.js
49
app.js
|
@ -35,10 +35,14 @@ io.configure(function () {
|
|||
|
||||
// Use the port that Heroku provides or default to 5000
|
||||
var port = process.env.PORT || 5000;
|
||||
app.listen(port, function() {
|
||||
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
|
||||
var host = process.env.HOST || '0.0.0.0';
|
||||
app.listen(port, host, function() {
|
||||
console.log("Express server listening on %j in %s mode", app.address(), app.settings.env);
|
||||
});
|
||||
|
||||
// configure title
|
||||
app.title = process.env.TITLE || 'Timer'
|
||||
|
||||
app.get('/', routes.index);
|
||||
|
||||
var stopwatch = new Stopwatch();
|
||||
|
@ -63,7 +67,46 @@ io.sockets.on('connection', function (socket) {
|
|||
stopwatch.stop();
|
||||
});
|
||||
|
||||
socket.on('click:zero', function () {
|
||||
stopwatch.zero();
|
||||
});
|
||||
|
||||
socket.on('click:reset', function () {
|
||||
stopwatch.reset();
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('click:resetShort', function () {
|
||||
stopwatch.resetShort();
|
||||
});
|
||||
});
|
||||
|
||||
app.post('/reset/', function (req, res) {
|
||||
stopwatch.reset();
|
||||
res.send("OK");
|
||||
});
|
||||
app.post('/reset-short/', function (req, res) {
|
||||
stopwatch.resetShort();
|
||||
res.send("OK");
|
||||
});
|
||||
app.post('/start-from-reset/', function (req, res) {
|
||||
stopwatch.reset();
|
||||
stopwatch.start();
|
||||
res.send("OK");
|
||||
});
|
||||
app.post('/start-from-reset-short/', function (req, res) {
|
||||
stopwatch.resetShort();
|
||||
stopwatch.start();
|
||||
res.send("OK");
|
||||
});
|
||||
app.post('/start/', function (req, res) {
|
||||
stopwatch.start();
|
||||
res.send("OK");
|
||||
});
|
||||
app.post('/stop/', function (req, res) {
|
||||
stopwatch.stop();
|
||||
res.send("OK");
|
||||
});
|
||||
app.post('/zero/', function (req, res) {
|
||||
stopwatch.zero();
|
||||
res.send("OK");
|
||||
});
|
||||
|
|
|
@ -2,6 +2,9 @@ var util = require('util'),
|
|||
events = require('events')
|
||||
_ = require('underscore');
|
||||
|
||||
var DEFAULT_TIME = 45* 60 * 1000;
|
||||
var DEFAULT_SHORT_TIME = 5 * 60 * 1000;
|
||||
|
||||
// ---------------------------------------------
|
||||
// Constructor
|
||||
// ---------------------------------------------
|
||||
|
@ -13,7 +16,9 @@ function Stopwatch() {
|
|||
this.hour = 3600000;
|
||||
this.minute = 60000;
|
||||
this.second = 1000;
|
||||
this.time = this.hour;
|
||||
this.defaultTime = DEFAULT_TIME;
|
||||
this.defaultShortTime = DEFAULT_SHORT_TIME;
|
||||
this.time = this.defaultTime;
|
||||
this.interval = undefined;
|
||||
|
||||
events.EventEmitter.call(this);
|
||||
|
@ -55,7 +60,19 @@ Stopwatch.prototype.stop = function() {
|
|||
|
||||
Stopwatch.prototype.reset = function() {
|
||||
console.log('Resetting Stopwatch!');
|
||||
this.time = this.hour;
|
||||
this.time = this.defaultTime;
|
||||
this.emit('reset:stopwatch', this.formatTime(this.time));
|
||||
};
|
||||
|
||||
Stopwatch.prototype.zero = function() {
|
||||
console.log('Zeroing Stopwatch!');
|
||||
this.time = 1000;
|
||||
this.emit('reset:stopwatch', this.formatTime(this.time));
|
||||
};
|
||||
|
||||
Stopwatch.prototype.resetShort = function() {
|
||||
console.log('Resetting Stopwatch to Short!');
|
||||
this.time = this.defaultShortTime;
|
||||
this.emit('reset:stopwatch', this.formatTime(this.time));
|
||||
};
|
||||
|
||||
|
@ -102,4 +119,4 @@ Stopwatch.prototype.getTime = function() {
|
|||
// ---------------------------------------------
|
||||
// Export
|
||||
// ---------------------------------------------
|
||||
module.exports = Stopwatch;
|
||||
module.exports = Stopwatch;
|
||||
|
|
|
@ -55,4 +55,4 @@ button.thoughtbot:active {
|
|||
-webkit-box-shadow: inset 0px 0px 0px 1px rgba(255, 115, 100, 0.4);
|
||||
-moz-box-shadow: inset 0px 0px 0px 1px rgba(255, 115, 100, 0.4);
|
||||
box-shadow: inset 0px 0px 0px 1px rgba(255, 115, 100, 0.4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,4 +14,8 @@ $('#stop').click(function() {
|
|||
|
||||
$('#reset').click(function() {
|
||||
socket.emit('click:reset');
|
||||
});
|
||||
});
|
||||
|
||||
$('#resetShort').click(function() {
|
||||
socket.emit('click:resetShort');
|
||||
});
|
||||
|
|
|
@ -5,5 +5,5 @@ var app = require('../app');
|
|||
*/
|
||||
|
||||
exports.index = function(req, res) {
|
||||
res.render('index')
|
||||
};
|
||||
res.render('index', {"title": app.title})
|
||||
};
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Usage:
|
||||
# HOST=127.0.0.1 PORT=5051 TITLE=HALL-B ./start.sh
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
NODE_ENV=production node app.js
|
|
@ -3,4 +3,7 @@
|
|||
<button id="start" class="thoughtbot">Start</button>
|
||||
<button id="stop" class="thoughtbot">Stop</button>
|
||||
<button id="reset" class="thoughtbot">Reset</button>
|
||||
</div>
|
||||
<button id="unused2" class="thoughtbot"> </button>
|
||||
<button id="zero" class="thoughtbot"> </button>
|
||||
<button id="resetShort" class="thoughtbot">Reset Short</button>
|
||||
</div>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>DEFCON</title>
|
||||
<title><%= title =></title>
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
|
@ -24,4 +24,4 @@
|
|||
<script src="/js/libs/jquery.js"></script>
|
||||
<script src="/js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue