Engine for Web Applications

org.cote.js.monitor

Class Index

static org.cote.js.monitor.MonitorService

version 2.0.0

Static instance of MonitorServiceImpl

This class participates in the engine library.

org.cote.js.monitor.Monitor

version 2.0.0

An object registerer with the ObjectRegistry, that defines an initializeMonitor method, and that may define any handle_{event name} method listed for the MonitorService. The initializeMonitor method must return true for the object to be treated as a monitor and receive event notifications and intervall callbacks.

See Example Monitor #1 for an example of implementating the script on a page. This class participates in the engine library.

Index

Example Index

Method Index

Examples

Example Monitor #1

Demonstrate how to create and register a basic monitor object.

Example Code

var oMonitor = {
   handle_window_load:function(){
   },
   // Required by MonitorService
   initializeMonitor:function(){
      // must return true for monitoring to be enabled;
      return 1;
   }
};
// important to prepare object so 1) it can be registered, and 2) add it to the ObjectRegistry
org.cote.js.prepareObject("MyMonitor","1.0",true,oMonitor);
// add the monitor object
org.cote.js.monitor.MonitorService.addMonitor(oMonitor);

Example Monitor #2

Demonstrate alternate method to create and register a basic monitor object, and include inline configuration for the monitor.

Example Code

function Monitor(){
}
Monitor.prototype.initializeMonitor = function(){
   alert("Access configuration value: " + this.getConfigKey("myprop"));
   // must return true for monitoring to be enabled;
   return 1;
}
var oMonitor = new Monitor();
// important to prepare object so it can be registered; skip auto-registering for this demonstration.
org.cote.js.prepareObject("MyMonitor","1.0",false,oMonitor");
// Add object to the registry.  It must be registered in order to be added as a monitor.
org.cote.js.registry.ObjectRegistry.addObject(oMonitor);
org.cote.js.monitor.MonitorService.addMonitor(oMonitor,"myprop:myval&myprop2:myval2");

Example Monitor #3

Demonstrate how to create and register a monitor using an ApplicationComponent.

Example Code

<!-- XML Component File -->
<application-components>
   <application-component id = "demo_monitor">
<![CDATA[
         component_init:function(){
           org.cote.js.monitor.MonitorService.addMonitor(this);
         },
         initializeMonitor:function(){
            return true;
         },
         handle_window_load:function(e){
            alert("window load via monitor service");
         }
      ]]>
   </application-component>
</application-components>
<!-- HTML Page -->
<script type = "text/javascript">
var oComponent = org.cote.js.appcomp.ApplicationComponent.newInstance();
oComponent.loadComponent("demo_monitor","/path/to/file.xml");
</script>

Methods

doInterval

Invoked by MonitorService doInterval. By default, this is invoked every one second. Each monitor can conttrol participating in the interval by setting the can_interval property to true or false, and can increase delay by setting the interval_offset property to the number of whole seconds that should elapse before doInterval is invoked again. The interval_offset is used as a degrading counter, so each monitor is responsible for setting its own delay after each invocation of doInterval. Method is virtual and can be overridden.

Syntax

void doInterval( )

getConfigKey

Syntax

v = getConfigKey( c )

Parameters

Returns

v as variant: Returns the String or int value for the corresponding key.

getConfigKeys

Returns the config_keys hash.

Syntax

c = getConfigKeys( )

Returns

c as hash: Returns the hash containing the parsed inline configuration name/value pairs.

getMonitorService

Returns the MonitorService to which this Monitor is registered.

Syntax

m = getMonitorService( )

Returns

m as MonitorServiceImpl: A MonitorService implementation.

handle_context_menu

Invoked by MonitorService dispatchEvent to delegate the contextmenu event. Method is virtual and can be overridden.

Syntax

void handle_context_menu( e )

Parameters

handle_document_scroll

Invoked by MonitorService dispatchEvent to delegate the document scroll event. Method is virtual and can be overridden.

Syntax

void handle_document_scroll( e )

Parameters

handle_form_reset

Invoked by MonitorService dispatchEvent to delegate the form reset event. Method is virtual and can be overridden.

Syntax

void handle_form_reset( e )

Parameters

handle_form_submit

Invoked by MonitorService dispatchEvent to delegate the form submit event. Method is virtual and can be overridden.

Syntax

void handle_form_submit( e )

Parameters

handle_input_blur

Invoked by MonitorService dispatchEvent to delegate the input blur event. Method is virtual and can be overridden.

Syntax

void handle_input_blur( e )

Parameters

handle_input_focus

Invoked by MonitorService dispatchEvent to delegate the input focus event. Method is virtual and can be overridden.

Syntax

void handle_input_focus( e )

Parameters

handle_mouse_click

Invoked by MonitorService dispatchEvent to delegate the mouse click event. Method is virtual and can be overridden.

Syntax

void handle_mouse_click( e )

Parameters

handle_mouse_move

Invoked by MonitorService dispatchEvent to delegate the mouse move event. Method is virtual and can be overridden.

Syntax

void handle_mouse_move( e )

Parameters

handle_select_change

Invoked by MonitorService dispatchEvent to delegate the select change event. Method is virtual and can be overridden.

Syntax

void handle_select_change( e )

Parameters

handle_window_beforeunload

Invoked by MonitorService dispatchEvent to delegate the beforeunload event. Method is virtual and can be overridden.

Syntax

void handle_window_beforeunload( e )

Parameters

handle_window_blur

Invoked by MonitorService dispatchEvent to delegate the window blur event. Method is virtual and can be overridden.

Syntax

void handle_window_blur( e )

Parameters

handle_window_error

Invoked by MonitorService dispatchEvent to delegate the error event. TODO: need to fix handler parameters. At the moment, error information is not being passed. Method is virtual and can be overridden.

Syntax

void handle_window_error( e )

Parameters

handle_window_focus

Invoked by MonitorService dispatchEvent to delegate the window focus event. Method is virtual and can be overridden.

Syntax

void handle_window_focus( e )

Parameters

handle_window_keydown

Invoked by MonitorService dispatchEvent to delegate the window keydown event. Method is virtual and can be overridden.

Syntax

void handle_window_keydown( e )

Parameters

handle_window_load

Invoked by MonitorService dispatchEvent to delegate the load event and binds elements to internal handlers. Dispatches window_load to monitors. Method is virtual and can be overridden.

Syntax

void handle_window_load( e )

Parameters

handle_window_resize

Invoked by MonitorService dispatchEvent to delegate the window resize event. Method is virtual and can be overridden.

Syntax

void handle_window_resize( e )

Parameters

handle_window_unload

Invoked by MonitorService dispatchEvent to delegate the unload event. Method is virtual and can be overridden.

Syntax

void handle_window_unload( e )

Parameters

initializeMonitor

Invoked by addMonitor if the object met the basic criteria for participating in the MonitorService: it must be registered, and it must define this method. Returns true if the object was initialized, false otherwise. If returning false, the object will not be treated as monitor and receive no notifications or callbacks. Whether this returns true or false, the object will continue to define the members set when addMonitor was invoked. Method is virtual and can be overridden.

Syntax

b = initializeMonitor( )

Returns

b as boolean: True if the object initialized and should be treated as a monitor, false if the object should be ignored.

org.cote.js.monitor.MonitorServiceImpl

version 2.0.0

A base class for creating beacon and XML transponders for monitoring Web pages.

This class participates in the engine library.

Index

Property Index

Method Index

Properties

object_config

Object API structure for storing sub structures: object_config.pointers and object_config.status.

Syntax

object = object.object_config

object_id

Unique instance identifier.

Syntax

String = object.object_id

object_type

The type of this object.

Syntax

String = object.object_type

object_version

Version of the object class.

Syntax

String = object.object_version

ready_state

Object load and execution state. Follows: 0 unitialized, 1 through 3 variant, 4 ready, 5 destroyed.

Syntax

int = object.ready_state

Methods

absorb

Copies the source array into the target array.

Syntax

void absorb( a, b )

Parameters

addMonitor

Adds an object to the monitor service, and allows that object to automatically receive event callbacks and easy access to MonitorService information. The specified object must define an initializeMonitor method, and the method must return true for the monitor to be added. Defines the getMonitorService method, can_interval, and interval_offset on the specified object.

Syntax

void addMonitor( o, c )

Parameters

bindElements

Binds MonitorService event handlers to common Web page objects. Individual monitors participate in the event handler by defining a handle_{event name} function, such as handle_window_load. Method is private and should not be directly referenced.

Syntax

void bindElements( )

dispatchEvent

Dispatches event notifications to Monitor instances that define a function named handle_{event key}, such as handle_window_load. The event object is passed as the only parameter. NOTES: should we bother with cancelling events? These are monitors, which shouldn't be tampering with anything. Method is private and should not be directly referenced.

Syntax

void dispatchEvent( s, e )

Parameters

doInterval

A an interval (one second / one thousand milliseconds) that invokes the doInterval method on Monitor instances that set the can_interval property to true. Monitors can increase delay by setting the interval_offset property to the number of seconds that should elapse before doInterval is invoked again. The interval_offset is used as a degrading counter, so each monitor is responsible for setting its own delay after each invocation of doInterval. Method is private and should not be directly referenced.

Syntax

void doInterval( )

getApplicationId

Returns the application id. Defaults to Global. Can be specified by defining the global APPLICATION_ID variable to a custom value.

Syntax

s = getApplicationId( )

Returns

s as String: String indicating the application identifier.

getContextId

Returns a light hash of the current page location plus a few random numbers to uniquely identify the current page visit from other pages visits by this particular session. This value only has to be unique in relation to other context_ids for the session id.

Syntax

s = getContextId( )

Returns

s as String: Light hash of the current Web page location plus a few random numbers.

getContextObject

Returns the object in which all monitoring should take place. Defaults to document. Can be specified by setting the global CONTEXT_OBJECT variable to a different object prior to loading the MonitorService.

Syntax

d = getContextObject( )

Returns

d as DOMNode: The context node in which monitoring is to take place.

getDatasetId

Returns the identifier used to describe the data being collected. Defaults to public. Can be specified by defining the global DATASET_ID variable to a custom value.

Syntax

d = getDatasetId( )

Returns

d as String: Identifier representing the type of data being collected.

getDatasetId

Returns true if the document has loaded, false otherwise.

Syntax

b = getDatasetId( )

Returns

b as boolean: Bit indicating whether the document has loaded and, under normal circumstances, whether it is rendered.

getObjectId

Returns the unique id of the object.

Syntax

i = getObjectId( )

Returns

i as String: The unique object instance id.

getObjectType

Returns the type of the object.

Syntax

t = getObjectType( )

Returns

t as String: The type of the object instance.

getObjectVersion

Returns the version of the object.

Syntax

v = getObjectVersion( )

Returns

v as String: The version of the object instance.

getPointers

Returns the object_config.pointers sub structure.

Syntax

o = getPointers( )

Returns

o as object: The object_config.pointers substructure.

getReadyState

Returns the state of the object.

Syntax

s = getReadyState( )

Returns

s as int: The object ready state.

getSessionId

Returns the session id based on the pre-configured session cookie name. By default, the MonitorService ships with MONITOR_SESSION_ID, and the value is auto-generated. To use a different cookie name, the SDK must be used to alter the build configuration. TODO: Add support for configurable names at runtime.

Syntax

s = getSessionId( )

Returns

s as String: String indicating the application session identifier.

getStatus

Returns the object_config.status sub structure.

Syntax

o = getStatus( )

Returns

o as object: The object_config.status substructure.

getWindowState

Returns an int representing the current state of the browser window. 0 = unknown, 1 = uninitialized, 2 = window not loaded, 3 = window loaded, 4 = window before unload, 5 = window unload

Syntax

i = getWindowState( )

Returns

i as int: The current state of the browser window.

handle_context_menu

Handler that manages the contextmenu event. Dispatches context_menu to monitors. Method is private and should not be directly referenced.

Syntax

void handle_context_menu( )

handle_document_scroll

Handler that manages the document scroll event. Dispatches document_scroll to monitors. Method is private and should not be directly referenced.

Syntax

void handle_document_scroll( )

handle_document_stop

Handler that manages the stop event. Dispatches document_stop to monitors. Method is private and should not be directly referenced.

Syntax

void handle_document_stop( )

handle_form_reset

Handler that manages the form reset event. Dispatches form_reset to monitors. Method is private and should not be directly referenced.

Syntax

void handle_form_reset( )

handle_form_submit

Handler that manages the form submit event. Dispatches form_submit to monitors. Method is private and should not be directly referenced.

Syntax

void handle_form_submit( )

handle_input_blur

Handler that manages the input blur event. Dispatches input_blur to monitors. Method is private and should not be directly referenced.

Syntax

void handle_input_blur( )

handle_input_focus

Handler that manages the input focus event. Dispatches input_focus to monitors. Method is private and should not be directly referenced.

Syntax

void handle_input_focus( )

handle_mouse_click

Handler that manages the mouse click event. Dispatches mouse_click to monitors. Method is private and should not be directly referenced.

Syntax

void handle_mouse_click( )

handle_mouse_move

Handler that manages the mouse move event. Dispatches mouse_move to monitors. Method is private and should not be directly referenced.

Syntax

void handle_mouse_move( )

handle_select_change

Handler that manages the select change event. Dispatches select_change to monitors. Method is private and should not be directly referenced.

Syntax

void handle_select_change( )

handle_window_beforeunload

Handler that manages the beforeunload event. Dispatches window_beforeunload to monitors. Method is private and should not be directly referenced.

Syntax

void handle_window_beforeunload( )

handle_window_blur

Handler that manages the window blur event. Dispatches window_blur to monitors. Method is private and should not be directly referenced.

Syntax

void handle_window_blur( )

handle_window_error

Handler that manages the error event. Dispatches window_error to monitors. TODO: need to fix handler parameters. At the moment, error information is not being passed. Method is private and should not be directly referenced.

Syntax

void handle_window_error( )

handle_window_focus

Handler that manages the window focus event. Dispatches window_focus to monitors. Method is private and should not be directly referenced.

Syntax

void handle_window_focus( )

handle_window_interval

Handler that manages the interval thread. Note: this doesn't use the ThreadService, though probably should. Method is private and should not be directly referenced.

Syntax

void handle_window_interval( )

handle_window_keydown

Handler that manages the window keydown event. Dispatches window_keydown to monitors. Method is private and should not be directly referenced.

Syntax

void handle_window_keydown( )

handle_window_load

Handler that manages the load event and binds elements to internal handlers. Dispatches window_load to monitors. Method is private and should not be directly referenced.

Syntax

void handle_window_load( )

handle_window_resize

Handler that manages the window resize event. Dispatches window_resize to monitors. Method is private and should not be directly referenced.

Syntax

void handle_window_resize( )

handle_window_unload

Handler that manages the unload event. Dispatches window_unload to monitors. Method is private and should not be directly referenced.

Syntax

void handle_window_unload( )

hashCookie

Hashes the document cookies into the <i>cookies</i> hash, where the default cookie structure of most browsers is: <i>name=value; name2=value2</i>. Optionally hashes embedded cookie values that use the following syntax: <i>subname:subvalue&subname2:subvalue2</i>. For example: <i>name=subname:subvalue; name2=subname2:subvalue2&subname3:subvalue3</i>

Syntax

void hashCookie( n, b, f )

Parameters

hashValue

Hashes the value into the specified hash, using the specified delimiters, such as: <i>name=value; name2=value2</i>.

Syntax

void hashValue( c, d, s, k )

Parameters

initializeMonitorService

Starts the MonitorService. This is automatically invoke when a MonitorService instance is created. Method is private and should not be directly referenced.

Syntax

void initializeMonitorService( )

removeMonitor

Remove an object from the monitor service.

Syntax

b = removeMonitor( o )

Parameters

Returns

b as boolean: Bit indicating whether the monitor was removed.