Functions

Functions are special methods that come with SDK which allow you to control the state of the beacon window.

open()

Takes no arguments Returns undefined

This function is used to open the beacon window. It is useful when you want to use a button on your webpage to directly open the beacon window. Follow the examples below on how it should be implemented.

Usage

var beacon = document.getElementsByTagName('beacon-app')[0];
beacon.open();

Examples

/** Using a button on webpage to open the beacon window **/
document.getElementById('my-button').addEventListener('click', function() {
var beacon = document.getElementsByTagName('beacon-app')[0];
beacon.open();
});

close()

Takes no arguments Returns undefined

This function is used to close the beacon window. Usage is similar to open function. Follow the examples below on how it should be implemented.

Usage

var beacon = document.getElementsByTagName('beacon-app')[0];
beacon.close();

Examples

/** Using a button on webpage to close the beacon window **/
document.getElementById('my-button').addEventListener('click', function() {
var beacon = document.getElementsByTagName('beacon-app')[0];
beacon.close();
});

getTextColor(color)

Takes 1 String argument which is a valid hex color code Returns String

This function returns a contrasting text color for the color passed as argument. It is the same function that is used to set the text color of beacon window based on the primary color.

This function does not modify beacon window's state. It is provided just for your reference to follow the same color styles.

Usage

var beacon = document.getElementsByTagName('beacon-app')[0];
console.log(beacon.getTextColor("#5CB1DB"));
// #ffffff
console.log(beacon.getTextColor("#6DDAD0"));
// #2c3e50