-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
53 lines (43 loc) · 1.39 KB
/
index.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
$(function () {
var clicks = 0, mSecs = 0, interval;
$('.click-adidas').click(function () {
if (mSecs < 1000) {
clicks += 1;
$('.share').hide();
}
var randomColorChange = '#' + (Math.random() * 0xFFFFFF << 0).toString(16);
$('.click-adidas').css('background-color', randomColorChange);
});
function clickChecker() {
if (clicks != 0) {
if (mSecs < 1000) {
mSecs += 1;
} else {
mSecs = 1000;
clearInterval(interval);
}
}
updateHtml();
}
function updateHtml() {
if (clicks != 0) {
$('span.time').html((mSecs / 100).toFixed(1) + 'S');
$('span.clicks').html(clicks + ' clicks');
}
if (mSecs == 1000) {
$('.under').show();
$('.click-adidas').addClass('red');
$('.share').show();
}
}
function tweet() {
var tweetText = "I just tapped " + clicks + "x in " + (mSecs / 100) + "s on @yzyio Adidas Confirmed Simulator. Link: " + window.location.href;
var twitterTweetUrl = "https://twitter.com/intent/tweet?text=";
var url = twitterTweetUrl + encodeURI(tweetText);
window.open(url);
}
$('span.share a ').click(function () {
tweet();
});
interval = setInterval(clickChecker, 1);
});