-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·63 lines (52 loc) · 1.65 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
<!DOCTYPE html>
<html>
<head>
<title>VMP</title>
<style type="text/css">
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
text-align: center;
}
img {
max-width: 100%;
min-height: 100%;
}
</style>
<script src="https://cdn.jsdelivr.net/lodash/4.12.0/lodash.min.js"></script>
</head>
<body>
<img id="img" alt="Nothing found yet" />
<script type="text/javascript">
var params = {};
var pairs = location.search.substring(1).split('&');
_.forEach(pairs, function (item) {
var key = decodeURIComponent(item.split('=')[0]);
var value = decodeURIComponent(item.split('=')[1]);
params[key] = value;
});
var img = document.getElementById('img');
var interval = 15 * 60 * 1000;
var tag = params.tag || 'tableflip';
function nextImage() {
var url = 'http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=' + tag;
fetch(url).then(function (response) {
response.json().then(function (json) {
var src = _.get(json, 'data.image_url');
if (!!src) {
img.src = src;
}
setTimeout(nextImage, interval);
});
}).catch(function (error) {
console.log(error);
setTimeout(nextImage, interval);
});
}
nextImage();
</script>
</body>
</html>