forked from Lexxus/jq-timeTo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
170 lines (132 loc) · 3.87 KB
/
example.html
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>«TimeTo» jQuery plug-in example</title>
<!--[if lt IE 9]>
<script>
document.createElement('figure');
document.createElement('figcaption');
</script>
<![endif]-->
<link href="timeTo.css" type="text/css" rel="stylesheet"/>
<style>
pre {
margin-bottom: 10px;
padding-left: 10px;
border-left: 3px #DDD solid;
}
</style>
</head>
<body>
<h1>«TimeTo» jQuery plugin demo</h1>
<h2>Countdown timer</h2>
<h3>Set delay in seconds</h3>
<pre>
$('#countdown').timeTo(120, function(){ alert('Countdown finished'); }); </pre>
<div id="countdown-1"></div>
<p><button id="reset-1" type="button">Reset</button></p>
<div class="clock"></div>
<div class="clock"></div>
<h3>Hide hours</h3>
<pre>
$('#countdown').timeTo({
seconds: 100,
displayHours: false
}); </pre>
<div id="countdown-11"></div>
<h3>Set delay to specified datetime</h3>
<pre>
$('#countdown').timeTo(new Date('<span id="date-str"></span>')); </pre>
<div id="countdown-2"></div>
<h3>Set captions and dark theme</h3>
<pre>
$('#countdown').timeTo({
timeTo: new Date(new Date('<span id="date2-str"></span>')),
displayDays: 2,
theme: "black",
displayCaptions: true,
fontSize: 48,
captionSize: 14
}); </pre>
<div id="countdown-3"></div>
<p> </p>
<h2>Digital clock</h2>
<pre>
$('#clock-1').timeTo();</pre>
<div id="clock-1"></div>
<p> </p>
<h2>Digital clock with Step Setting and Step Callback</h2>
<pre>
$('#clock-w-step-cb').timeTo(
{
step: function() {
console.log('Executing every 3 ticks');
},
stepCount: 3
}
);
</pre>
<div id="clock-w-step-cb"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="node_modules/jquery/dist/jquery.min.js"><\/script>')</script>
<script src="jquery.time-to.js"></script>
<script>
/**
* Set timer countdown in seconds with callback
*/
$('#countdown-1').timeTo(120, function(){
alert('Countdown finished');
});
$('#reset-1').click(function() {
$('#countdown-1').timeTo('reset');
});
/**
* Hide hours
*/
$('#countdown-11').timeTo({
seconds: 100,
displayHours: false
});
$('#clock-w-step-cb').timeTo(
{
step: function() {
console.log('Executing every 3 ticks');
},
stepCount: 3
}
);
var date = getRelativeDate(20);
document.getElementById('date-str').innerHTML = date.toString();
/**
* Set timer countdown to specyfied date
*/
$('#countdown-2').timeTo(date);
date = getRelativeDate(7, 9);
document.getElementById('date2-str').innerHTML = date.toString();
/**
* Set theme and captions
*/
$('#countdown-3').timeTo({
time: new Date('2017-07-30T23:59:45'),
countdown: false,
displayDays: 2,
theme: "black",
displayCaptions: true,
fontSize: 48,
captionSize: 14
});
/**
* Simple digital clock
*/
$('#clock-1').timeTo();
function getRelativeDate(days, hours, minutes){
var date = new Date((new Date()).getTime() + 60000 /* milisec */ * 60 /* minutes */ * 24 /* hours */ * days /* days */);
date.setHours(hours || 0);
date.setMinutes(minutes || 0);
date.setSeconds(0);
return date;
}
</script>
</body>
</html>