• Quick Start
  • Booting
  • Platform
  • Portals
  • References
    • API Reference TOI3
    • IIP Reference
  • Resources
ARRIS Enterprises, Inc. Confidential Information

TOI3 Bootstrapping

TOI3 does not rely on a browser plugin in order to access the TOI interface from a browser environment. Instead, the platform services are accessed using JavaScript and the XMLHttpRequest API. A JavaScript toi object providing access to the platform can be obtained by making an XMLHttpRequest:


function createToiInstance() {
  var bootstrapUrl = "http://localhost:8000/toi/toi.js";
  var xhr = new XMLHttpRequest();
  xhr.open("GET", bootstrapUrl, false);
  var retrievalFailed = false;
  try {
    xhr.send();
    if (xhr.readyState != 4 || xhr.status != 200) {
      retrievalFailed = true;
    }
  }
  catch (e) {
    retrievalFailed = true;
  }
  if (retrievalFailed) {
     throw new Error("Unable to retrieve " + bootstrapUrl +
       ". Did you remember to include the 'kreatv-option-toi3js' IIP?");
  }
  eval.call((window || this), xhr.responseText);
  return new Toi();
}

toi = createToiInstance();
toi.onload = function () {
  // Your TOI3/JS application code goes here
  alert("Successfully loaded TOI version " + toi.version);
};
The resulting object can then be used in a style similar to that of the toi object exposed by the TOI2/JS browser plugin:

var productName = toi.informationService.getObject(
  toi.consts.ToiInformationService.CONST_HW_PRODUCTNAME);
alert("Application is running on a " + productName);

There is no global toi object defined automatically in TOI3/JS. The object is called toi in the code above and in the remainder of the documentation, but the scope and name of the object returned by the Toi function is arbitrary and up to the portal developer to decide. Calling it toi and defining it globally minimizes the effort required to port existing TOI2 applications to TOI3.

5.0.1

Copyright (c) 2016 ARRIS Enterprises, LLC. All Rights Reserved. ARRIS Enterprises, LLC. Confidential Information.