-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
107 lines (93 loc) · 1.97 KB
/
script.js
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
var playAudio = false;
$(document).ready(function ()
{
var
html = $("html"),
body = $("body"),
main = $("#main"),
rate = 200,
despawn = 5000,
delay = 1000;
function newBonzi()
{
var
scale = "scale(" + rand(0.7, 1.6) + ")",
top = rand(-10, 100) + "%",
opacity = rand(0.1, 1),
index = rand(-30, 10),
duration = rand(1, 5) + "s",
fromLeft = dice(0, 1),
bonzi = $("<figure/>").css({
top,
opacity,
"z-index": index,
"-webkit-transform": scale,
"-moz-transform": scale,
"-o-transform": scale,
"-webkit-animation-duration": duration,
"-moz-animation-duration": duration,
"-ms-animation-duration": duration,
"background-position-x": -(200 * Math.ceil(rand(0, 16))),
"background-position-y": -(160 * Math.ceil(rand(0, 20)))
});
bonzi.addClass("bonzi");
bonzi.addClass(fromLeft ? "moveL" : "moveR");
bonzi.appendTo(main);
setTimeout(function ()
{
bonzi.remove()
}, despawn)
}
function gogogo()
{
document.title = "Bonzi!";
body.addClass("play");
$("#spinner").fadeOut(200);
setTimeout(function()
{
$("#spinner").remove();
}, 202);
setTimeout(function()
{
setInterval(function()
{
newBonzi()
}, rate)
}, delay)
}
var cfg = {
lines: 13,
length: 7,
width: 4,
radius: 10,
rotate: 0,
color: "#fff",
speed: 1,
trail: 60,
shadow: !0,
hwaccel: !1,
className: "spinner",
zIndex: 2e9,
top: "auto",
left: "auto"
};
var spin = $("<figure/>").attr({ id: "spinner" });
$("html").append(spin);
var root = document.getElementById("spinner");
new Spinner(cfg).spin(root);
gogogo();
});
function rand(min, max)
{
return Math.random() * (max - min) + min;
}
function dice(min, max)
{
return Math.floor(Math.random() * (max - min + 1)) + min;
}
$('#left').on('click', function()
{
if (!playAudio) { $('#song').trigger('play'); $('#left').html('Pause audio'); }
else { $('#song').trigger('pause'); $('#left').html('Play audio'); }
playAudio = !playAudio;
})