Timer

Timers and intervals. Easy.

Functions

Util.Timer.setTimer

Definition

Name
Util.Timer.setTimer
Shorthand
u.t.setTimer
Syntax
Number = Util.Timer.setTimer( Node node, Function|String action, Number timeout [, Mixed param] );

Description

Set timer, based on setTimeout, but action is executed as node.

Parameters

node
Node Node to execute action on
action
Function|String Function or name of function to execute on timeout
timeout
Number timeout in milliseconds
param
Mixed Optional parameter to pass to callback when timeout occurs.

Returns

Number timer_id, which can be used to reset timer.

Examples

Plain timer - action as string (lowest memory footprint)
var node = u.qs("#node"); node.timerDone = function() { // timer done } u.t.setTimer(node, "timerDone", 500);

Returns timer_id.

Plain timer - function reference
var node = u.qs("#node"); node.timerDone = function() { // timer done } u.t.setTimer(node, node.timerDone, 500);

Returns timer_id.

Plain timer - inline function
var node = u.qs("#node"); u.t.setTimer(node, function() { // timer done }, 500);

Returns timer_id.

Passing parameter
var node = u.qs("#node"); node.timerDone = function(string) { // timer done alert(string); } u.t.setTimer(node, node.timerDone, 500, "hello");

Returns timer_id.

Uses

JavaScript
  • setTimeout
Manipulator

none

Util.Timer.resetTimer

Definition

Name
Util.Timer.resetTimer
Shorthand
u.t.resetTimer
Syntax
Void = Util.Timer.resetTimer( Number id );

Description

Reset timer, using clearTimeout. Prevent it from executing action.

Parameters

id
Number timer id to reset

Returns

Void

Examples

node.timer_id = u.t.setTimer(node, callbackFunction, 500); u.t.resetTimer(node.timer_id);

Timer never fires because of timer reset.

Uses

JavaScript
  • clearTimeout
Manipulator

none

Util.Timer.resetAllTimers

Definition

Name
Util.Timer.resetAllTimers
Shorthand
u.t.resetAllTimers
Syntax
Void = Util.Timer.resetAllTimers();

Description

Reset all timers.

Parameters

No parameters

Returns

Void

Examples

node.timer_id = u.t.setTimer(node, callbackFunction, 500); u.t.resetTimer(node.timer_id);

Timer never fires because of timer reset.

Uses

JavaScript

none

Manipulator
  • Util.Timer.resetTimer

Util.Timer.setInterval

Definition

Name
Util.Timer.setInterval
Shorthand
u.t.setInterval
Syntax
Number = Util.Timer.setInterval( Node node, Function action, Number timeout [, Mixed param] );

Description

Set interval, based on setInterval, but action is executed as node.

Parameters

node
Node Node to execute action on
action
Function Function to execute on timeout
timeout
Number timeout in milliseconds
param
Mixed Optional parameter to pass to callback when timeout occurs.

Returns

Number interval_id, which can be used to reset interval.

Examples

var node = u.qs("#node"); node.intervalDone = function() { // done, again and again... } u.t.setInterval(node, node.intervalDone, 500);

Returns interval_id.

Uses

JavaScript
  • setInterval
Manipulator

none

Util.Timer.resetInterval

Definition

Name
Util.Timer.resetInterval
Shorthand
u.t.resetInterval
Syntax
Void = Util.Timer.resetInterval( Number id );

Description

Reset interval, using clearInterval. Prevent it from executing action.

Parameters

id
Number interval id to reset

Returns

Void

Examples

var interval_id = u.t.setInterval(node, callbackFunction, 500); u.t.resetInterval(interval_id);

callbackFunction never trigered, we reset interval.

Uses

JavaScript
  • clearInterval
Manipulator

none

Util.Timer.resetAllIntervals

Definition

Name
Util.Timer.resetAllIntervals
Shorthand
u.t.resetAllIntervals
Syntax
Void = Util.Timer.resetAllIntervals();

Description

Reset all intervals.

Parameters

No parameters

Returns

Void

Examples

No examples

Uses

JavaScript

none

Manipulator
  • Util.Timer.resetInterval

Files

Main file

  • u-timer.js

Segment support files

  • none

Segment dependencies

desktop_edge
u-timer.js
desktop_ie11
u-timer.js
desktop
u-timer.js
desktop_ie10
u-timer.js
desktop_ie9
u-timer.js
desktop_light
u-timer.js
tablet
u-timer.js
tablet_light
u-timer.js
smartphone
u-timer.js
mobile
not tested
mobile_light
not tested
tv
u-timer.js
seo
not supported