/[colormatch]/trunk/timer.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/timer.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Sat Oct 2 23:24:01 2004 UTC (19 years, 8 months ago) by dpavlin
File MIME type: application/javascript
File size: 4232 byte(s)
imported original ColorMatch

1 dpavlin 1 /*----------------------------------------------------------------------------\
2     | Timer Class |
3     |-----------------------------------------------------------------------------|
4     | Created by Erik Arvidsson |
5     | (http://webfx.eae.net/contact.html#erik) |
6     | For WebFX (http://webfx.eae.net/) |
7     |-----------------------------------------------------------------------------|
8     | Object Oriented Encapsulation of setTimeout fires ontimer when the timer |
9     | is triggered. Does not work in IE5.00 |
10     |-----------------------------------------------------------------------------|
11     | Copyright (c) 1999 - 2002 Erik Arvidsson |
12     |-----------------------------------------------------------------------------|
13     | This software is provided "as is", without warranty of any kind, express or |
14     | implied, including but not limited to the warranties of merchantability, |
15     | fitness for a particular purpose and noninfringement. In no event shall the |
16     | authors or copyright holders be liable for any claim, damages or other |
17     | liability, whether in an action of contract, tort or otherwise, arising |
18     | from, out of or in connection with the software or the use or other |
19     | dealings in the software. |
20     | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
21     | This software is available under the three different licenses mentioned |
22     | below. To use this software you must chose, and qualify, for one of those. |
23     | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
24     | The WebFX Non-Commercial License http://webfx.eae.net/license.html |
25     | Permits anyone the right to use the software in a non-commercial context |
26     | free of charge. |
27     | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
28     | The WebFX Commercial license http://webfx.eae.net/commercial.html |
29     | Permits the license holder the right to use the software in a commercial |
30     | context. Such license must be specifically obtained, however it's valid for |
31     | any number of implementations of the licensed software. |
32     | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
33     | GPL - The GNU General Public License http://www.gnu.org/licenses/gpl.txt |
34     | Permits anyone the right to use and modify the software without limitations |
35     | as long as proper credits are given and the original and modified source |
36     | code are included. Requires that the final product, software derivate from |
37     | the original source or any software utilizing a GPL component, such as |
38     | this, is also licensed under the GPL license. |
39     |-----------------------------------------------------------------------------|
40     | 2002-10-14 | Original version released |
41     |-----------------------------------------------------------------------------|
42     | Created 2002-10-14 | All changes are in the log above. | Updated 2002-10-14 |
43     \----------------------------------------------------------------------------*/
44    
45     function Timer(nPauseTime) {
46     this._pauseTime = typeof nPauseTime == "undefined" ? 1000 : nPauseTime;
47     this._timer = null;
48     this._isStarted = false;
49     }
50    
51     Timer.prototype.start = function () {
52     if (this.isStarted())
53     this.stop();
54     var oThis = this;
55     this._timer = window.setTimeout(function () {
56     if (typeof oThis.ontimer == "function")
57     oThis.ontimer();
58     }, this._pauseTime);
59     this._isStarted = false;
60     };
61    
62     Timer.prototype.stop = function () {
63     if (this._timer != null)
64     window.clearTimeout(this._timer);
65     this._isStarted = false;
66     };
67    
68     Timer.prototype.isStarted = function () {
69     return this._isStarted;
70     };
71    
72     Timer.prototype.getPauseTime = function () {
73     return this._pauseTime;
74     };
75    
76     Timer.prototype.setPauseTime = function (nPauseTime) {
77     this._pauseTime = nPauseTime;
78     };

  ViewVC Help
Powered by ViewVC 1.1.26