📄 timer.js
字号:
/* timer.js{{IS_NOTE Purpose: Timer Description: History: Mon Sep 26 14:04:22 2005, Created by tomyeh}}IS_NOTECopyright (C) 2005 Potix Corporation. All Rights Reserved.{{IS_RIGHT This program is distributed under GPL Version 2.0 in the hope that it will be useful, but WITHOUT ANY WARRANTY.}}IS_RIGHT*///Timer//zkTimer = {};zk.Timer = Class.create();zk.Timer.prototype = { initialize: function (comp) { this.id = comp.id; zkau.setMeta(comp, this); this.init(); }, /** Recognized by zkau.js when 'obsolte' or other severe fatal * error is found. It clears any timeout and interval to avoid * annoying users. */// cleanupOnFatal: function (ignorable) {// this.cleanup();// },//Tom M. Yeh: 5/21/2007//Don't cleanup since it may take a while to failover to another server//Rather, we turn off the error message (by specifying ignorable) init: function () { var el = $e(this.id); if (!el) return; this.cleanup(); //stop pending timer/interval var repeats = getZKAttr(el, "repeats") == "true"; var delay = getZKAttr(el, "delay"); var func = "zkTimer._fire('"+this.id+"')"; if (repeats) this.interval = setInterval(func, delay); else this.timeout = setTimeout(func, delay); }, cleanup: function () { if (this.timeout) { clearTimeout(this.timeout); this.timeout = null; } if (this.interval) { clearInterval(this.interval); this.interval = null; } }};/** Init (and re-init) a timer. */zkTimer.init = function (cmp) { if (getZKAttr(cmp, "running") != "false") { var meta = zkau.getMeta(cmp); if (meta) meta.init(); else new zk.Timer(cmp); }};zkTimer.setAttr = function (cmp, nm, val) { if (nm == "z.running") { zkau.setAttr(cmp, nm, val); if (val == "true") zkTimer.init(cmp); else { var meta = zkau.getMeta(cmp); if (meta) meta.cleanup(); } return true; } return false;};/** Fires an onTimer event. */zkTimer._fire = function (uuid) { zkau.send({uuid: uuid, cmd: "onTimer", data: null, ignorable: true}, 0);};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -