-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
113 lines (97 loc) · 3.14 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
108
109
110
111
112
113
jQuery(document).ready(function() {
var QRBox = $('#QRBox');
var MainBox = $('#MainBox');
var BTCQR = 'images/qqPay.jpg'; // 二维码路径
var AliPayQR = 'images/AliPay.jpg';
var WeChanQR = 'images/Wechat.jpg';
function showQR(QR) {
if (QR) {
MainBox.css('background-image','url('+QR+')');
}
$('#DonateText,#donateBox,#github').addClass('blur');
QRBox.fadeIn(300,function(argument) {
MainBox.addClass('showQR');
});
}
$('#donateBox>li').click(function(event) {
var thisID = $(this).attr('id');
if (thisID === 'BTC') {
showQR(BTCQR);
// new Clipboard('#BTCBn');
} else if (thisID === 'AliPay') {
showQR(AliPayQR);
} else if (thisID === 'WeChat') {
showQR(WeChanQR);
}
});
MainBox.click(function(event) {
MainBox.removeClass('showQR').addClass('hideQR');
setTimeout (function(a) {
QRBox.fadeOut(300,function(argument) {
MainBox.removeClass('hideQR');
});
$('#DonateText,#donateBox,#github').removeClass('blur');
},600);
});
var ball = function () {
var canvas = $("#particles");
var context = canvas.get(0).getContext("2d");
var canvasWidth = canvas.width();
var canvasHeight = canvas.height();
$(window).resize(resizeCanvas);
function resizeCanvas() {
canvas.attr("width", $(window).get(0).innerWidth);
canvas.attr("height", $(window).get(0).innerHeight);
canvasWidth = canvas.width();
canvasHeight = canvas.height();
}
resizeCanvas();
var Item = function (x, y, radius, vX , vY) {
this.x = x;
this.y = y;
this.radius = radius;
this.vX = vX;
this.vY = vY;
};
var items = new Array();
for (var i = 0; i < 30; i++) {
var x = 20 + (Math.random() * (canvasWidth -40));
var y = 20 + (Math.random() * (canvasHeight -40));
var radius = 5 + Math.random() * 4 - 2;
var vX = Math.random() * 4 - 2;
var vY = Math.random() * 4 - 2;
items.push(new Item(x, y ,radius, vX, vY));
}
function animate() {
context.clearRect(0, 0, canvasWidth, canvasHeight);
context.fillStyle = "rgb(255, 255, 255)";
var itemLength = items.length;
for (var i = 0; i < itemLength; i++) {
var tmpItem = items[i];
tmpItem.x += tmpItem.vX;
tmpItem.y += tmpItem.vY;
if (tmpItem.x - tmpItem.radius < 0) {
tmpItem.x = tmpItem.radius;
tmpItem.vX *= -1;
} else if (tmpItem.x + tmpItem.radius > canvasWidth) {
tmpItem.x = canvasWidth - tmpItem.radius;
tmpItem.vX = -1;
}
if (tmpItem.y - tmpItem.radius < 0) {
tmpItem.y = tmpItem.radius;
tmpItem.vY *= -1;
} else if (tmpItem.y + tmpItem.radius > canvasHeight) {
tmpItem.y = canvasHeight - tmpItem.radius;
tmpItem.vY = -1;
}
context.beginPath();
context.arc(tmpItem.x, tmpItem.y, tmpItem.radius, 0, Math.PI * 2, false);
context.closePath();
context.fill();
}
setTimeout(animate, 33);
}
animate();
};
ball();
});