forked from Lexxus/jq-timeTo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
129 lines (104 loc) · 3.04 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
<!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(100, function(){ alert('Countdown finished'); }); </pre>
<div id="countdown-1"></div>
<h3>Hide hours</h3>
<pre>
$('#countdown').timeTo({
seconds: 100,
displayHours: false
}); </pre>
<div id="countdown-11"></div>
<h3>Set delay to specyfied datetime</h3>
<pre>
$('#countdown').timeTo(new Date('<span id="date-str"></span>')); </pre>
<div id="countdown-2"></div>
<h3>Set captions and dark theme</h1>
<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>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="jquery-1.9.1.min.js"><\/script>')</script>
<script src="jquery.timeTo.min.js"></script>
<script>
/**
* Set timer countdown in seconds with callback
*/
$('#countdown-1').timeTo(100, function(){
alert('Countdown finished');
});
/**
* Hide hours
*/
$('#countdown-11').timeTo({
seconds: 100,
displayHours: false
});
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({
timeTo: date,
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>