-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
80 lines (73 loc) · 2.67 KB
/
index.html
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="3600" >
<title>Auto Image Circle</title>
<!-- TOOD Add Caduceus monitoring -->
<style type="text/css">
.bg {
position: fixed;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
}
.bg img {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
min-width: 50%;
min-height: 50%;
}
</style>
</head>
<body>
<div id="initial-bg" class="bg"><img src="img/initial-background.png" alt=""></div>
<div id="img-container"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(function () {
var fetchConfig = function () {
// config.html because config.json cannot be delivered by telekom business server
var jqXHR = $.getJSON("config.html", function (data) {
//var jqXHR = $.getJSON("config.json", function (data) {
//console.log("Got a new configuration " + data.images.length);
images = data.images;
});
return jqXHR;
};
var initialImage = $('#initial-bg');
var images = [];
var indexOfCurrentImage = 0;
var displayImage = function () {
if (initialImage.is(':visible')) {
initialImage.fadeOut('slow', function() {
$('img[src="' + images[0] + '"]').parent('.bg').fadeIn('slow');
indexOfCurrentImage = 0;
});
} else {
var indexOfNextImage = indexOfCurrentImage + 1 < images.length ? indexOfCurrentImage + 1 : 0;
$('img[src="' + images[indexOfCurrentImage] + '"]').parent('.bg').fadeOut('slow', function() {
$('img[src="' + images[indexOfNextImage] + '"]').parent('.bg').fadeIn('slow');
indexOfCurrentImage = indexOfNextImage;
});
}
};
// Initial fetch of the configuration and after success, starting the image circle
fetchConfig().success(function () {
for (var i = 0, length = images.length; i < length; i++) {
var imageUrl = images[i];
var bgElem = '<div class="bg" style="display: none;"><img src="' + imageUrl + '" alt=""/></div>';
$('#img-container').append(bgElem);
}
indexOfCurrentImage = images.length - 1;
window.setInterval(displayImage, 12000);
});
});
</script>
</body>
</html>