Skip to content

Commit

Permalink
core: global define photoBooth.takingPic
Browse files Browse the repository at this point in the history
Change-Id: I7cad7a84cf8af17ef0d6bf0148e8143c1f2c3d1e
  • Loading branch information
andi34 committed Oct 21, 2022
1 parent 4855f55 commit 9f1645a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
29 changes: 17 additions & 12 deletions src/js/core.js
Expand Up @@ -60,7 +60,6 @@ const photoBooth = (function () {

let timeOut,
isPrinting = false,
takingPic = false,
chromaFile = '',
currentCollageFile = '',
imgFilter = config.filters.defaults,
Expand All @@ -69,6 +68,7 @@ const photoBooth = (function () {
endTime,
totalTime;

api.takingPic = false;
api.nextCollageNumber = 0;

api.isTimeOutPending = function () {
Expand All @@ -80,7 +80,7 @@ const photoBooth = (function () {

photoboothTools.console.log('Timeout for auto reload cleared.');

if (!takingPic) {
if (!api.takingPic) {
photoboothTools.console.logDev('Timeout for auto reload set to', timeToLive, ' milliseconds.');
timeOut = setTimeout(function () {
photoboothTools.reloadPage();
Expand Down Expand Up @@ -214,14 +214,19 @@ const photoBooth = (function () {
};

api.thrill = function (photoStyle, retry = 0) {
if (api.takingPic) {
photoboothTools.console.logDev('Taking picture in progress already!');

return;
}
api.navbar.close();
api.reset();
api.closeGallery();
api.showResultInner(false);

remoteBuzzerClient.inProgress(true);
takingPic = true;
photoboothTools.console.logDev('Taking picture in progress: ' + takingPic);
api.takingPic = true;
photoboothTools.console.logDev('Taking picture in progress: ' + api.takingPic);

if (api.isTimeOutPending()) {
api.resetTimeOut();
Expand Down Expand Up @@ -522,9 +527,9 @@ const photoBooth = (function () {
if (config.dev.loglevel > 1) {
loading.append($('<p class="text-muted">').text(data.error));
}
takingPic = false;
api.takingPic = false;
remoteBuzzerClient.inProgress(false);
photoboothTools.console.logDev('Taking picture in progress: ' + takingPic);
photoboothTools.console.logDev('Taking picture in progress: ' + api.takingPic);
if (config.dev.reload_on_error) {
loading.append($('<p>').text(photoboothTools.getTranslation('auto_reload')));
setTimeout(function () {
Expand Down Expand Up @@ -613,9 +618,9 @@ const photoBooth = (function () {

preloadImage.src = imageUrl;

takingPic = false;
api.takingPic = false;
remoteBuzzerClient.inProgress(false);
photoboothTools.console.logDev('Taking picture in progress: ' + takingPic);
photoboothTools.console.logDev('Taking picture in progress: ' + api.takingPic);

api.resetTimeOut();
};
Expand Down Expand Up @@ -726,9 +731,9 @@ const photoBooth = (function () {
api.shellCommand('post-command', filename);
}

takingPic = false;
api.takingPic = false;
remoteBuzzerClient.inProgress(false);
photoboothTools.console.logDev('Taking picture in progress: ' + takingPic);
photoboothTools.console.logDev('Taking picture in progress: ' + api.takingPic);

api.resetTimeOut();

Expand Down Expand Up @@ -1165,7 +1170,7 @@ const photoBooth = (function () {
$(document).on('keyup', function (ev) {
if (triggerPic[0] || triggerCollage[0]) {
if (config.picture.key && parseInt(config.picture.key, 10) === ev.keyCode) {
if (takingPic) {
if (api.takingPic) {
api.handleButtonPressWhileTakingPic();
} else {
$('.closeGallery').trigger('click');
Expand All @@ -1181,7 +1186,7 @@ const photoBooth = (function () {
}

if (config.collage.key && parseInt(config.collage.key, 10) === ev.keyCode) {
if (takingPic) {
if (api.takingPic) {
api.handleButtonPressWhileTakingPic();
} else {
$('.closeGallery').trigger('click');
Expand Down
12 changes: 5 additions & 7 deletions src/js/livechroma.js
Expand Up @@ -8,7 +8,6 @@ let seriously;
let target;
let chroma;
let seriouslyimage;
let takingPic = false;
let needsReload = false;

function greenToTransparency(imageIn, imageOut) {
Expand Down Expand Up @@ -193,7 +192,7 @@ function saveImage(cb) {
imgData: dataURL
},
function (data) {
takingPic = false;
photoBooth.takingPic = false;
needsReload = true;
if ($('.chroma-control-bar').is(':hidden')) {
$('.chroma-control-bar').show();
Expand Down Expand Up @@ -266,7 +265,6 @@ $('.backgroundPreview').on('click', function () {
// Take Chroma Button
$('.takeChroma, .newchroma').on('click', function (e) {
e.preventDefault();
takingPic = true;
const chromaInfo = photoboothTools.getTranslation('chromaInfoAfter');

photoBooth.thrill('chroma');
Expand All @@ -292,10 +290,10 @@ $(document).on('keyup', function (ev) {
photoboothTools.console.log('Please choose a background first!');
} else if (needsReload) {
photoboothTools.console.log('Please reload the page to take a new Picture!');
} else if (!takingPic) {
} else if (!photoBooth.takingPic) {
$('.closeGallery').trigger('click');
$('.takeChroma').trigger('click');
} else if (config.dev.loglevel > 0 && takingPic) {
} else if (config.dev.loglevel > 0 && photoBooth.takingPic) {
photoboothTools.console.log('Taking photo already in progress!');
}
}
Expand All @@ -305,11 +303,11 @@ $(document).on('keyup', function (ev) {
photoboothTools.console.log('Please choose a background first!');
} else if (needsReload) {
photoboothTools.console.log('Please reload the page to take a new Picture!');
} else if (!takingPic) {
} else if (!photoBooth.takingPic) {
$('.closeGallery').trigger('click');
photoboothTools.console.logDev('Collage key pressed. Not possible on live chroma, triggering photo now.');
$('.takeChroma').trigger('click');
} else if (config.dev.loglevel > 0 && takingPic) {
} else if (config.dev.loglevel > 0 && photoBooth.takingPic) {
photoboothTools.console.log('Taking photo already in progress!');
}
}
Expand Down

0 comments on commit 9f1645a

Please sign in to comment.