Utilities & Timers
⚠️ Always use jSignage timers (
$.setTimeout), neverwindow.setTimeout.
Timer Methods
| Method | Description |
|---|---|
$.setTimeout(fn, ms) | Execute once after delay |
$.clearTimeout(handle) | Cancel pending timeout |
$.setInterval(fn, ms) | Execute repeatedly |
$.setIntervalSync(fn, ms) | Synchronized interval (3.0.6+) |
$.clearInterval(handle) | Cancel repeating interval |
Timer Example
var count = 0;
$.setInterval(function() {
count++;
$('#counter').text(String(count));
}, 1000);Helper Methods
| Method | Description |
|---|---|
$.shuffle(array) | Random shuffle (Fisher-Yates) |
$.randomChoice(array) | Pick one random element |
$.extend(target, ...sources) | Merge objects (like jQuery.extend) |
$.getDocumentViewbox() | Get {x, y, width, height} viewBox |
$.durInSeconds(str) | Convert duration string to seconds |
Shuffle for Random Playlist
var items = $.shuffle(['A.jpg', 'B.jpg', 'C.jpg', 'D.jpg']);
$.playlist({ data: items, repeatDur: 'indefinite'}).addTo('svg');
Loggers
Method Level $.debug(msg)Debug $.info(msg)Info $.warn(msg)Warning $.error(msg)Error
Localization
var fmt = $.DateTimeFormat('en-US', { dateStyle: 'long', timeStyle: 'short'});
var text = fmt.format(new Date());
Related Pages
- jSignage Core — library loading and
constraints
- Playlists —
$.shuffle() for random order
- Text Layers — dynamic clocks with
$.setInterval()