Browse Source

simplify coutdown

bob
P.BARRY 10 years ago
parent
commit
5cbfa3e768
2 changed files with 53 additions and 29 deletions
  1. 21
      tools/tools-gphoto2.js
  2. 61
      views/index.ejs

21
tools/tools-gphoto2.js

@ -55,16 +55,17 @@ BOB_module.takePicture = function(pBoothId, pPictId, pCallback) {
} else { } else {
BOB_mod_mkdirp(destPath, function() { BOB_mod_mkdirp(destPath, function() {
BOB_mod_fs.writeFile(pictOrig, pData, function(pErr) { BOB_mod_fs.writeFile(pictOrig, pData, function(pErr) {
BOB_mod_gm(pictOrig)
.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(pictOrig, function(pErr) {
return pCallback(pErr, pictPblt)
})
// BOB_mod_gm(pictOrig)
// .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(pictOrig, function(pErr) {
// return pCallback(pErr, pictPblt)
// })
return pCallback(pErr, pictOrig)
}); });
}) })
} }

61
views/index.ejs

@ -22,9 +22,9 @@
</div> </div>
<div id="idViewCountdown" style="font-size:15em; display:none"></div> <div id="idViewCountdown" style="font-size:15em; display:none"></div>
</div> </div>
<div style="font-size:8em; height:600px; display:none">
<div id="idViewDoIt" style="font-size:8em; height:600px; display:none">
Faites<br/> Faites<br/>
<span style="font-size:2em">le chat</span>
<span id="idViewDoIt-theme" style="font-size:2em">le chat</span>
</div> </div>
</div> </div>
@ -70,23 +70,26 @@ socket.on('boothClick', function(pData) {
BOB_runBooth(); BOB_runBooth();
}); });
BOB_var_context = {
var BOB_var_context = {
boothOnGoing : false, boothOnGoing : false,
initTimer : 3,
initTimer : 6,
onGoingTimer : 0, onGoingTimer : 0,
boothId : null, boothId : null,
pictureId : 0 pictureId : 0
} }
BOB_var_themes = [
"le chat",
"le cuir moustache",
"le roi",
"le bouffon",
"le moussailon",
"le geek",
"l'amoureux",
]
var BOB_var_themes = {
selectedId : 0,
list : [
"le chat",
"le cuir moustache",
"le roi",
"le bouffon",
"le moussailon",
"le geek",
"l'amoureux",
]
}
$(document).ready(function() { $(document).ready(function() {
$('#idBtnClick').click(function() { $('#idBtnClick').click(function() {
@ -95,30 +98,38 @@ $(document).ready(function() {
}) })
function BOB_runBooth() { function BOB_runBooth() {
if( BOB_var_context.boothOnGoing === false ) { if( BOB_var_context.boothOnGoing === false ) {
var currentDate = new Date(); var currentDate = new Date();
BOB_var_context.boothOnGoing = true; BOB_var_context.boothOnGoing = true;
BOB_var_context.boothId = currentDate.getTime(); BOB_var_context.boothId = currentDate.getTime();
BOB_var_context.pictureId = 0; BOB_var_context.pictureId = 0;
BOB_var_context.onGoingTimer = BOB_var_context.initTimer; BOB_var_context.onGoingTimer = BOB_var_context.initTimer;
$('#idViewTrigger').fadeOut(500, function() { $('#idViewTrigger').fadeOut(500, function() {
BOB_countdown(); BOB_countdown();
}); });
} }
} }
function BOB_countdown() { function BOB_countdown() {
$('#idViewCountdown').fadeIn(); $('#idViewCountdown').fadeIn();
$('#idViewCountdown').html(BOB_var_context.onGoingTimer); $('#idViewCountdown').html(BOB_var_context.onGoingTimer);
//
if( BOB_var_context.onGoingTimer > 5 ) {
// $('#idViewDoIt').show();
// $('#idViewDoIt-theme').hide();
} else if( BOB_var_context.onGoingTimer > 2 ) {
// $('#idViewDoIt-theme').html( BOB_var_themes.list[BOB_var_themes.selectedId] );
// $('#idViewDoIt-theme').show();
}
if( BOB_var_context.onGoingTimer > 0 ) { if( BOB_var_context.onGoingTimer > 0 ) {
setTimeout(function() { setTimeout(function() {
BOB_var_context.onGoingTimer -= 1; BOB_var_context.onGoingTimer -= 1;
BOB_countdown(); BOB_countdown();
}, 1000) }, 1000)
} else { } else {
$('#idViewCountdown').html("Smile :-)");
$('#idViewCountdown').html("Smile");
BOB_takeThe1Pictures(); BOB_takeThe1Pictures();
} }
} }
@ -139,9 +150,21 @@ function BOB_displayPictPreview(pBoothId, pPictureId, pCallback) {
function BOB_takeThe1Pictures() { function BOB_takeThe1Pictures() {
$.get('/dslr/takepicture/'+BOB_var_context.boothId+'/'+BOB_var_context.pictureId, function(pResponse) { $.get('/dslr/takepicture/'+BOB_var_context.boothId+'/'+BOB_var_context.pictureId, function(pResponse) {
console.log(pResponse);
if( pResponse.error ) {
if( confirm(pResponse.error) ) {
BOB_var_context.boothOnGoing = false;
$('#idViewCountdown').fadeOut(500, function() {
$('#idViewTrigger').fadeIn();
});
return;
}
}
// $('#idViewDoIt').hide();
// $('#idViewDoIt-theme').hide();
// BOB_var_themes.selectedId++;
BOB_displayPictPreview(BOB_var_context.boothId, BOB_var_context.pictureId, function() {
// BOB_displayPictPreview(BOB_var_context.boothId, BOB_var_context.pictureId, function() {
BOB_var_context.pictureId += 1; BOB_var_context.pictureId += 1;
if( BOB_var_context.pictureId < 4 ) { if( BOB_var_context.pictureId < 4 ) {
BOB_var_context.onGoingTimer = BOB_var_context.initTimer; BOB_var_context.onGoingTimer = BOB_var_context.initTimer;
@ -153,7 +176,7 @@ function BOB_takeThe1Pictures() {
$('#idViewTrigger').fadeIn(); $('#idViewTrigger').fadeIn();
}); });
} }
})
// })
}) })
} }

Loading…
Cancel
Save