Namespaces

Property

static

gotDOMContentLoaded

Make sure to catch any DOMContentLoaded events occurring before asynchronous loading of scripts. Those scripts, like ui.js, should check this variable before listening for the event.

Methods

public static

loadScript(url, successCallback, errorCallback)

Load a script.

Parameters

Name Type Optional Description

url

string

 

URL or path to the script. Relative paths are relative to the HTML file that initiated script loading.

successCallback

function()

 

Optional parameterless function that will be called when the script has loaded.

errorCallback

function()

 

Optional function that will be called if loading the script fails, takes an error object as parameter.

public static

loadScripts(array, loadedCallback)

Load array of scripts.

Parameters

Name Type Optional Description

array

array

 

Array of URL or path name stringa. Relative paths are relative to the HTML file that initiated script loading.

loadedCallback

function()

 

Optional parameterless function called when all scripts in the array has loaded.

public static

markScriptAsLoaded(pathOrURL)

Experimental. Mark a script as loaded. This is useful if a script is designed to be included both in HTML and in JavaScript.

Parameter

Name Type Optional Description

pathOrURL

string

 

URL or path to the script. Relative paths are relative to the HTML file that initiated script loading.

public static

os.isAndroid() → boolean

Returns true if current platform is Android, false if not.

Returns

boolean true if platform is Android, false if not.

public static

os.isIOS() → boolean

Returns true if current platform is iOS, false if not.

Returns

boolean true if platform is iOS, false if not.

public static

os.isIOS7() → boolean

Returns true if current platform is iOS 7, false if not.

Returns

boolean true if platform is iOS 7, false if not.

public static

os.isWP() → boolean

Returns true if current platform is Windows Phone, false if not.

Returns

boolean true if platform is Windows Phone, false if not.

public static

printObject(obj, printFun)

Print a JavaScript object (dictionary). For debugging.

Example

var obj = { company: 'Evothings', field: 'IoT' };
evothings.printObject(obj);
evothings.printObject(obj, console.log);

Parameters

Name Type Optional Description

obj

Object

 

Object to print.

printFun

function()

 

print function (optional - defaults to console.log if not given).

public static

scriptsLoaded(callback)

Add a callback that will be called when all scripts are loaded.

It is good practise to always use this function when loading script asynchronously or using a library that does so.

Parameter

Name Type Optional Description

callback

function()

 

Parameterless function that will be called when all scripts have finished loading.