Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.

Commit 2fe2866

Browse files
committed
config: allow to disable continous check for new pictures
- also allow to adjust the time our database get checked for updates Change-Id: Ic20cb370b0bd8b1c71c3885e2b3c035aba5ac9a9
1 parent 946e72a commit 2fe2866

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

config/config.inc.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@
127127
$config['gallery']['date_format'] = 'd.m.Y - G:i';
128128
$config['gallery_pictureTime'] = '3000';
129129
$config['gallery_bottom_bar'] = true;
130+
$config['gallery_db_check_enabled'] = true;
131+
$config['gallery_db_check_time'] = '10';
132+
130133
// PhotoSwipe
131134
$config['pswp_clickToCloseNonZoomable'] = false;
132135
$config['pswp_closeOnScroll'] = false;

gallery.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
// to detect changes
1111
$resp = array('dbsize'=>getDBSize());
1212
exit(json_encode($resp));
13-
1413
}
1514

1615
$images = getImagesFromDB();
@@ -101,7 +100,9 @@
101100
<script type="text/javascript" src="resources/js/theme.js"></script>
102101
<script type="text/javascript" src="resources/js/core.js"></script>
103102
<script type="text/javascript" src="resources/js/gallery.js"></script>
103+
<?php if ($config['gallery_db_check_enabled']): ?>
104104
<script type="text/javascript" src="resources/js/gallery_updatecheck.js"></script>
105+
<?php endif; ?>
105106
<script src="node_modules/@andreasremdt/simple-translator/dist/umd/translator.min.js"></script>
106107
<script type="text/javascript" src="resources/js/i18n.js"></script>
107108
</body>

lib/configsetup.inc.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,17 @@
818818
'name' => 'gallery_pictureTime',
819819
'value' => $config['gallery_pictureTime']
820820
],
821+
'gallery_db_check_enabled' => [
822+
'type' => 'checkbox',
823+
'name' => 'gallery_db_check_enabled',
824+
'value' => $config['gallery_db_check_enabled']
825+
],
826+
'db_check_time' => [
827+
'type' => 'input',
828+
'placeholder' => $defaultConfig['gallery_db_check_time'],
829+
'name' => 'gallery_db_check_time',
830+
'value' => $config['gallery_db_check_time']
831+
],
821832
'pswp_clickToCloseNonZoomable' => [
822833
'type' => 'checkbox',
823834
'name' => 'pswp_clickToCloseNonZoomable',

resources/lang/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
"gallery": "Gallery",
5252
"gallery_bottom_bar": "Show button bar inside gallery on bottom",
5353
"gallery_date_format": "Date style",
54+
"gallery_db_check_enabled": "Continuously check for new pictures in standalone gallery",
55+
"gallery_db_check_time": "Interval at which the database is checked for new images (in seconds):",
5456
"gallery_no_image": "The gallery is still empty. Take some pictures!",
5557
"gallery_pictureTime": "Milliseconds an image is displayed at slideshow",
5658
"gallery_pswp_bgOpacity": "Background opacity",
@@ -144,6 +146,8 @@
144146
"manual_force_buzzer": "If enabled, the take picture and collage buttons disappear. You now get a button which tells to use a buzzer to take a picture or collage.",
145147
"manual_gallery_bottom_bar": "If enabled, the button bar is shown in the gallery below.",
146148
"manual_gallery_date_format": "Enter your date style.",
149+
"manual_gallery_db_check_enabled": "If enabled, Photobooth continuously checks for new pictures in standalone gallery and reloads the page on inactivity (time of inactivity depends on \"Show image after capture:\" option).",
150+
"manual_gallery_db_check_time": "Add the interval (in seconds) the database get checked for new images.",
147151
"manual_gallery_pictureTime": "Add a value which is used as milliseconds an image is displayed at slideshow inside the gallery.",
148152
"manual_gallery_pswp_bgOpacity": "Background opacity, low values make the background more transparent.",
149153
"manual_general_camera_mode": "Choose between front- or back facing camera mode of your device cam.",

src/js/gallery_updatecheck.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* If changes are detected, the page will automatically be reloaded.
55
*
66
* Needs:
7-
* jQuery
8-
* photoBooth Javascript
7+
* - jQuery
8+
* - photoBooth Javascript
99
*
1010
* Remarks:
1111
* - Not made for highly demanded pages (as pages is requested regulary
@@ -18,7 +18,7 @@
1818
// Size of the DB - is used to determine changes
1919
let lastDBSize = -1;
2020
// Interval, the page is checked (/ms)
21-
const interval = 1000 * 5;
21+
const interval = 1000 * config.gallery_db_check_time;
2222
// URL to request for changes
2323
const ajaxurl = 'gallery.php?status';
2424

@@ -34,7 +34,11 @@ function dbUpdated() {
3434

3535
const checkForUpdates = function () {
3636
if (photoBooth.isTimeOutPending()) {
37-
//If there is user interaction, do not check for updates
37+
// If there is user interaction, do not check for updates
38+
if (config.dev) {
39+
console.log('Timeout pending, waiting to refresh the standalone gallery');
40+
}
41+
3842
return;
3943
}
4044
$.getJSON({

0 commit comments

Comments
 (0)