NAME

Timeout Object

SYNOPSIS

var TIMER = new Timeout(function(){ alert("Timeout") }, 10000);

DESCRIPTION

This object is like the inbuilt 'setTimeout' but allows for pause, resume and reset operations as well as querying the remaining time.

SOURCE

The code can be obtained from the head of this document. View source in your browser.

CONSTRUCTOR

var TIMER = new Timeout( [<action:coderef>, [<period:integer>, [<start:boolean>]]] );

The constructor takes optional parameters of the function to call when the period finishes, and a boolean indicating if we should start immediately

ACCESSORS

remainingTime

var integer = TIMER.remainingTime()

Returns the time remaining on the timeout in thousandths of a second

MANIPULATORS

setAction

TIMER.setAction( <function:coderef> )

Sets (or changes) the function that will be called when time is up

setTime

TIMER.setTime( <period:integer> )

Sets (or changes) the period for the timeout in thousandths of a second. If the timeout is currently in progress, the timer will be reset (but not paused).

METHODS

start

TIMER.start()

reset

TIMER.reset()

start and reset are synonomous functions for starting the Timeout from the original period value

pause

TIMER.pause()

Pauses execution of the function indefinitely

resume

TIMER.resume()

Resumes a timeout from the pause, or if the timeout isn't in progress, from the original period value.

clear

TIMER.clear()

Clears any pause without resuming. Calling resume() after this will be the same as calling start() or reset().

EXAMPLE

SUPPORT

Support for this function is provided via ##javascript on freenode IRC.

Bugs, errors and omissions excepted and accepted.

LICENSE AND COPYRIGHT

Copyright © Rick Measham, 2007. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the GPL or under the same terms as Perl at your discresion.

AUTHOR

Rick Measham (aka Woosta)