Use the example code as a basis to start new widget libraries.
HelloWorld.prototype = new WidgetLogic();
/**
* Widget constructor
*/
function HelloWorld()
{
}
/**
* Called to start the widget when it should draw its contents. This method
* will be called once per dashboard load, the widget is then responsible for
* updating itself thereafter.
*
* Useful methods:
* this.getResultIDs() : returns the active result ID(s), if applicable (null
* otherwise).
* this.getMonitorIDs() : returns the active monitor ID(s), if applicable (null
* otherwise).
* this.saveCustomSettings() : saves the widget custom settings immediately
* (useful for persisting user settings/data)
*
* Useful fields:
* this.canvas : the HTML element to into which the widget should add DOM
* elements.
* this.widget : the widget object, which contains:
* customSettings : an associative array (JS object) which contains any
* user-specified settings for this widget.
* id : a unique identifer (whole number) for the widget
* color : the user-defined color of the widget
* title : the user-defined title of the widget
* displayName : the widget's default display name
* height : the user-specified custom height of the widget, or -1
* if the user has not specified a height.
*/
HelloWorld.prototype.start = function()
{
}
/**
* This function, if defined, will be called once if the widget is removed from
* a dashboard.
*/
HelloWorld.prototype.destroy = function()
{
}
/**
* If this widget needs to render itself differently for print layout, you can
* use this function to do so. When the widget is ready to be printed, call
* the "callbackFunction" that is passed in.
* params:
* bForPrinting : Boolean. True if the widget should draw for print layout, false
* if the widget should draw for normal screen layout.
* oLayoutArgs : Contains user-selected layout options:
* .paperSize : paper size, such as "Letter", "Legal", "A4", etc.
* .orientation: paper orientation, either "portrait" or "landscape"
* callbackFunction : the function that must be called after the widget is finished
* with layout changes.
*/
HelloWorld.prototype.setPrintLayout = function(bForPrinting, oLayoutArgs, callbackFunction)
{
callbackFunction();
}
/**
* This function, if defined, will be called when a widget is resized. Usually this
* function does not need to be defined. You only need to do so if you have special
* rendering code in your widget that needs the size of the container.
* params:
* newSize : Number. The new size of the widget, in pixels.
*/
HelloWorld.prototype.onWidgetResize = function(newSize)
{
}
/**
* This function, if defined, can return a string of HTML which will be added
* to the widget's edit panel. This allows the user to specify widget custom
* settings which can be accessed in the start() method via the
* "customSettings" field.
*/
HelloWorld.prototype.getCustomSettingsPanelHTML = function()
{
}