PageSourceSearch

https://www.love-y.net/sp/js/jquery.timer.js

js love-y.net collected 2026-10-04 15:11:30 UTC 1,570 bytes, 74 lines download raw bytes

1/*
2*
3*	jQuery Timer plugin v0.1
4*		Matt Schmidt [http://www.mattptr.net]
5*
6*	Licensed under the BSD License:
7*		http://mattptr.net/license/license.txt
8*
9*/
10
11jQuery.timer = function(interval, callback) {
12    /**
13    *
14    * timer() provides a cleaner way to handle intervals  
15    *
16    *	@usage
17    * $.timer(interval, callback);
18    *
19    *
20    * @example
21    * $.timer(1000, function (timer) {
22    * 	alert("hello");
23    * 	timer.stop();
24    * });
25    * @desc Show an alert box after 1 second and stop
26    * 
27    * @example
28    * var second = false;
29    *	$.timer(1000, function (timer) {
30    *		if (!second) {
31    *			alert('First time!');
32    *			second = true;
33    *			timer.reset(3000);
34    *		}
35    *		else {
36    *			alert('Second time');
37    *			timer.stop();
38    *		}
39    *	});
40    * @desc Show an alert box after 1 second and show another after 3 seconds
41    *
42    * 
43    */
44
45    var interval = interval || 100;
46
47    if (!callback)
48        return false;
49
50    _timer = function(interval, callback) {
51        this.stop = function() {
52            clearInterval(self.id);
53        };
54
55        this.internalCallback = function() {
56            callback(self);
57        };
58
59        this.reset = function(val) {
60            if (self.id)
61                clearInterval(self.id);
62
63            var val = val || 100;
64            this.id = setInterval(this.internalCallback, val);
65        };
66
67        this.interval = interval;
68        this.id = setInterval(this.internalCallback, this.interval);
69
70        var self = this;
71    };
72
73    return new _timer(interval, callback);
74};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.