commit
30e438aa32
13 changed files with 898 additions and 0 deletions
Split View
Diff Options
-
30.gitignore
-
116app.js
-
93bin/www
-
23package.json
-
77routes/index.js
-
9routes/users.js
-
63tools/tools-gphoto2.js
-
153tools/tools-photobooth.js
-
5tools/tools-test.js
-
3views/error.ejs
-
161views/index.ejs
-
72views/index_back.ejs
-
93views/view.ejs
@ -0,0 +1,30 @@ |
|||
# Logs |
|||
logs |
|||
*.log |
|||
|
|||
# Runtime data |
|||
pids |
|||
*.pid |
|||
*.seed |
|||
|
|||
# Directory for instrumented libs generated by jscoverage/JSCover |
|||
lib-cov |
|||
|
|||
# Coverage directory used by tools like istanbul |
|||
coverage |
|||
|
|||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) |
|||
.grunt |
|||
|
|||
# node-waf configuration |
|||
.lock-wscript |
|||
|
|||
# Compiled binary addons (http://nodejs.org/api/addons.html) |
|||
build/Release |
|||
|
|||
# Dependency directory |
|||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- |
|||
node_modules |
|||
|
|||
# Debug log from npm |
|||
npm-debug.log |
|||
@ -0,0 +1,116 @@ |
|||
var BOB_mod_path = require('path'); |
|||
var express = require('express'); |
|||
var path = require('path'); |
|||
var favicon = require('serve-favicon'); |
|||
var logger = require('morgan'); |
|||
var cookieParser = require('cookie-parser'); |
|||
var bodyParser = require('body-parser'); |
|||
|
|||
var BOB_cfg_config = BOB_initConfig(); |
|||
|
|||
var routes = require('./routes/index')(BOB_cfg_config); |
|||
var users = require('./routes/users'); |
|||
|
|||
var app = express(); |
|||
|
|||
// view engine setup
|
|||
app.set('views', path.join(__dirname, 'views')); |
|||
app.set('view engine', 'ejs'); |
|||
|
|||
// uncomment after placing your favicon in /public
|
|||
//app.use(favicon(__dirname + '/public/favicon.ico'));
|
|||
app.use(logger('dev')); |
|||
app.use(bodyParser.json()); |
|||
app.use(bodyParser.urlencoded({ extended: false })); |
|||
app.use(cookieParser()); |
|||
app.use(express.static(path.join(__dirname, 'public'))); |
|||
|
|||
app.use('/', routes); |
|||
app.use('/users', users); |
|||
|
|||
// catch 404 and forward to error handler
|
|||
app.use(function(req, res, next) { |
|||
var err = new Error('Not Found'); |
|||
err.status = 404; |
|||
next(err); |
|||
}); |
|||
|
|||
// error handlers
|
|||
|
|||
// development error handler
|
|||
// will print stacktrace
|
|||
if (app.get('env') === 'development') { |
|||
app.use(function(err, req, res, next) { |
|||
res.status(err.status || 500); |
|||
res.render('error', { |
|||
message: err.message, |
|||
error: err |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
// production error handler
|
|||
// no stacktraces leaked to user
|
|||
app.use(function(err, req, res, next) { |
|||
res.status(err.status || 500); |
|||
res.render('error', { |
|||
message: err.message, |
|||
error: {} |
|||
}); |
|||
}); |
|||
|
|||
app.setSocketIo = function(pSocketIo) { |
|||
BOB_cfg_config.io = pSocketIo; |
|||
|
|||
pSocketIo.on('connection', function(socket){ |
|||
console.log('New client connected', socket.id); |
|||
|
|||
socket.on('event', function(data){ |
|||
console.log("event"); |
|||
}); |
|||
socket.on('disconnect', function(){ |
|||
console.log("disconnect"); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
module.exports = app; |
|||
|
|||
|
|||
|
|||
function BOB_initConfig() { |
|||
// Config
|
|||
var cfgConfig = { |
|||
background : '#ffffff', |
|||
margins : 0.01, |
|||
style : 'default', |
|||
nbPicture : 4, |
|||
cropSize : { |
|||
width : 2000, |
|||
height : 2500 |
|||
}, |
|||
pictNames : [], |
|||
layout : [], |
|||
booths : {}, |
|||
paths : { |
|||
final : "", |
|||
template : "", |
|||
prebuilt : "", |
|||
original : "" |
|||
} |
|||
}; |
|||
// Init PATH
|
|||
cfgConfig.paths.final = BOB_mod_path.resolve(__dirname, './public/img/final'); |
|||
cfgConfig.paths.final_ld = BOB_mod_path.resolve(__dirname, './public/img/final_ld'); |
|||
cfgConfig.paths.prebuilt = BOB_mod_path.resolve(__dirname, './public/img/prebuilt'); |
|||
cfgConfig.paths.template = BOB_mod_path.resolve(__dirname, './public/img/template'); |
|||
cfgConfig.paths.original = BOB_mod_path.resolve(__dirname, './public/img/original'); |
|||
// Init pinctures names
|
|||
for( var index = 0; index < cfgConfig.nbPicture; index ++ ) { |
|||
(function(pId) { |
|||
cfgConfig.pictNames.push('pict_'+pId+'.jpg'); |
|||
})(index); |
|||
} |
|||
|
|||
return cfgConfig; |
|||
} |
|||
@ -0,0 +1,93 @@ |
|||
#!/usr/bin/env node |
|||
|
|||
/** |
|||
* Module dependencies. |
|||
*/ |
|||
|
|||
var app = require('../app'); |
|||
var debug = require('debug')('bobinoscope:server'); |
|||
var http = require('http'); |
|||
|
|||
/** |
|||
* Get port from environment and store in Express. |
|||
*/ |
|||
|
|||
var port = normalizePort(process.env.PORT || '3000'); |
|||
app.set('port', port); |
|||
|
|||
/** |
|||
* Create HTTP server. |
|||
*/ |
|||
|
|||
var server = http.createServer(app); |
|||
var io = require('socket.io')(server); |
|||
|
|||
app.setSocketIo(io); |
|||
|
|||
/** |
|||
* Listen on provided port, on all network interfaces. |
|||
*/ |
|||
|
|||
server.listen(port); |
|||
server.on('error', onError); |
|||
server.on('listening', onListening); |
|||
|
|||
/** |
|||
* Normalize a port into a number, string, or false. |
|||
*/ |
|||
|
|||
function normalizePort(val) { |
|||
var port = parseInt(val, 10); |
|||
|
|||
if (isNaN(port)) { |
|||
// named pipe |
|||
return val; |
|||
} |
|||
|
|||
if (port >= 0) { |
|||
// port number |
|||
return port; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
/** |
|||
* Event listener for HTTP server "error" event. |
|||
*/ |
|||
|
|||
function onError(error) { |
|||
if (error.syscall !== 'listen') { |
|||
throw error; |
|||
} |
|||
|
|||
var bind = typeof port === 'string' |
|||
? 'Pipe ' + port |
|||
: 'Port ' + port; |
|||
|
|||
// handle specific listen errors with friendly messages |
|||
switch (error.code) { |
|||
case 'EACCES': |
|||
console.error(bind + ' requires elevated privileges'); |
|||
process.exit(1); |
|||
break; |
|||
case 'EADDRINUSE': |
|||
console.error(bind + ' is already in use'); |
|||
process.exit(1); |
|||
break; |
|||
default: |
|||
throw error; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Event listener for HTTP server "listening" event. |
|||
*/ |
|||
|
|||
function onListening() { |
|||
var addr = server.address(); |
|||
var bind = typeof addr === 'string' |
|||
? 'pipe ' + addr |
|||
: 'port ' + addr.port; |
|||
debug('Listening on ' + bind); |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
{ |
|||
"name": "bobinoscope", |
|||
"version": "0.0.0", |
|||
"private": true, |
|||
"scripts": { |
|||
"start": "node ./bin/www" |
|||
}, |
|||
"dependencies": { |
|||
"async": "~0.9.0", |
|||
"body-parser": "~1.12.0", |
|||
"cookie-parser": "~1.3.4", |
|||
"debug": "~2.1.1", |
|||
"ejs": "~2.3.1", |
|||
"express": "~4.12.2", |
|||
"gamepad": "^1.0.2", |
|||
"gm": "~1.17.0", |
|||
"gphoto2": "~0.1.7", |
|||
"mkdirp": "~0.5.0", |
|||
"morgan": "~1.5.1", |
|||
"serve-favicon": "~2.2.0", |
|||
"socket.io": "~1.3.5" |
|||
} |
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
var BOB_mod_express = require('express'); |
|||
var BOB_mod_router = BOB_mod_express.Router(); |
|||
var BOB_mod_path = require('path'); |
|||
var BOB_mod_mkdirp = require('mkdirp'); |
|||
|
|||
var BOB_tol_gphotos = null; |
|||
var BOB_tol_booth = null; |
|||
var BOB_cfg_config = null; |
|||
|
|||
var BOB_var_boothInProgress = 0; |
|||
|
|||
var BOB_var_gamepad = require("gamepad"); |
|||
|
|||
/* GET home page. */ |
|||
BOB_mod_router.get('/bobinoscope', function(req, res, next) { |
|||
res.render('index', { title: 'Express' }); |
|||
}); |
|||
/* GET view page. */ |
|||
BOB_mod_router.get('/', function(req, res, next) { |
|||
res.render('view', {}); |
|||
}); |
|||
|
|||
BOB_mod_router.get('/booth/build/:boothId', function(req, res, next) { |
|||
BOB_var_boothInProgress += 1; |
|||
BOB_cfg_config.io.emit('boothState'); |
|||
BOB_tol_booth.buildBooth(req.params.boothId, function(pErr) { |
|||
BOB_cfg_config.io.emit('boothState'); |
|||
BOB_var_boothInProgress -= 1; |
|||
res.send(pErr); |
|||
}); |
|||
}) |
|||
|
|||
BOB_mod_router.get('/booth/list/:from', function(req, res, next) { |
|||
BOB_tol_booth.getBoothList(req.params.from, function(pErr, pList) { |
|||
res.json({error: pErr, booths: pList, inProgress : BOB_var_boothInProgress}); |
|||
}) |
|||
}) |
|||
|
|||
/* GET home page. */ |
|||
BOB_mod_router.get('/dslr/takepicture/:boothId/:pictId', function(req, res, next) { |
|||
// BOB_cfg_config.io.emit('boothState');
|
|||
BOB_tol_gphotos.takePicture(req.params.boothId, req.params.pictId, function(pErr) { |
|||
res.json({ error: pErr, data : null}); |
|||
}) |
|||
}); |
|||
|
|||
/* GET view page. */ |
|||
BOB_mod_router.get('/download/final/hd/:pictId', function(req, res, next) { |
|||
res.download('public/img/final/'+req.params.pictId); |
|||
}); |
|||
|
|||
|
|||
// Initialize the library
|
|||
BOB_var_gamepad.init() |
|||
// List the state of all currently attached devices
|
|||
for (var i = 0, l = BOB_var_gamepad.numDevices(); i < l; i++) { |
|||
console.log(i, BOB_var_gamepad.deviceAtIndex()); |
|||
} |
|||
// Create a game loop and poll for events
|
|||
setInterval(BOB_var_gamepad.processEvents, 16); |
|||
// Scan for new gamepads as a slower rate
|
|||
setInterval(BOB_var_gamepad.detectDevices, 500); |
|||
// Listen for button down events on all gamepads
|
|||
BOB_var_gamepad.on("down", function (pId, pNum) { |
|||
BOB_cfg_config.io.emit('boothClick', { |
|||
id : pId, |
|||
num : pNum |
|||
}); |
|||
}) |
|||
|
|||
|
|||
module.exports = function(pConfig) { |
|||
BOB_cfg_config = pConfig; |
|||
BOB_tol_gphotos = require('../tools/tools-gphoto2')(pConfig); |
|||
BOB_tol_booth = require('../tools/tools-photobooth')(pConfig); |
|||
return BOB_mod_router; |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
var express = require('express'); |
|||
var router = express.Router(); |
|||
|
|||
/* GET users listing. */ |
|||
router.get('/', function(req, res, next) { |
|||
res.send('respond with a resource'); |
|||
}); |
|||
|
|||
module.exports = router; |
|||
@ -0,0 +1,63 @@ |
|||
var BOB_mod_gphoto2 = require('gphoto2'); |
|||
var BOB_var_gphoto = new BOB_mod_gphoto2.GPhoto2(); |
|||
var BOB_mod_fs = require('fs'); |
|||
var BOB_mod_path = require('path'); |
|||
var BOB_mod_mkdirp = require('mkdirp'); |
|||
|
|||
var BOB_cfg_config = null; |
|||
|
|||
var BOB_var_camera = null; |
|||
|
|||
var BOB_module = {}; |
|||
|
|||
|
|||
function BOB_upCameraReference(pCallback) { |
|||
// List cameras / assign list item to variable to use below options
|
|||
if( BOB_var_camera === null ) { |
|||
BOB_var_gphoto.list(function (list) { |
|||
if (list.length === 0) { |
|||
return pCallback(); |
|||
} else { |
|||
BOB_var_camera = list[0]; |
|||
console.log(BOB_var_camera.model); |
|||
return pCallback(); |
|||
} |
|||
}) |
|||
} else { |
|||
return pCallback(); |
|||
} |
|||
} |
|||
|
|||
BOB_module.getConfig = function(pCallback) { |
|||
BOB_var_camera.getConfig(pCallback); |
|||
} |
|||
|
|||
BOB_module.takePicture = function(pBoothId, pPictId, pCallback) { |
|||
var destPath = BOB_mod_path.join(BOB_cfg_config.paths.original, pBoothId); |
|||
var pictPath = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]); |
|||
|
|||
BOB_upCameraReference(function() { |
|||
if( BOB_var_camera === null ) { |
|||
return pCallback("No camera found"); |
|||
} else { |
|||
BOB_var_camera.takePicture({download: true}, function (pErr, pData) { |
|||
// If error occurs
|
|||
if( pErr ) { |
|||
return pCallback(pErr) |
|||
// Else write file on ddisk
|
|||
} else { |
|||
BOB_mod_mkdirp(destPath, function() { |
|||
BOB_mod_fs.writeFile(pictPath, pData, function(pErr) { |
|||
return pCallback(pErr, pictPath) |
|||
}); |
|||
}) |
|||
} |
|||
}); |
|||
} |
|||
}) |
|||
} |
|||
|
|||
module.exports = function(pConfig) { |
|||
BOB_cfg_config = pConfig; |
|||
return BOB_module; |
|||
} |
|||
@ -0,0 +1,153 @@ |
|||
var BOB_mod_gm = require('gm').subClass({ imageMagick: true }); |
|||
var BOB_mod_async = require('async'); |
|||
var BOB_mod_path = require('path'); |
|||
var BOB_mod_fs = require('fs'); |
|||
var BOB_mod_mkdirp = require('mkdirp'); |
|||
|
|||
var BOB_cfg_config = null; |
|||
|
|||
var BOB_module = {}; |
|||
|
|||
BOB_module.getBoothList = function(pFrom, pCallback) { |
|||
BOB_mod_fs.readdir(BOB_cfg_config.paths.final, function(pErr, pBoothList) { |
|||
var boothList = pBoothList.sort(); |
|||
|
|||
boothList = boothList.splice(boothList.indexOf(pFrom) + 1); |
|||
|
|||
pCallback(pErr, boothList); |
|||
}) |
|||
} |
|||
|
|||
BOB_module.buildBooth = function(pBoothId, pCallback) { |
|||
var index = 0; |
|||
var funcResizeArray = []; |
|||
|
|||
BOB_mod_mkdirp.sync(BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId)); |
|||
|
|||
BOB_cfg_config.pictNames.forEach(function(pPictName) { |
|||
funcResizeArray.push(function(pCb) { |
|||
var srcPict = BOB_mod_path.join(BOB_cfg_config.paths.original, pBoothId, pPictName); |
|||
var dstPict = BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId, pPictName); |
|||
|
|||
console.log("Resizing "+dstPict); |
|||
|
|||
BOB_mod_gm(srcPict) |
|||
.autoOrient() |
|||
.gravity('Center') |
|||
.resize(BOB_cfg_config.cropSize.width, BOB_cfg_config.cropSize.height, "^") |
|||
.crop(BOB_cfg_config.cropSize.width, BOB_cfg_config.cropSize.height) |
|||
// .modulate(100, 0)
|
|||
// .contrast(+2)
|
|||
.write(dstPict, function(pErr) { |
|||
pCb() |
|||
}) |
|||
}) |
|||
}) |
|||
|
|||
BOB_mod_async.parallel( |
|||
funcResizeArray, |
|||
function(pErr, pData) { |
|||
console.log("Building booth") |
|||
switch(BOB_cfg_config.style) { |
|||
default : |
|||
BOB_generateBooth(pBoothId, 'default', pCallback); |
|||
} |
|||
} |
|||
) |
|||
} |
|||
|
|||
function BOB_generateBooth(pBoothId, pType, pCallback) { |
|||
var prebuiltPath = BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId); |
|||
var finalPict = BOB_mod_path.join(BOB_cfg_config.paths.final, pBoothId+".jpg"); |
|||
var finalLdPict = BOB_mod_path.join(BOB_cfg_config.paths.final_ld, pBoothId+".jpg"); |
|||
var outPict = BOB_mod_gm(BOB_cfg_config.booths[pType].template); |
|||
|
|||
var printedDate = new Date(parseInt(pBoothId)); |
|||
|
|||
outPict.fill(BOB_cfg_config.background); |
|||
outPict.drawRectangle(0, 0, BOB_cfg_config.booths[pType].resolution.width, BOB_cfg_config.booths[pType].resolution.height); |
|||
|
|||
BOB_cfg_config.pictNames.forEach(function(pPictName, pIndex) { |
|||
var cmdDraw = 'image Over'; |
|||
cmdDraw += ' '+BOB_cfg_config.booths[pType].layout[pIndex].x; |
|||
cmdDraw += ','+BOB_cfg_config.booths[pType].layout[pIndex].y; |
|||
cmdDraw += ' '+BOB_cfg_config.booths[pType].layout[pIndex].width; |
|||
cmdDraw += ','+BOB_cfg_config.booths[pType].layout[pIndex].height; |
|||
cmdDraw += ' '+BOB_mod_path.join(prebuiltPath, pPictName); |
|||
|
|||
console.log(cmdDraw); |
|||
outPict.draw(cmdDraw); |
|||
}) |
|||
|
|||
outPict.fill("#000000"); |
|||
outPict.pointSize(40); |
|||
outPict.draw('text 1900,3850 "'+printedDate.toUTCString()+'"'); |
|||
|
|||
outPict.write(finalPict, function (pErr) { |
|||
BOB_mod_gm(finalPict) |
|||
.resize(600, null) |
|||
.write(finalLdPict, function(pErr) { |
|||
pCallback(pErr); |
|||
}) |
|||
}); |
|||
} |
|||
|
|||
module.exports = function(pConfig) { |
|||
BOB_cfg_config = pConfig; |
|||
BOB_updateConfig(); |
|||
return BOB_module; |
|||
} |
|||
|
|||
|
|||
function BOB_updateConfig() { |
|||
BOB_mod_fs.readdir(BOB_cfg_config.paths.template, function(pErr, pFiles) { |
|||
if( pErr ) { |
|||
console.log(pErr); |
|||
} else { |
|||
BOB_mod_async.map(pFiles, |
|||
function(pFile, pCb) { |
|||
// Get name of template
|
|||
var boothName = pFile.split('.')[0]; |
|||
// Init layouts object for the template
|
|||
BOB_cfg_config.booths[boothName] = { |
|||
name : boothName, |
|||
template : BOB_mod_path.join(BOB_cfg_config.paths.template, pFile), |
|||
resolution : { width : 0, height : 0 }, |
|||
layout : [] |
|||
}; |
|||
// Get reslution of current template
|
|||
BOB_mod_gm(BOB_cfg_config.booths[boothName].template).size(function(pErr, pValue){ |
|||
if( pErr ) { |
|||
console.log(pErr); |
|||
} else { |
|||
BOB_cfg_config.booths[boothName].resolution = pValue; |
|||
BOB_generatePictLayout(boothName); |
|||
} |
|||
pCb(); |
|||
}) |
|||
}, |
|||
function(pErr) { |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
|
|||
function BOB_generatePictLayout(pBoothName) { |
|||
var index = 0; |
|||
var marginX = 50; |
|||
var marginY = 50; |
|||
|
|||
var pictWidth = ( BOB_cfg_config.booths[pBoothName].resolution.width - 3 * marginX ) / 2; |
|||
var pictHeight = parseInt(pictWidth * BOB_cfg_config.cropSize.height / BOB_cfg_config.cropSize.width); |
|||
|
|||
BOB_cfg_config.pictNames.forEach(function(pPictName, pIndex) { |
|||
BOB_cfg_config.booths[pBoothName].layout.push({ |
|||
x : marginX + (marginX + pictWidth) * ( pIndex % 2 ), |
|||
y : marginY + (marginY + pictHeight) * parseInt( pIndex / 2 ), |
|||
width : pictWidth, |
|||
height : pictHeight |
|||
}) |
|||
}) |
|||
|
|||
console.log("INIT DONE"); |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
|
|||
|
|||
module.exports = function(pConfig) { |
|||
console.log("TOOL TEST", pConfig); |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<h1><%= message %></h1> |
|||
<h2><%= error.status %></h2> |
|||
<pre><%= error.stack %></pre> |
|||
@ -0,0 +1,161 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|||
<title><%= title %></title> |
|||
<!-- Latest compiled and minified CSS --> |
|||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> |
|||
<link rel="stylesheet" href="/css/cover.css"/> |
|||
</head> |
|||
<body> |
|||
<div class="site-wrapper"> |
|||
<div class="site-wrapper-inner"> |
|||
<div class="cover-container"> |
|||
<div class="inner cover" style="height:900px;position:relative"> |
|||
|
|||
<div id="idBoothPanel" style="position:absolute;width:100%"> |
|||
<div style="height:180px"> |
|||
<div id="idViewTrigger"> |
|||
<h1 class="cover-heading">Prends ta face !</h1> |
|||
</div> |
|||
<div id="idViewCountdown" style="font-size:15em; display:none"></div> |
|||
</div> |
|||
<div style="font-size:8em; height:600px; display:none"> |
|||
Faites<br/> |
|||
<span style="font-size:2em">le chat</span> |
|||
</div> |
|||
</div> |
|||
|
|||
<div id="idPictPreview" style="position:absolute;display:none;width:100%"> |
|||
<img src="/img/test.jpgautoOrient.jpg" height="900px"> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="mastfoot"> |
|||
<div class="inner"> |
|||
<p>BW Bros.</p> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
</body> |
|||
<!-- Latest compiled and minified JQuery --> |
|||
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script> |
|||
<!-- Latest compiled and minified javaScript bootstrap--> |
|||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> |
|||
<!-- Getting the Socket.IO Client --> |
|||
<script src="https://cdn.socket.io/socket.io-1.3.4.js"></script> |
|||
</html> |
|||
|
|||
<style type="text/css"> |
|||
* { |
|||
-webkit-box-sizing: border-box; |
|||
box-sizing: border-box; |
|||
} |
|||
</style> |
|||
|
|||
<script type="text/javascript"> |
|||
|
|||
var socket = io('http://192.168.1.18:3000'); |
|||
|
|||
socket.on('connect', function() { |
|||
console.log("connect") |
|||
}) |
|||
|
|||
socket.on('boothClick', function(pData) { |
|||
BOB_runBooth(); |
|||
}); |
|||
|
|||
BOB_var_context = { |
|||
boothOnGoing : false, |
|||
initTimer : 3, |
|||
onGoingTimer : 0, |
|||
boothId : null, |
|||
pictureId : 0 |
|||
} |
|||
|
|||
BOB_var_themes = [ |
|||
"le chat", |
|||
"le cuir moustache", |
|||
"le roi", |
|||
"le bouffon", |
|||
"le moussailon", |
|||
"le geek", |
|||
"l'amoureux", |
|||
] |
|||
|
|||
$(document).ready(function() { |
|||
$('#idBtnClick').click(function() { |
|||
BOB_runBooth(); |
|||
}) |
|||
}) |
|||
|
|||
function BOB_runBooth() { |
|||
|
|||
if( BOB_var_context.boothOnGoing === false ) { |
|||
var currentDate = new Date(); |
|||
BOB_var_context.boothOnGoing = true; |
|||
BOB_var_context.boothId = currentDate.getTime(); |
|||
BOB_var_context.pictureId = 0; |
|||
BOB_var_context.onGoingTimer = BOB_var_context.initTimer; |
|||
$('#idViewTrigger').fadeOut(500, function() { |
|||
BOB_countdown(); |
|||
}); |
|||
} |
|||
|
|||
} |
|||
|
|||
function BOB_countdown() { |
|||
$('#idViewCountdown').fadeIn(); |
|||
$('#idViewCountdown').html(BOB_var_context.onGoingTimer); |
|||
if( BOB_var_context.onGoingTimer > 0 ) { |
|||
setTimeout(function() { |
|||
BOB_var_context.onGoingTimer -= 1; |
|||
BOB_countdown(); |
|||
}, 1000) |
|||
} else { |
|||
$('#idViewCountdown').html("Smile :-)"); |
|||
BOB_takeThe1Pictures(); |
|||
} |
|||
} |
|||
|
|||
function BOB_displayPictPreview(pBoothId, pPictureId, pCallback) { |
|||
$('#idViewCountdown').html(""); |
|||
$('#idPictPreview > img').attr('src', '/img/original/'+pBoothId+'/pict_'+pPictureId+'.jpg'); |
|||
$('#idBoothPanel').fadeOut(50, function() { |
|||
$('#idPictPreview').show(); |
|||
setTimeout(function() { |
|||
$('#idPictPreview').hide(); |
|||
$('#idBoothPanel').fadeIn(50, function() { |
|||
pCallback() |
|||
}) |
|||
}, 2000) |
|||
}) |
|||
} |
|||
|
|||
function BOB_takeThe1Pictures() { |
|||
$.get('/dslr/takepicture/'+BOB_var_context.boothId+'/'+BOB_var_context.pictureId, function(pResponse) { |
|||
console.log(pResponse); |
|||
|
|||
BOB_displayPictPreview(BOB_var_context.boothId, BOB_var_context.pictureId, function() { |
|||
BOB_var_context.pictureId += 1; |
|||
if( BOB_var_context.pictureId < 4 ) { |
|||
BOB_var_context.onGoingTimer = BOB_var_context.initTimer; |
|||
BOB_countdown(); |
|||
} else { |
|||
BOB_var_context.boothOnGoing = false; |
|||
$.get('/booth/build/'+BOB_var_context.boothId); |
|||
$('#idViewCountdown').fadeOut(500, function() { |
|||
$('#idViewTrigger').fadeIn(); |
|||
}); |
|||
} |
|||
}) |
|||
}) |
|||
} |
|||
|
|||
|
|||
</script> |
|||
@ -0,0 +1,72 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|||
<title><%= title %></title> |
|||
<!-- Latest compiled and minified CSS --> |
|||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> |
|||
<link rel="stylesheet" href="/css/cover.css"/> |
|||
</head> |
|||
<body> |
|||
|
|||
<body> |
|||
|
|||
<div class="site-wrapper"> |
|||
<div class="site-wrapper-inner"> |
|||
<div class="cover-container"> |
|||
<div class="masthead clearfix"> |
|||
<div class="inner"> |
|||
<h3 class="masthead-brand">Bobinoscope</h3> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="inner cover"> |
|||
<h1 class="cover-heading">Prends ta face !</h1> |
|||
<p class="lead"> |
|||
<a href="#" class="btn btn-lg btn-default" id="idBtnClick">Clic</a> |
|||
</p> |
|||
<img id="idDisplayImg" width="640px"/> |
|||
</div> |
|||
|
|||
<div class="mastfoot"> |
|||
<div class="inner"> |
|||
<p>BW Bros.</p> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
</body> |
|||
<!-- Latest compiled and minified JQuery --> |
|||
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script> |
|||
<!-- Latest compiled and minified javaScript bootstrap--> |
|||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> |
|||
</html> |
|||
|
|||
<script type="text/javascript"> |
|||
$(document).ready(function() { |
|||
$('#idBtnClick').click(function() { |
|||
BOB_takeThe4Pictures(); |
|||
}) |
|||
}) |
|||
|
|||
function BOB_takeThe4Pictures() { |
|||
var currentDate = new Date(); |
|||
var pictId = 0; |
|||
var boothId = currentDate.getTime(); |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
function BOB_takeOnePicture(pBoothId, pPictId) { |
|||
$.get('/dslr/takepicture', function(pResponse) { |
|||
$('#idDisplayImg').attr('src', pResponse.data); |
|||
}) |
|||
} |
|||
|
|||
|
|||
</script> |
|||
@ -0,0 +1,93 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|||
<title>Bobinoscope</title> |
|||
<!-- Latest compiled and minified CSS --> |
|||
<link rel="stylesheet" href="/css/view.css"/> |
|||
</head> |
|||
<body> |
|||
<div id="idMain" style="width:400px; margin: auto"> |
|||
<div id="idViewLoading"> |
|||
<img src='/img/common/294.GIF'/> |
|||
</div> |
|||
<div id="idViewContainer"> |
|||
|
|||
</div> |
|||
|
|||
</div> |
|||
</body> |
|||
<!-- Latest compiled and minified JQuery --> |
|||
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script> |
|||
<!-- Latest compiled and minified javaScript bootstrap--> |
|||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> |
|||
<!-- Getting the Socket.IO Client --> |
|||
<script src="https://cdn.socket.io/socket.io-1.3.4.js"></script> |
|||
</html> |
|||
|
|||
<script type="text/javascript"> |
|||
|
|||
var socket = io('http://192.168.1.18:3000'); |
|||
socket.on('connect', function() { |
|||
console.log("connect") |
|||
}) |
|||
socket.on('boothState', function (data) { |
|||
BOB_getBooths(); |
|||
}); |
|||
|
|||
$(document).ready(function() { |
|||
BOB_getBooths(); |
|||
|
|||
if( $(window).width() < 400 ) { |
|||
$('#idMain').css('width' ,'100%'); |
|||
} |
|||
}) |
|||
|
|||
var BOB_var_lastBooth = "0"; |
|||
|
|||
function BOB_getBooths() { |
|||
var boothList = $(".classBoothItem"); |
|||
var jqBoothContainer = $('#idViewContainer'); |
|||
|
|||
$.get('/booth/list/'+BOB_var_lastBooth, function(pResponse) { |
|||
if( pResponse.inProgress > 0 ) { |
|||
$('#idViewLoading').fadeIn(); |
|||
} else { |
|||
$('#idViewLoading').fadeOut(); |
|||
} |
|||
|
|||
pResponse.booths.forEach(function(pBoothName) { |
|||
var jqImg = $('<img>'); |
|||
jqImg.css('width', '100%'); |
|||
jqImg.css('opacity', '0'); |
|||
jqImg.css('transition', 'opacity 1s'); |
|||
jqImg.data('booth', pBoothName); |
|||
jqImg.attr('src', "/img/final_ld/"+pBoothName); |
|||
jqImg.addClass('classBoothItem'); |
|||
|
|||
jqImg.on('click', function() { |
|||
jqImg.css('opacity', '0.4'); |
|||
if( confirm("Télécharger ?") ) { |
|||
window.open("/download/final/hd/"+pBoothName, "_blank"); |
|||
} |
|||
jqImg.css('opacity', '1'); |
|||
}) |
|||
|
|||
jqImg.on('load', function() { |
|||
jqImg.css('opacity', '1'); |
|||
}) |
|||
|
|||
if( pBoothName.localeCompare(BOB_var_lastBooth) > 0 ) { |
|||
BOB_var_lastBooth = pBoothName; |
|||
} |
|||
|
|||
jqBoothContainer.prepend(jqImg); |
|||
}) |
|||
}) |
|||
|
|||
console.log('-----------------'); |
|||
} |
|||
|
|||
</script> |
|||
Write
Preview
Loading…
Cancel
Save