forked from ExploreBTC/BitcoinGrind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
61 lines (48 loc) · 1.49 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
/**
* Here's where you store the faucets (the URLs).
*/
var faucets = [
'default.html',
'http://fieldbitcoins.com/',
'http://memebase.cheezburger.com/',
'http://geek.cheezburger.com/',
'http://icanhas.cheezburger.com/gifs',
];
var currentFaucet = 0;
function setFaucet() {
document.querySelector('.faucet-frame').src = faucets[currentFaucet];
}
/**
* Jump to button.
*/
document.querySelector(".controls-jump").addEventListener('click', function() {
currentFaucet = prompt('Enter a number to skip to that faucet:') - 1;
if (currentFaucet < 0 || currentFaucet >= faucets.length) return alert('The number has to be between 1 and ' + faucets.length + '.');
setFaucet();
});
/**
* Link button (open in new tab).
*/
document.querySelector(".controls-link").addEventListener('click', function() {
window.open(document.querySelector('.faucet-frame').src, '_blank').focus();
});
/**
* Reload button.
*/
document.querySelector(".controls-reload").addEventListener('click', setFaucet);
/**
* Previous button.
*/
document.querySelector(".controls-previous").addEventListener('click', function() {
currentFaucet--;
if (currentFaucet === -1) currentFaucet = faucets.length - 1;
setFaucet();
});
/**
* Next button.
*/
document.querySelector(".controls-next").addEventListener('click', function() {
currentFaucet++;
if (currentFaucet === faucets.length) currentFaucet = 0;
setFaucet();
});