ContentAPI

When utilizing the content API syntax is key

With dominKnow | ONE you can access a variety of functions through the contentAPI and utilize them in your HTML widgets. When using them them, syntax is key.

The basic format can be seen below:

For getting and setting variables

//Where thevariablename is the name of a custom variable declared in your dominKnow | ONE project.
parent.contentApi.getData('thevariablename');

//Where tempVar is a JavasScript value to which you are setting the dominKnow | ONE variable.
parent.contentApi.setData('thevariablename',tempVar);


Calling a contentAPI action that gets the studentID

//Where studentID is the name of a custom variable declared in your dominKnow | ONE project.
var studentID = parent.contentApi.getUserID ();

Calling a contentAPI action that gets the studentName

//Where studentName is the name of a custom variable declared in your dominKnow | ONE project.
var studentName = parent.contentApi.getStudentName ();


//NOTE: If you are calling functions from the Execute JavaScript panel you are "one" frame above an HTML widget so the syntax would be:

contentApi.getData('thevariablename');

//instead of 

parent.contentApi.getData('thevariablename');

//drop the "parent" from the call.

General JavaScript Hints

It's often useful to see what is going on in a script. You can send information to the Browser's log (which you can see in advanced settings - JavaScript Console) so you know if the script is working.

For example in the studentName case you could report the value to the console log when testing with the following JavaScript command.

console.log ("student is " + studentName);

DISCLAIMER: The dominKnow support team does NOT provide programming/coding support for the creation of CSS and JavaScript elements when creating your dominKnow | ONE content.