forked from thomasjacquin/allsky-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublic.php
executable file
·56 lines (44 loc) · 2.12 KB
/
public.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
include_once('includes/functions.php');
$cam = get_variable('/home/pi/allsky/autocam.sh', 'CAMERA=', 'ZWO');
$img_dir = get_variable('/home/pi/allsky/config.sh', 'IMG_DIR=', 'current');
$img_prefix = get_variable('/home/pi/allsky/config.sh', 'IMG_PREFIX=', 'liveview-');
define('RASPI_CONFIG', '/etc/raspap');
define('RASPI_CAMERA_SETTINGS', RASPI_CONFIG . '/settings_'.$cam.'.json');
$camera_settings_str = file_get_contents(RASPI_CAMERA_SETTINGS, true);
$camera_settings_array = json_decode($camera_settings_str, true);
$image_name = $img_dir . "/" . $img_prefix . $camera_settings_array['filename'];
?>
<style>
body {
margin: 0;
}
</style>
<div class="row">
<div id="live_container" style="background-color: black;">
<img id="current" class="current" src="<?php echo $image_name ?>" style="width:100%">
</div>
</div>
<!-- jQuery -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript">
function getImage(){
var img = $("<img />").attr('src', '<?php echo $image_name ?>?_ts=' + new Date().getTime())
.attr("id", "current")
.attr("class", "current")
.css("width", "100%")
.on('load', function() {
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
console.log('broken image!');
setTimeout(function(){
getImage();
}, 500);
} else {
$("#live_container").empty().append(img);
}
});
}
setInterval(function(){
getImage();
}, <?php echo $camera_settings_array["nightexposure"]/1000 < 5000 ? 5000 : $camera_settings_array["nightexposure"]/1000?>);
</script>