@@ -15,16 +15,39 @@ <h1>jQuery Timer Demo</h1>
1515 < p > Project home: < a href ="http://jchavannes.com/jquery-timer " target ="_blank "> http://jchavannes.com/jquery-timer</ a > </ p >
1616 < p > < a href ="res/demo.js " target ="_blank "> View Source</ a > </ p >
1717
18- < hr /> < h3 style ='margin-top:20px; '> Example 1 - Stopwatch</ h3 >
18+ < br />
19+
20+ < h2 > Usage</ h2 >
21+
22+ < hr />
23+
24+ < h3 > Stopwatch</ h3 >
25+
26+ < h4 > Create a new stopwatch</ h4 >
27+ < p > HTML</ p >
28+ < pre > <div id='time'>%lt;/div></ pre >
29+ < p > Javascript</ p >
30+ < pre >
31+ var stopwatch = $.stopwatch(function(watch) {
32+ $('#time').html(watch.getFormattedTime();
33+ });</ pre >
34+
35+ < br />
36+
37+ < h2 > Examples</ h2 >
38+
39+ < hr />
40+
41+ < h3 style ='margin-top:20px; '> Example 1 - Stopwatch</ h3 >
1942 < p >
2043 < span id ="stopwatch "> 00:00:00</ span > < br />
2144 < input type ='button ' value ='Example1.toggle() ' onclick ='Example1.toggle() ' />
2245 < input type ='button ' value ='Example1.stop() ' onclick ='Example1.stop() ' />
2346 </ p >
24- < pre style =' padding:10px 15px; ' >
25- var Example1 = $.stopWatch (function () {
26- var output = this.getFormattedTime() + " - <i> (" + this.getTime() + " milliseconds)</i> ";
27- $(' #stopwatch' ).html(output);
47+ < pre >
48+ var Example1 = $.stopwatch (function () {
49+ var output = this.getFormattedTime() + " - < i > (" + this.getTime() + " milliseconds)</ i > ";
50+ $(" #stopwatch" ).html(output);
2851});</ pre >
2952 < br />
3053
@@ -34,16 +57,42 @@ <h3>Example 2 - Countdown</h3>
3457 < input type ='button ' value ='Example2.toggle() ' onclick ='Example2.toggle() ' />
3558 < input type ='button ' value ='Example2.stop() ' onclick ='Example2.stop() ' />
3659 </ form >
37- < pre style =' padding:10px 15px; ' >
38- var Example2 = $.countDown (function() {
39- $(' #countdown' ).html(this.getFormattedTime());
60+ < pre >
61+ var Example2 = $.countdown (function() {
62+ $(" #countdown" ).html(this.getFormattedTime());
4063 if (this.isFinished()) {
41- alert(' Example 2: Countdown complete!' );
64+ alert(" Example 2: Countdown complete!" );
4265 }
4366}, 20);</ pre >
4467 < br />
4568
46- < h3 > Example 3 - Slideshow (preserves time remaining when paused)</ h3 >
69+
70+ < h3 > Example 3 - The original jQuery Timer (basically a suped-up version of setTimeout)</ h3 >
71+ < p > timer has been executed < span id ='counter ' style =''> 0</ span > times.</ p >
72+ < div class ='example-four '>
73+ < input type ='button ' value ='timer.play() ' onclick ='timer.play(); ' /> < br />
74+ < input type ='button ' value ='timer.play(true) ' onclick ='timer.play(true); ' /> < br />
75+ < input type ='button ' value ='timer.pause() ' onclick ='timer.pause(); ' /> < br />
76+ < input type ='button ' value ='timer.toggle() ' onclick ='timer.toggle(); ' /> < br />
77+ < input type ='button ' value ='timer.toggle(true) ' onclick ='timer.toggle(true); ' /> < br />
78+ < input type ='button ' value ='timer.stop() ' onclick ='timer.stop(); ' />
79+ </ div >
80+ < div class ='example-four '>
81+ < input type ='button ' value ='timer.reset() ' onclick ='timer.reset(); ' /> < br />
82+ < input type ='button ' value ='timer.once() ' onclick ='timer.once(); ' /> < br />
83+ < input type ='button ' value ='timer.once(5000) ' onclick ='timer.once(5000); ' /> < br />
84+ < input type ='button ' value ='timer.set({time:1000}) ' onclick ='timer.set({time:1000}); ' /> < br />
85+ < input type ='button ' value ='timer.set({time:5000}) ' onclick ='timer.set({time:5000}); ' />
86+ </ div >
87+ < br /> < pre >
88+ var count = 0;
89+ var timer = $.timer(function() {
90+ $('#counter').html(++count);
91+ });
92+ timer.set({ time : 1000, autostart : true });</ pre >
93+
94+
95+ < h3 > Example 4 - Slideshow (preserves time remaining when paused)</ h3 >
4796 < div class ="galleryImages ">
4897 < img src ='res/img/1.jpg ' alt ='' />
4998 < img src ='res/img/2.jpg ' alt ='' />
@@ -65,31 +114,9 @@ <h3>Example 3 - Slideshow (preserves time remaining when paused)</h3>
65114 </ div >
66115 < p class ="example-three ">
67116 < span id ="timeRemaining "> < br /> </ span >
68- < input type ='button ' value ='Play / Pause ' onclick ='Example3 .toggleGallery(); ' />
117+ < input type ='button ' value ='Play / Pause ' onclick ='Example4 .toggleGallery(); ' />
69118 </ p >
70119
71- < h3 > Example 4 - The Basics (just a suped-up version of setTimeout)</ h3 >
72- < p > timer has been executed < span id ='counter ' style =''> 0</ span > times.</ p >
73- < div class ='example-four '>
74- < input type ='button ' value ='timer.play() ' onclick ='timer.play(); ' /> < br />
75- < input type ='button ' value ='timer.play(true) ' onclick ='timer.play(true); ' /> < br />
76- < input type ='button ' value ='timer.pause() ' onclick ='timer.pause(); ' /> < br />
77- < input type ='button ' value ='timer.toggle() ' onclick ='timer.toggle(); ' /> < br />
78- < input type ='button ' value ='timer.toggle(true) ' onclick ='timer.toggle(true); ' /> < br />
79- < input type ='button ' value ='timer.stop() ' onclick ='timer.stop(); ' />
80- </ div >
81- < div class ='example-four '>
82- < input type ='button ' value ='timer.reset() ' onclick ='timer.reset(); ' /> < br />
83- < input type ='button ' value ='timer.once() ' onclick ='timer.once(); ' /> < br />
84- < input type ='button ' value ='timer.once(5000) ' onclick ='timer.once(5000); ' /> < br />
85- < input type ='button ' value ='timer.set({time:1000}) ' onclick ='timer.set({time:1000}); ' /> < br />
86- < input type ='button ' value ='timer.set({time:5000}) ' onclick ='timer.set({time:5000}); ' />
87- </ div >
88- < br /> < pre style ='margin-bottom:20px; padding:10px 15px; '>
89- var count = 0;
90- var timer = $.timer(function() {
91- $('#counter').html(++count);
92- });
93- timer.set({ time : 1000, autostart : true });</ pre >
120+
94121</ body >
95122</ html >
0 commit comments