Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Connected Art - Client library

Electric Objects' Javascript library for building Connected Art

Demo

https://electricobjects.github.io/eo-js/index.html

Usage

Add the script tag in the <head> or <body> of your HTML.

<script src="https://electricobjects.github.io/eo-js/electricobjects.js"></script>

To fetch device data using the Connected Art interface:

ElectricObjects
    .fetchDeviceInfo()
    .then(function(data) {
        // Do something with the data
        console.log(data);
    })
    .catch(function(error) {
        // Handle exceptions
    });

The device data object

The data object returned by fetchDeviceInfo() gives you an object formatted like this:

{
    "id": "sample",
    "latitude": 48.8582,
    "longitude": 2.2945,
    "name": "Sample EO",
    "release_name": "EO2",
    "timezone": "America/New_York"
}

How it works

When your web-based Connected Art is displayed on the EO device, the EO backend appends a JSON Web Token as a parameter of the URL. The token is then used by the Javascript client library to fetch data about the current device.

For example:

Original URL:

https://example.com/my-connected-art-piece

URL when loaded on the EO device:

https://example.com/my-connected-art-piece?eo_device_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ

Testing on non-EO devices

We recommend using the latest version of Google Chrome or Chromium (what the EO devices run) to test Connected Art pieces in your development environment.

When testing on your own computer, a JWT is not provided. For convenience, we automatically return sample data when the JWT is missing.

About

Javascript library for building Connected Art

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages