3 * jQuery Timer plugin v0.1
4 * Matt Schmidt [http://www.mattptr.net]
6 * Licensed under the BSD License:
7 * http://mattptr.net/license/license.txt
11 jQuery.timer = function (interval, callback)
15 * timer() provides a cleaner way to handle intervals
18 * $.timer(interval, callback);
22 * $.timer(1000, function (timer) {
26 * @desc Show an alert box after 1 second and stop
30 * $.timer(1000, function (timer) {
32 * alert('First time!');
37 * alert('Second time');
41 * @desc Show an alert box after 1 second and show another after 3 seconds
46 var interval = interval || 100;
51 _timer = function (interval, callback) {
52 this.stop = function () {
53 clearInterval(self.id);
56 this.internalCallback = function () {
60 this.reset = function (val) {
62 clearInterval(self.id);
65 this.id = setInterval(this.internalCallback, val);
68 this.interval = interval;
69 this.id = setInterval(this.internalCallback, this.interval);
74 return new _timer(interval, callback);