1 /*----------------------------------------------------------------------------\
\r
3 |-----------------------------------------------------------------------------|
\r
4 | Created by Erik Arvidsson |
\r
5 | (http://webfx.eae.net/contact.html#erik) |
\r
6 | For WebFX (http://webfx.eae.net/) |
\r
7 |-----------------------------------------------------------------------------|
\r
8 | Object Oriented Encapsulation of setTimeout fires ontimer when the timer |
\r
9 | is triggered. Does not work in IE 5.00 |
\r
10 |-----------------------------------------------------------------------------|
\r
11 | Copyright (c) 2002, 2006 Erik Arvidsson |
\r
12 |-----------------------------------------------------------------------------|
\r
13 | Licensed under the Apache License, Version 2.0 (the "License"); you may not |
\r
14 | use this file except in compliance with the License. You may obtain a copy |
\r
15 | of the License at http://www.apache.org/licenses/LICENSE-2.0 |
\r
16 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
\r
17 | Unless required by applicable law or agreed to in writing, software |
\r
18 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
\r
19 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
\r
20 | License for the specific language governing permissions and limitations |
\r
21 | under the License. |
\r
22 |-----------------------------------------------------------------------------|
\r
23 | 2002-10-14 | Original version released |
\r
24 | 2006-05-28 | Changed license to Apache Software License 2.0. |
\r
25 |-----------------------------------------------------------------------------|
\r
26 | Created 2002-10-14 | All changes are in the log above. | Updated 2006-05-28 |
\r
27 \----------------------------------------------------------------------------*/
\r
29 function Timer(nPauseTime) {
\r
30 this._pauseTime = typeof nPauseTime == "undefined" ? 1000 : nPauseTime;
\r
32 this._isStarted = false;
\r
35 Timer.prototype.start = function () {
\r
36 if (this.isStarted())
\r
39 this._timer = window.setTimeout(function () {
\r
40 if (typeof oThis.ontimer == "function")
\r
42 }, this._pauseTime);
\r
43 this._isStarted = false;
\r
46 Timer.prototype.stop = function () {
\r
47 if (this._timer != null)
\r
48 window.clearTimeout(this._timer);
\r
49 this._isStarted = false;
\r
52 Timer.prototype.isStarted = function () {
\r
53 return this._isStarted;
\r
56 Timer.prototype.getPauseTime = function () {
\r
57 return this._pauseTime;
\r
60 Timer.prototype.setPauseTime = function (nPauseTime) {
\r
61 this._pauseTime = nPauseTime;
\r