JSignage:Helpers

From SpinetiX Support Wiki

Jump to: navigation, search

This page describes some jSignage utility methods. See also Timers and Parsers.

._createElement()

$._createElement( name, attributes );

Returns: SVG Element

Description

Creates an SVG element (using document.createElementNS DOM method) and adds the specified attributes on the newly created element.

Note that this function returns a DOM object and is different from the $.createElement() method which returns a jSignage Object.

Parameters

  • name
    Type: String.
    The name of the SVG element.
  • attributes
    Type: Plain Object.
    The attributes to be set onto the element.

Example

var elem = $._createElement( 'animate', { attributeName: 'opacity', from: 0, to: 1, dur: 10, begin: 0 } );

.debug()

$.debug( text );

Adds a log entry at debug level with the provided string text. Added in jSignage version 1.3.0.

.durInSeconds()

$.durInSeconds( time, defaultTime );

Returns: Number

Description

Parses a time value and returns its value in seconds or, in case of undefined or malformed, the provided default value.

Parameters

  • time
    Type: Number or String.
    A time value, with or without the unit suffix (e.g., h, min, ms) to be parsed.
  • defaultTime
    Type: Number. Default: 0;
    The default time value to be used in case the parsing fails.

Example

var dur = $.durInSeconds( args && args.dur, 1 );

.error()

$.error( text );

Throws a JavaScript error with the provided string text.

.getCurrentTime()

$.getCurrentTime();

Returns: Number

Description: Gets the current document time in seconds.

.getDocumentViewbox()

$.getDocumentViewbox();

Returns: Plain Object

Description: Gets the document viewBox as an SVGRect object containing x,y, width, and height numeric properties.

.info()

$.info( text );

Adds a log entry at info level with the provided string text. Added in jSignage version 1.3.0.

.randomChoice()

$.randomChoice ( array );

Description: Returns a randomly selected item of the provided array parameter.

.setAttributes()

$.setAttributes( element , attributes );

Returns: Undefined

Description

Sets the specified attributes on an SVG element.

Parameters

  • element
    Type: SVG Element.
    The SVG element to set attributes to.
  • attributes
    Type: Plain Object.
    The attributes to be set onto the element.

.shuffle()

$.shuffle( array );
$.shuffle( array, limit );

Returns: Array

Description

Returns an array containing items selected randomly from the input array. The limit parameter can be used to limit the number of items in the returned array.

Parameters

  • array
    Type: Array.
    The array to be used as source.
  • limit
    Type: Number.
    Optional limit of items of the resulted array.

.triggerWithOffset()

$.triggerWithOffset( trigger, offset );

Returns: Number or String

Description

Produces a well-formed SVG time point to use for the begin or end attribute of an SVG animation element.

Parameters

  • trigger
    Type: Array.
    The time-point to be used as base.
  • offset
    Type: Number.
    A number of seconds to be used as offset from the trigger time-point.

Example

animateElement.setAttribute( 'begin', $.triggerWithOffset( trigger, offset ) );

.warn()

$.warn( text );

Adds a log entry at warning level with the provided string text. Added in jSignage version 1.3.0.

This page was last modified on 14 March 2018, at 14:21.