Documentation (API v1.0)
Set/Get Attribute Code Sample
In this example, the widgelet maintains the application information in the session storage.
// Once the widgelet code for API gets loaded, the RA platform will call this function
// to set its display properties.
function App_init() {
// Display properties.
var dinfo = {
visible:true,
iconIndex: 0,
tooltip: "Tooltip Text"
};
// To set the attributes required for the display(icon,tooltiptext) properties of the app.
RoamAbout.setAttribute("display", dinfo);
}
// RA platform will call this function to get the display properties of the app.
function App_getDisplayInfo() {
// To get the attributes required for the display(icon,tooltiptext) properties of the app.
return RoamAbout.getAttribute("display");
}
HTTP Request Code Sample
// RA platform will call this function when the user clicks the app icon in the tray.
function App_handleClick() {
// This function will make a HTTP request to the callback URL with the following query string.
// Query string to append with the callback URL.
var query = "?q=1";
RoamAbout.httpRequest(function(status, data, context)
{responseReceived(status, data, context);}, null, query);
return 0;
}
// The callback function for httpRequest API. It gets called when it receives response from
// the HTTP request. The data argument contains the response text.
function responseReceived(status, data, context) {
try {
alert(data);
}
catch(e)
{
alert(e);
}
}
Create/Delete Overlay Code Sample
// RA platform will call this function when the user clicks the app icon in the tray.
function App_handleClick() {
try {
// If an overlay is not created yet, it will create an overlay for the app.
if (overlayId == null) {
// This function will create an overlay, and host your callback URL with the following
// query string.
// Query string to append with the callback URL.
var query = "?q=1";
// This will create an overlay with the given width(300) and height(400), and the
// callback function to store the overlay id when the overlay created.
RoamAbout.createOverlay(function(status, data, context){
overlayCreated(status, data, context);}, null, 300, 400, query);
}
//If overlay is already created then delete it.
else {
// This will destroy an overlay by passing the overlay id, and the callback
// function to uninitialize the overlay id when the overlay destroyed.
RoamAbout.destroyOverlay(function(status, data, context){
overlayDestroyed(status, data, context);}, null, overlayId);
}
}
catch(e) {
alert(e);
}
return 0;
}
// The callback function for createOverlay API. It gets called when it receives a response from
// the createOverlay API. The data argument contains the overlay id.
function overlayCreated(status, data, context) {
// Store the overlay id
overlayId = data;
}
// The callback function for destroyOverlay API. It gets called when it receives a response from
// the destroyOverlay API.
function overlayDestroyed(status, data, context) {
// Uninitialize the overlay id
overlayId = null;
}
GetLocation Code Sample
// RA platform will call this function when the user clicks the app icon in the tray.
function App_handleClick() {
// This function will get the location(URL) of the current document. It will truncate
// the location(URL) text to the maxlength i.e., provided in the call (200). If the
// maxlength is not provided, it will truncate the location(URL) text to the default
// maxlength(120).
RoamAbout.getLocation(function(status, data, context)
{locationReceived(status, data, context);}, null, 200);
return 0;
}
// The callback function for getLocation API. It gets called when it receives response from
// the getLocation API. The data argument contains the location(URL) text.
function locationReceived(status, data, context){
try {
alert(data);
}
catch(e)
{
alert(e);
}
}
GetSelection Code Sample
// RA platform will call this function when the user clicks the app icon in the tray.
function App_handleClick() {
// This function will get the selected content from the current document. It will truncate
// the selected content to the maxlength i.e., provided in the call (80). If the maxlength
// is not provided, it will truncate the selected content to the default maxlength(40).
RoamAbout.getSelection(function(status, data, context)
{selectionReceived(status, data, context);}, null, 80);
return 0;
}
// The callback function for getSelection API. It gets called when it receives response from
// the getSelection API. The data argument contains the selected content.
function selectionReceived(status, data, context){
try {
alert(data);
}
catch(e)
{
alert(e);
}
}
GetTitle Code Sample
// RA platform will call this function when the user clicks the app icon in the tray.
function App_handleClick() {
// This function will get the title of the current document. It will truncate the title to the
// maxlength i.e., provided in the call (80). If the maxlength is not provided, it will
// truncate the title to the default maxlength(40).
RoamAbout.getTitle(function(status, data, context)
{titleReceived(status, data, context);}, null, 80);
return 0;
}
// The callback function for getTitle API. It gets called when it receives response from
// the getTitle API. The data argument contains the selected content.
function titleReceived(status, data, context){
try {
alert(data);
}
catch(e)
{
alert(e);
}
}


