View difference between Paste ID: VeT6AZWx and ecpxgHtN
SHOW: | | - or go back to the newest paste.
1
/*
2
//	PD3 Faucet Timer
3
//	Created by Serlite
4
//
5
//	(Hide using Ctrl + Alt + Z)
6
*/
7
8
var sinceLastClaim = 0;
9
var $fTimer = null;
10
var $fTimerWrapper = null;
11-
var $fTimerAuto = null;
11+
12
var fTimerHider = {17: false, 18: false, 90:false};
13
14-
var fAutoOpened = false;
14+
initializeTimer();
15-
var fClaimThresh = 180;
15+
16
// Creates GUI and begins timer countdown
17-
if (!window.jQuery.ui){
17+
18-
	$("body").append("<script src='//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.js'></script>");
18+
19
	if (!window.jQuery.ui){
20-
// Delay to allow jQuery UI to load
20+
		$("body").append("<script src='//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.js'></script>");
21-
setTimeout(initializeTimer, 500);
21+
22
23
	// Delay to allow jQuery UI to load
24
	setTimeout(function(){
25
		$("body").append("<div class='faucet-timer' style='background:#FFF; border:2px solid #b4b9cd; position:fixed; z-index:9999; top:100px; left:200px; color:#6d738c; padding:15px; font-size:1em'><p style='margin-bottom:10px;'>Since last claim:</p><p><span class='time-counter' style='font-weight:bold;'>00:00</span></p></div>");
26-
		setTimeout(initializeTimer, 500);
26+
27
		// Caching reference
28
		$fTimer = $(".faucet-timer .time-counter");
29-
		$("body").append(
29+
30-
			"<div class='faucet-timer' style='background:#FFF; border:2px solid #b4b9cd; position:fixed; z-index:9999; top:100px; left:200px; color:#6d738c; padding:15px; font-size:1em'>"+
30+
31-
				"<p style='margin-bottom:8px;'>Since last claim:</p>"+
31+
32-
				"<p>"+
32+
33-
					"<span class='time-counter' style='font-weight:bold; width:48%; display:inline-block'>00:00</span>"+
33+
34-
					"<label style='background:rgb(191, 199, 233); padding:2px 0; width:52%; display:inline-block; text-align:center; color:rgb(109, 115, 140); font-weight:bold; box-shadow: rgba(67, 71, 91, 0.4) 0px -2px 0px 0px inset;' title='Activate automatic faucet modal opening'>"+
34+
35-
						"<input class='auto-open' style='display:none' type='checkbox' />AUTO"+
35+
36-
					"</label>"+
36+
37-
				"</p>"+
37+
38-
			"</div>"
38+
39-
		);
39+
				setTimerCol();
40
41
				// Reset interval ensure precision
42
				clearInterval(fIntervalRef);
43-
		$fTimerAuto = $(".faucet-timer .auto-open");
43+
44
			}
45
		});
46
47
		// Register key down in combo
48
		$(document).keydown(function(e){
49
			if (e.keyCode in fTimerHider){
50
				fTimerHider[e.keyCode] = true;
51
52
				// Ctrl + Alt + Z, toggle visible
53
				if (fTimerHider[17] && fTimerHider[18] && fTimerHider[90]){
54-
				checkTimerState();
54+
55-
				fAutoOpened = false;
55+
56
			}
57
		});
58
59
		// Register key up in combo
60
		$(document).keyup(function(e){
61
			if (e.keyCode in fTimerHider){
62
				fTimerHider[e.keyCode] = false;
63
			}
64
		});
65
66
	}, 800);
67
}
68
69
// Increment timer value
70
function updateFaucetTime(){
71
	sinceLastClaim++;
72
	writeFaucetTime(formattedFaucetTime());
73
	setTimerCol();
74
}
75
76
// Format time into more readable string
77
function formattedFaucetTime(){
78
	var minutes = Math.floor(sinceLastClaim/60).toString();
79
	var seconds = (sinceLastClaim%60).toString();
80
81
	// Adding leading zeroes
82-
		// Toggle automatic modal opening
82+
83-
		$fTimerAuto.on("change", toggleAutoButton);
83+
84
	}
85
	if (seconds.length == 1){
86
		seconds = "0" + seconds;
87
	}
88
89
	return (minutes + ":" + seconds);
90
}
91
92-
	checkTimerState();
92+
93
function writeFaucetTime(faucetTime){
94
	$fTimer.text(faucetTime);
95
}
96
97
// Change colour according to time
98
function setTimerCol(){
99
	if (sinceLastClaim >= 180){
100
		$fTimer.css("color","#5fb365");
101
	}
102
	else{
103
		$fTimer.css("color","#6d738c");
104
	}
105
}