Yes-co Open Javascript API
CDN
The Client Javascript library can be loaded through our CDN, for example:
<script src="https://api.yes-co.com/1.0/embed/js/application.js"></script>
Creating a new Application instance
Using the Client Javascript library You can load a piece of Yes-co Open into your own Web Application, for this to happen you need to do 2 things.
1. Create a HTML holder for the Application, for example:
<div id="yesco-application" style="width: 100%;"></div>
2. Create a new instance of the Application onload of the page providing the id of the HTML holder and the url you wish to load, for example:
yesco.addOnLoad(function()
{
// Create a new instance of the yesco application object
var yescoApplication = new yesco.Application({
containerId: 'yesco-application', // Provide the id of the div in which the application will create it's iframe
url: 'putyourgivenurlhere' // Provide the url the application should load
});
}
Subscribing to events
Yes-co Open fires a bunch of events which can be used to handle certain stuff in your own Web Application, these events can be subscribed to using the static method “yesco.connect”,
this method accepts the Yes-co Open Application instance / The name of the event / An optional function or scope + function
for example when just providing a function:
// Register an event to handle the entity changed information received
yesco.connect(yescoApplication, 'onEntityChanged', function(entity) {
console.log('My entity entity, '');
});
In case you wish the scope of the function is set to your own object you can use for example:
// Register an event to handle the entity changed information received
yesco.connect(yescoApplication, 'onEntityChanged', this, function(entity) {
console.log('Received: ', entity);
});
TIP: When using a proper browser like Firefox / Chrome / Safari the function “console.log” will report the object information in an easy to read format (unlike IE which will just report back the string “[1]“).
Available events
The following events are currently available:
onEntityChanged
This event will return an object as the first parameter which contains the following parameters:
- apiId
- The API Object Id
- type
- The API Object type
- label
- This contains what this project has changed, for example “Kadaster” / “MediaVideo” / “Algemeen”
Code sample:
// Register an event to handle the entity changed information received
yesco.connect(yescoApplication, 'onEntityChanged', this, function(entity) {
console.log('Received: ', entity);
});
onEntityCreated
This event will return an object as the first parameter and an object as the second parameter which contains the following parameters:
1st Parameter (entity created)
- apiId
- The API Object Id
- type
- The API Object type
2nd Parameter (entity master)
- apiId
- The API Object Id
- type
- The API Object type
Code sample:
// Register an event to handle the entity created information received
yesco.connect(yescoApplication, 'onEntityCreated', function(entity, entityMaster) {
console.log('Received:', entity, entityMaster);
});
onMcpPublished
This event will return an object as the first parameter which contains the following parameters:
- apiId
- The API Object Id
- type
- The API Object type
- label
- Contains the name of the published channel, this may change over time
Code sample:
// Register an event to handle the entity changed information received
yesco.connect(yescoApplication, 'onMcpPublished', this, function(entity) {
console.log('Received: ', entity);
});
onMcpRevoked
This event will return an object as the first parameter which contains the following parameters:
- apiId
- The API Object ID
- type
- The API Object type
- label
- Contains the name of the revoked channel, this may change over time
Code sample:
// Register an event to handle the entity changed information received
yesco.connect(yescoApplication, 'onMcpRevoked', this, function(entity) {
console.log('Received: ', entity);
});