-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
96 lines (92 loc) · 3.38 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
<!doctype html>
<!--[if lt IE 7]><html class="lt-ie9 lt-ie8 lt-ie7" lang="en"><![endif]-->
<!--[if IE 7]><html class="lt-ie9 lt-ie8" lang="en"><![endif]-->
<!--[if IE 8]><html class="lt-ie9" lang="en"><![endif]-->
<!--[if gt IE 8]><!--><html lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="viewport" content="width=device-width">
</head>
<body>
<div id="icon"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
<script src="//github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"></script>
<script>window.Raphael || document.write('<script src="js/libs/raphael-min.js"></\script>')</script>
<script src="js/libs/raphael-svg-import.js"></script>
<script>
var blacklist = [300, 334, 351, 360, 368, 512, 642, 645, 764, 779, 780, 798, 799, 800, 899, 962, 991, 997, 1037, 1048, 1075, 1077, 1102, 1104, 1268, 1271, 1272, 1273, 1274, 1321, 1358, 1359, 1389, 1391, 1404, 1406, 1442];
var svg_cache = [];
var random_byte = function() {
return Math.floor(Math.random() * 255);
};
var random_color = function() {
var c = "rgb("+ random_byte() + ", " + random_byte() + ", " + random_byte() + ")";
console.log(c);
return c;
};
var step = function(paper) {
var i = 300;
while($.inArray(i, blacklist) > -1) {
i = Math.floor(Math.random() * 1535);
}
if(typeof svg_cache[i] !== 'undefined') {
console.log("reading svg from cache");
var svg = svg_cache[i];
var icon = paper.set();
paper.importSVG(svg, icon);
icon.attr({"opacity": 0.0, width: 100, height: 100, fill: random_color()});
icon.animate({"opacity": 1.0}, 20, function() {
icon.animate({"opacity": 0.0}, 20, function() {
try {
icon.remove();
} catch(e) {
console.log(e);
}
setTimeout(function(){step(paper);}, 1);
});
});
} else {
$.ajax({
url: "/noun/" + i,
success: function(data) {
var icon = paper.set();
try {
paper.importSVG(data, icon);
svg_cache[i] = data;
} catch(e) {
console.log(e);
blacklist.push(i);
setTimeout(function(){step(paper);}, 20);
}
icon.attr({"opacity": 0.0, width: 100, height: 100, fill: random_color()});
icon.animate({"opacity": 1.0}, 20, function() {
icon.animate({"opacity": 0.0}, 20, function() {
try {
icon.remove();
} catch(e) {
console.log(e);
}
setTimeout(function(){step(paper);}, 1);
});
});
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log(XMLHttpRequest);
console.log(textStatus);
console.log(errorThrown);
blacklist.push(i);
setTimeout(function(){step(paper);}, 1);
}
});
}
};
$(document).ready(function() {
var paper = new Raphael("icon", 400, 400);
step(paper);
});
</script>
</body>
</html>