summaryrefslogtreecommitdiffstats
path: root/slider/js/timer.js
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2007-07-22 10:09:14 +0000
committerAndreas Unterkircher <unki@netshadow.at>2007-07-22 10:09:14 +0000
commitd989420a0c316a8c1f9a643418669496f807094b (patch)
tree80a484fa29156959d2c794311ef268654725ccf2 /slider/js/timer.js
parentfd60c69466028220a85533ba9e1abededfaf1e95 (diff)
issue46, added a javascript-based slider to modify slide-interval
git-svn-id: file:///var/lib/svn/phpfspot/trunk@242 fa6a889d-dae6-447d-9e79-4ba9a3039384
Diffstat (limited to 'slider/js/timer.js')
-rw-r--r--slider/js/timer.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/slider/js/timer.js b/slider/js/timer.js
new file mode 100644
index 0000000..e96fe19
--- /dev/null
+++ b/slider/js/timer.js
@@ -0,0 +1,62 @@
+/*----------------------------------------------------------------------------\
+| Timer Class |
+|-----------------------------------------------------------------------------|
+| Created by Erik Arvidsson |
+| (http://webfx.eae.net/contact.html#erik) |
+| For WebFX (http://webfx.eae.net/) |
+|-----------------------------------------------------------------------------|
+| Object Oriented Encapsulation of setTimeout fires ontimer when the timer |
+| is triggered. Does not work in IE 5.00 |
+|-----------------------------------------------------------------------------|
+| Copyright (c) 2002, 2006 Erik Arvidsson |
+|-----------------------------------------------------------------------------|
+| Licensed under the Apache License, Version 2.0 (the "License"); you may not |
+| use this file except in compliance with the License. You may obtain a copy |
+| of the License at http://www.apache.org/licenses/LICENSE-2.0 |
+| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
+| Unless required by applicable law or agreed to in writing, software |
+| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
+| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
+| License for the specific language governing permissions and limitations |
+| under the License. |
+|-----------------------------------------------------------------------------|
+| 2002-10-14 | Original version released |
+| 2006-05-28 | Changed license to Apache Software License 2.0. |
+|-----------------------------------------------------------------------------|
+| Created 2002-10-14 | All changes are in the log above. | Updated 2006-05-28 |
+\----------------------------------------------------------------------------*/
+
+function Timer(nPauseTime) {
+ this._pauseTime = typeof nPauseTime == "undefined" ? 1000 : nPauseTime;
+ this._timer = null;
+ this._isStarted = false;
+}
+
+Timer.prototype.start = function () {
+ if (this.isStarted())
+ this.stop();
+ var oThis = this;
+ this._timer = window.setTimeout(function () {
+ if (typeof oThis.ontimer == "function")
+ oThis.ontimer();
+ }, this._pauseTime);
+ this._isStarted = false;
+};
+
+Timer.prototype.stop = function () {
+ if (this._timer != null)
+ window.clearTimeout(this._timer);
+ this._isStarted = false;
+};
+
+Timer.prototype.isStarted = function () {
+ return this._isStarted;
+};
+
+Timer.prototype.getPauseTime = function () {
+ return this._pauseTime;
+};
+
+Timer.prototype.setPauseTime = function (nPauseTime) {
+ this._pauseTime = nPauseTime;
+}; \ No newline at end of file