This is especially usef " /> 国产乱对白精彩在线播放,与子敌伦刺激对白亂輪亂性,久久爽狠狠添AV激情五月

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

Prototype PeriodicalExecuter對象 學習

This is a simple facility for periodical execution of a function. This essentially encapsulates the native clearInterval/setInterval mechanism found in native Window objects.

This is especially useful if you use one to interact with the user at given intervals (e.g. use a prompt or confirm call): this will avoid multiple message boxes all waiting to be actioned.


這個對象就是可以周期性的執(zhí)行某個方法,但是在它內部維持了一個狀態(tài),可以防止由于某些原因一次調用沒執(zhí)行,然后下一次調用又來了,這樣會造成連續(xù)執(zhí)行兩次方法。上面的第二斷英文就是這個意思。

幫助文檔上說這個對象只提供了一個方法stop,但是在我看的源碼里還提供了一個事件onTimerEvent,應該可以在某個時候觸發(fā)這個事件。但幫助文檔上沒有給出示例。

這個對象源碼比較簡單,這里直接貼出來了,就不再注釋了:
復制代碼 代碼如下:
var PeriodicalExecuter = Class.create({
initialize: function(callback, frequency) {
this.callback = callback;
this.frequency = frequency;
this.currentlyExecuting = false;

this.registerCallback();
},

registerCallback: function() {
this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
},

execute: function() {
this.callback(this);
},

stop: function() {
if (!this.timer) return;
clearInterval(this.timer);
this.timer = null;
},

onTimerEvent: function() {
if (!this.currentlyExecuting) {
try {
this.currentlyExecuting = true;
this.execute();
} catch(e) {
/* empty catch for clients that don't support try/finally */
}
finally {
this.currentlyExecuting = false;
}
}
}
});

看一下示例:
復制代碼 代碼如下:
new PeriodicalExecuter(function(pe) {
if (!confirm('Want me to annoy you again later?'))
pe.stop(); },
5);
// Note that there won't be a stack of such messages if the user takes too long
// answering to the question...

JavaScript技術Prototype PeriodicalExecuter對象 學習,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 日本高清免费在线观看 | 无码任你躁久久久久久老妇双奶 | 久久这里只有精品视频9 | 色欲AV亚洲情无码AV蜜桃 | 国产在线aaa片一区二区99 | 国产成人精品综合久久久 | 美女也烦恼主题曲 | 国模大胆一区二区三区 | 女性私密五月天 | 国内精品伊人久久久久 | 国产色婷婷亚洲99精品 | 99久久99久久久精品久久 | 女的把腿张开男的往里面插 | 久久机热免费视频 | 软糯白嫩双性受h | 8x华人免费视频 | 午夜国产精品视频在线 | 国产亚洲精品黑人粗大精选 | 高h 纯肉文 | 久久久久久久网站 | 秋霞电影院兔费理论观频84mb | 国产51麻豆二区精品AV视频 | 国产原创剧情麻豆在线 | 无套内谢大学生A片 | 老熟人老女人国产老太 | 国产色青青视频在线观看 | 91久久综合精品国产丝袜长腿 | 广西美女色炮150p图 | 成人免费观看在线视频 | 粉嫩AV国产一区二区福利姬 | 入禽太深在线观看免费高清 | 蜜芽资源高清在线观看 | 国产亚洲精品久久久久久久 | 中文字幕无码一区二区免费 | 人妻久久久精品99系列AV | 野花影院手机在线观看 | 老师的玉足高跟鞋满足我 | 伦理片 a在线线版韩国 | 全黄h全肉细节文在线观看 全黄H全肉细节文短篇 | 又黄又爽又无遮挡在线观看免费 | 正在播放国产尾随丝袜美女 |