-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
134 lines (121 loc) · 4.26 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<html>
<head>
<title>WAIT FOR GIF</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="jquery.xdomainajax.js"></script>
<script>
$(function() {
var url_params;
(window.onpopstate = function () {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
url_params = {};
while (match = search.exec(query))
url_params[decode(match[1])] = decode(match[2]);
})();
window.load_bees_bombs = function() {
$.ajax({
url: 'http://beesandbombs.tumblr.com/rss',
type: 'GET',
dataType: 'text',
crossDomain: 'true',
xhrFields: {
withCredentials: true
},
success: function(data) {
var urls = [];
var RE = /src="(.+?\.gif)"/g;
var match = RE.exec(data.responseText);
while (match != null) {
urls.push(match[1]);
match = RE.exec(data.responseText);
}
$('.gifLoader').html('<img src="' + urls[0] + '" />');
window.setInterval(window.deploy_random_gif, 30000, urls);
}
});
}
window.load_gifbin = function() {
var numFirst = 982001; // gifbin's first ID (arbitrary?)
var numRange = 4721; // as of 26/05/12, supposedly increments 1 per day
var gifId = Math.floor(Math.random() * numRange) + numFirst;
$.ajax({
url: 'http://www.gifbin.com/f/' + gifId,
type: 'GET',
dataType: 'text',
crossDomain: 'true',
xhrFields: {
withCredentials: true
},
success: function(data) {
var matches = data.responseText.match(/^.+<img.+?src="(.+?)".+$/m);
if (matches.length > 1) {
var img = matches[1];
if (img.substr(img.lastIndexOf(".") + 1) == 'gif') {
$('.gifLoader').html('<img src="' + img + '" />');
window.setTimeout('window.deploy_gifbin()', 30000);
} else {
window.setTimeout('window.load_gifbin()', 2000);
}
} else {
window.setTimeout('window.load_gifbin()', 2000);
}
}
});
};
window.deploy_gifbin = function() {
$('.gifLoader').removeClass('gifLoader').addClass('gifWait');
$('.gif').hide().removeClass('gif').addClass('gifLoader').show();
$('.gifWait').removeClass('gifWait').addClass('gif');
window.load_gifbin();
}
window.deploy_random_gif = function(urls) {
console.log('deploy_random_gif');
var url = urls[Math.floor(Math.random() * urls.length)];
$('.gifLoader').removeClass('gifLoader').addClass('gifWait');
$('.gif').hide().removeClass('gif').addClass('gifLoader').show();
$('.gifWait').removeClass('gifWait').addClass('gif');
$('.gifLoader').html('<img src="' + url + '" />');
}
var source = ('source' in url_params) ? url_params.source : 'gifbin';
switch (source) {
case 'beesandbombs':
window.load_bees_bombs();
break;
case 'gifbin':
default:
window.load_gifbin();
}
var height = Math.round($('.gif').height() / 4);
$('.gif').css({ fontSize: height + 'px' });
});
</script>
<style>
body {
margin: 0; padding: 0;
font: bold 20vh/1 Consolas, Monaco, 'Courier New', monospace;
}
.gif, .gif img {
position: absolute;
height: 100%; width: 100%;
z-index: 1;
}
.gifLoader {
position: absolute; left: 10px; bottom: 10px;
z-index: 2;
background: rgba(0, 0, 0, 0.5);
}
.gifLoader img {
height: 50px; width: 50px;
border: 2px solid rgba(0, 0, 0, 0.5);
}
</style>
</head>
<body>
<div id="gif1" class="gif"><div style="padding: 0.2em; background: #fab;">WAIT FOR GIF</div></div>
<div id="gif2" class="gifLoader"></div>
</body>
</html>