# JavaScript

This guide will walk you through the basics of using some features of the CaSS Library in Javascript. We'll use the Developer Console in your web browser.

Links for distributions of the library may be found in the Links page inside the developer guide.

# Browser

  1. Navigate here (opens new window). Chrome is what this was built under, but any Javascript console should work. This sample page has the CaSS library loaded, meaning you'll be able to use it directly within the browser's console.
  2. Open the Developer Tools (F12) and switch to the Console.
  3. Clear the console using something resembling 🚫.
  4. Type the following:
  1. After a few seconds, an object should appear on the console with the framework data. Browse the data a bit before continuing.

Now let’s do something a bit more interesting, and Create, Update, Read, then Delete a new competency.

  1. First, we need an identity to work under. Type the following:
  1. If the array has identities in it, you’re good to go (skip to step 5). If not, you need to log in.
m = new EcRemoteIdentityManager();
m.server = repo.selectedServer; //Sets the identity server endpoint to the repository endpoint
m.configureFromServer(console.log,console.log); //This retrieves username and password salts from the server.
  1. We can now begin the login process.
m.startLogin("test","test"); //Creates the hashes for storage and retrieval of keys.
m.fetch(console.log,console.log); //This retrieves the identities and encryption keys from the server.
  1. Now check again to make sure the identity is available for use.
  1. Now let’s instantiate a new competency.
c = new EcCompetency();
  1. Viewing the competency, we can see it has no owner, no id, nothing except for a type. This object is not ready to be saved. Let’s make it so.
c.generateId(repo.selectedServer); //This generates a new ID that sets the object’s home to sandbox.
c.addOwner(EcIdentityManager.ids[0].ppk.toPk()); //This adds us as the owner.
  1. An object isn’t useful without data, so let’s populate it with some useful data.
c.name = "Creating Competencies by hand using CASS.";
c.description = "Subject can create competencies using CASS in the Javascript Console.";
  1. Lets examine our object one more time and then save it.
  1. Now navigate to your new object’s URL (in a new tab!)
  1. Finally, delete the object.
  1. Refreshing the tab, the object has been deleted. However, the object is versioned, so if you perform the following, it will continue to exist. Examine the difference between the IDs. Note that the version portion of the URL will update automatically upon save. (compare it to the ID in step 6)
c.id; // Refers to the the immutable version of the object at that version.
c.shortId(); // Refers to the latest version of the object.
  1. Examine some of the other functions that exist and see how they operate.
f = new EcFramework();

# JavaScript Library

If you'd like to use the JavaScript library, there are several ways of obtaining (or linking to) it:

Check out the Links page for a compilation of all relevant links in one location.

If you’re just looking to retrieve competencies or frameworks, here are some examples:





If you see the alert, you’re ready to go. Check out the other guides for more information.