Namespace jQueryChrono
Main namespace
Defined in: jquery.chrono.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Field Attributes | Field Name and Description |
---|---|
<inner> <constant> |
Reasonable defaults (delay: 4, units: ms), based on how Mozilla works with timers:
https://developer.mozilla.org/en/window.setTimeout#Minimum_delay_and_timeout_nesting
|
<inner> |
Trim string.
|
<inner> <constant> |
The supported units of time:
millisecond, milliseconds, ms, second, seconds, sec, secs, s, minute, minutes, min, mins, m, hour, hours, hr, hrs, h, day, days, d |
Method Attributes | Method Name and Description |
---|---|
<inner> |
after()
|
<inner> |
create_timer(delay|delay+units, units, callback)
Accepts more human-readable arguments for creating JavaScript timers and
converts them to values that can be inspected and passed along to
setTimeout or setInterval.
|
<static> |
jQueryChrono.create_timer()
|
<inner> |
every()
|
<inner> |
parse_callback(parsed, args)
Parses a callback function from the given arguments.
|
<inner> |
parse_delay(parsed, args)
Parses a numerical delay from the given arguments.
|
<inner> |
parse_sequence(parsed, args)
Parses a string sequence of delay with unit arguments.
|
<inner> |
parse_units(parsed, args)
Parses a units string from the given arguments.
|
Field Detail
<inner> <constant>
defaults
Reasonable defaults (delay: 4, units: ms), based on how Mozilla works with timers:
https://developer.mozilla.org/en/window.setTimeout#Minimum_delay_and_timeout_nesting
<inner>
{String}
trim
Trim string. Copied from jQuery.
<inner> <constant>
valid_units
The supported units of time:
millisecond, milliseconds, ms,
second, seconds, sec, secs, s,
minute, minutes, min, mins, m,
hour, hours, hr, hrs, h,
day, days, d
millisecond, milliseconds, ms,
second, seconds, sec, secs, s,
minute, minutes, min, mins, m,
hour, hours, hr, hrs, h,
day, days, d
Method Detail
<inner>
after()
<inner>
{Object}
create_timer(delay|delay+units, units, callback)
Accepts more human-readable arguments for creating JavaScript timers and
converts them to values that can be inspected and passed along to
setTimeout or setInterval.
If the time when the timer should run is negative or faster than the default (jQueryChrono-defaults), it uses the default delay and default units.
If the time when the timer should run is negative or faster than the default (jQueryChrono-defaults), it uses the default delay and default units.
- Parameters:
- {Number|String} delay|delay+units
- Combined with units, represents when a timer should run.
Units can be specified as part of this argument as a suffix of the string and must represent a valid unit of time (jQueryChrono-valid_units). - {String} units Optional
- Combined with the delay, represents when a timer should run. If present, must be a valid unit of time (jQueryChrono-valid_units).
- {Function} callback
- Represents the code to be executed when the timer is ready.
- Returns:
- {Object} An object with a valid "delay", a valid "units" string, a time, in milliseconds, of "when" the timer should run, and a "callback" that the timer should execute when it's ready.
<static>
jQueryChrono.create_timer()
<inner>
every()
<inner>
{Object}
parse_callback(parsed, args)
Parses a callback function from the given arguments.
- Parameters:
- {Object} parsed
- The arguments parsed so far
- {arguments} args
- The original arguments from the caller (e.g. jQueryChrono.create_timer)
- Throws:
- Exception if the callback is not a function
- Returns:
- {Object} The parsed parameter updated with the parsed callback
<inner>
{Object}
parse_delay(parsed, args)
Parses a numerical delay from the given arguments.
- Parameters:
- {Object} parsed
- The arguments parsed so far
- {arguments} args
- The original arguments from the caller (e.g. jQueryChrono.create_timer)
- Throws:
- Exception if the delay is not a number
- Returns:
- {Object} The parsed parameter updated with the parsed delay
<inner>
{Object}
parse_sequence(parsed, args)
Parses a string sequence of delay with unit arguments.
"1 minute, 15 seconds" // parsed = { delay: 75, units: "seconds" }
- Parameters:
- {Object} parsed
- The arguments parsed so far
- {arguments} args
- The original arguments from the caller (e.g. jQueryChrono.create_timer)
- Throws:
- Exception if the sequence contains blanks, invalid delays, or invalid units
- Returns:
- {Object} The parsed parameter updated with the parsed delay and units, each set to the minimum unit in the sequence
<inner>
{Object}
parse_units(parsed, args)
Parses a units string from the given arguments.
- Parameters:
- {Object} parsed
- The arguments parsed so far
- {arguments} args
- The original arguments from the caller (e.g. jQueryChrono.create_timer)
- Throws:
- Exception if the units are not a key of jQueryChrono-valid_units
- Returns:
- {Object} The parsed parameter updated with the parsed units