-
Notifications
You must be signed in to change notification settings - Fork 20
/
public.php
53 lines (47 loc) · 1.42 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
<?php
// functions.php sets a bunch of constants and variables,
// including $image_name and $delay.
// It needs to be at the top of this file since code below uses the items it sets.
include_once('includes/functions.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<style> body { margin: 0; } </style>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Thomas Jacquin">
<title>AllSky Public Page</title>
</head>
<body>
<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>
<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 $delay ?>);
</script>
</body>
</html>