forked from vogievetsky/KoalasToTheMax
/
index.html
269 lines (240 loc) · 9.47 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8">
<meta name="description" content="Koalas to the Max, a site made with love by Vadim Ogievetsky for Annie Albagli">
<meta name="keywords" content="Koalas Max Vadim Ogievetsky Annie Albagli D3 Canvas SVG Koala Maximization">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="google" content="notranslate">
<title>Koalas to the Max dot Com</title>
<script type="text/javascript" src="polyfill/polyfill.js?1.6.1"></script>
<!--[if gte IE 9]><!-->
<script type="text/javascript" src="d3.v2.min.js?1.6.1"></script>
<script type="text/javascript" src="d3.mouse.patch.js?1.6.1"></script>
<script type="text/javascript" src="koala.js?1.6.1"></script>
<!--<![endif]-->
<link rel="stylesheet" type="text/css" href="koala.css?1.6.1"/>
</head>
<body>
<div id="center">
<div id="cont">
<noscript>
Your browser does not support JavaScript or it is disabled.<br>
JavaScript is needed to view this site.
</noscript>
<div id="dots">
</div>
<div id="next" style="display: none">
<div class="msg">
Awesome stuff! Now make your own and share the link.<br/>
Paste an image URL bellow and click enter.
</div>
<input placeholder="http://imgur.com/your_favourite_image.jpg"/>
</div>
</div>
</div>
<div id="footer">
Made with love by
<a href="http://vadim.ogievetsky.com">Vadim Ogievetsky</a>
for
<a href="http://anniealbagli.com">Annie Albagli</a>
/
Powered by
<a href="http://mbostock.github.com/d3">D3</a>
</div>
<script type="text/javascript">
// FlexTrack
(function() {
try {
var num = 0;
var initTime = +new Date();
window.flextrack = function(a) {
if (Object.prototype.toString.call(a) != '[object Object]') return false;
a.N_ = num++;
a.P_ = document.location.pathname;
a.S_ = +new Date() - initTime;
a.R_ = document.referrer || 'Direct';
var params = [];
for (var k in a) params.push(encodeURIComponent(k) + "=" + encodeURIComponent(String(a[k])));
var i = new Image();
i.src = 'http://tracking.metamx.com/m.gif?' + params.join('&');
return true;
};
} catch (e) {}
})();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17409200-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">
window.shownFile = 'none';
(function() {
var now = +new Date();
window.gaTrack = function(type, subtype) {
var time = Math.round((+new Date() - now) / 1000);
function doTrack() {
if (!window._gaq) return;
_gaq.push(['_trackEvent', String(type), String(subtype), window.location.href, time]);
}
if (window._gaq) {
doTrack()
} else {
setTimeout(doTrack, 1);
}
}
})();
function track(type, subtype) {
flextrack({
Type: type,
SybType: subtype,
File: shownFile
});
gaTrack(type, subtype);
}
</script>
<!--[if lt IE 9]>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
<style>
.chromeFrameInstallDefaultStyle {
width: 800px;
height: 600px;
border: 1px solid #cccccc;
}
</style>
<div id="prompt">
</div>
<script>
window.inOldIE = true;
track('OldIE', '1');
// The conditional ensures that this code will only execute in IE,
// Therefore we can use the IE-specific attachEvent without worry
window.attachEvent("onload", function() {
CFInstall.check({
mode: "inline", // the default
node: "prompt",
oninstall: function() {
track('InstalledGCF', 'OneLessRawIE');
}
});
});
</script>
<![endif]-->
<!--[if gte IE 9]><!-->
<script type="text/javascript">
// Code left intentionally unminimized for your reading pleasure.
(function() {
window.shownFile = 'none';
var version = '1.6.1';
// If an error happens I want to know about it!
window.onerror = function(msg, url, ln) {
msg = msg.toString();
// In Chrome and Firefox an error on a script form a foreign domain will cause this, see link bellow:
// http://stackoverflow.com/questions/5913978/cryptic-script-error-reported-in-javascript-in-chrome-and-firefox
if (msg === 'Script error.' && url === '' && ln === 0) return;
track('OnError-' + version, "'" + msg + "' in '" + url + "' @ " + ln + " /u:'" + window.navigator.userAgent + "'");
window.onerror = function() {};
};
if (!koala.supportsCanvas()) {
track('NoCanvas', window.navigator.userAgent);
alert("Sorry, KoalsToTheMax needs HTML5 Canvas support which your browser does not have. Supported browsers include Chrome, Safari, Firefox, Opera, and Internet Explorer 9, 10");
return;
}
if (!koala.supportsSVG()) {
track('NoSVG', window.navigator.userAgent);
alert("Sorry, KoalsToTheMax needs SVG support which your browser does not have. Supported browsers include Chrome, Safari, Firefox, Opera, and Internet Explorer 9, 10");
return;
}
if (!window.d3) {
track('NoD3', window.navigator.userAgent);
alert("Some how D3 was not loaded so the site can not start. This is bad... We are investigating. Try refreshing the page and see if that helps.");
return;
}
try {
function utf8_to_b64(str) {
return window.btoa(unescape(encodeURIComponent(str)));
}
function b64_to_utf8(str) {
return decodeURIComponent(escape(window.atob(str)));
}
var hrefSplit = window.location.href.split("?", 2);
var domian = hrefSplit[0];
var file = hrefSplit[1];
if (file) {
if (file.match(/^[a-z0-9+\/=]+$/i)) {
file = b64_to_utf8(file);
} else {
// Hide the link in the url
window.location.href = domian + '?' + utf8_to_b64(file);
}
shownFile = 'CUSTOM';
} else {
var possible = ['dog', 'kitten', 'koalas', 'lion', 'otter', 'owls', 'pandas'];
shownFile = possible[Math.floor(Math.random() * possible.length)];
file = 'img/' + shownFile + '.jpg';
}
if (file.match(/^http:/)) {
file = "image-server.php?url=" + file;
}
function onEvent(what, value) {
track(what, value);
if (what === 'LayerClear' && value == 0) {
d3.select('#next')
.style('display', null)
.select('input')
.on('keydown', function() {
d3.select('div.err').remove();
if (d3.event.keyCode !== 13) return;
var input = d3.select(this).property('value');
if (input.match(/^http:\/\/.+\..+/i)) {
track('Submit', input);
d3.select('#next div.msg').text('Thinking...');
d3.select(this).style('display', 'none');
setTimeout(function() {
window.location.href = domian + '?' + utf8_to_b64(input);
}, 750);
} else {
d3.select('#next').selectAll('div.err').data([0])
.enter().append('div')
.attr('class', "err")
.text("That doesn't appear to be a valid image URL. [Hint: it should start with 'http://']")
}
});
}
}
var img = new Image();
img.onload = function() {
var colorData;
try {
colorData = koala.loadImage(this);
} catch (e) {
colorData = null;
track('BadLoad-' + version, "Msg: '" + e.message + "' file: '" + file + "'");
alert("Sorry, KoalsToTheMax could not load the image '" + file + "'");
setTimeout(function() {
window.location.href = domian;
}, 750);
}
if (colorData) {
koala.makeCircles(colorData, onEvent);
track('GoodLoad-' + version, 'Yay');
}
};
img.src = file;
} catch (e) {
track('Problemo', String(e.message));
}
})();
</script>
<!--<![endif]-->
</body>
</html>