JavaScript Reference

General

html5.ready(callback)

ParameterTypeRequiredDefaultDescription
callbackfunctionYes--Function called when library has been initialized

Specify a function to be called when the library and document has been loaded. When the registered callback function has been executed it is safe to call the other library functions.


html5.getClickTag(name)

ParameterTypeRequiredDefaultDescription
namestringNo"clickTAG"Name of click tag parameter to get. See Multiple Landing Pages for more information.

Returns a URL to use for redirecting to a specified landing page. Optionally takes a parameter with the name of a specific click tag to return. Please note that this function will not simply return a URL specified in your manifest.json file, but will augment the URL with click tracking information. Therefore it is important to fetch the landing page URL using this method instead of specifying it in code.


html5.getVariable(name)

ParameterTypeRequiredDefaultDescription
namestringYes--Name of variable to get. See Variables for type information.

Either returns a value defined by you in your manifest.json file, or a dynamically expanded macro variable. See Variables for more information.


html5.createClickTag(url)

ParameterTypeRequiredDefaultDescription
urlstringYes--URL of landing page to redirect to

Returns a URL to use for redirecting to a dynamically specified landing page. Please note that you need to use this function if you wish to redirect the user to a custom landing page since it will augment the URL with click tracking information.

Geo


html5.geo.nearest(coords)

ParameterTypeRequiredDefaultDescription
coordslist<coord>Yes--List of objects with "latitude" and "longitude" entries

Returns the nearest coordinate given the browser's current location as a reference point. Requires "$latitude" and "$longitude" as configured variables.


html5.geo.order(coord, coords)

ParameterTypeRequiredDefaultDescription
referenceCoordcoordYes--Reference coordinate
coordslist<coord>Yes--List of objects with "latitude" and "longitude" entries

Returns a list of coordinates ordered by distance from the passed in reference point.


html5.geo.distance(a, b)

ParameterTypeRequiredDefaultDescription
acoordYes--Starting coordinate
bcoordYes--End coordinate

Returns the distance between two locations in space in meters.

Product Feed


html5.products.all()

Returns products from product feed. Requires "$productFeed""$products" and optionally "$numberOfProducts as configured variables.