evothings
Source: evothings-libraries/
Functions for loading scripts asynchronously, detecting platform, and other common application functionality.
Property
Namespaces
easyble
eddystone
iotsensor
os
tisensortag
util
Property
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
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. |
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. |
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. |
os.isAndroid() → boolean
Returns true if current platform is Android, false if not.
- Returns
-
boolean
true if platform is Android, false if not.
os.isIOS() → boolean
Returns true if current platform is iOS, false if not.
- Returns
-
boolean
true if platform is iOS, false if not.
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.
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.
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). |
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. |