Hemi JavaScript Framework
Hemi
Description
Framework base classes, including: Hemi for creating framework objects and loading external libraries; Hemi.xml for AJAX and JSON requests (libXmlRequest derivative); Hemi.registry for object repository management; Hemi.message for delegating message subscriptions and publications.
Class Index
version 3.1.0
The base set of classes for the Hemi Framework.
This class resides in the global namespace.
Index
Object Index
- public Hemi: The core class used to load and manage framework classes.
Objects
Hemi
The core class used to load and manage framework classes.
static Hemi
version
This class resides in the global namespace.
Index
Example Index
Object Index
- public DATATYPES (internal): Enumeration of object types.
- public FrameworkObject: API definition for any object created by the Hemi Framework.
Property Index
Method Index
- private _forName (internal): Creates a specific internal object. Includes the definition for base_object, and supports external definitions via class imports.
- private _implements: Implements a specified feature.
- public getLibrary (internal): Returns the specified namespace object.
- public GetSpecifiedAttribute: Returns the value of an attribute if it was specified and the length is greater than zero.
- public guid: Returns a globally unique identifier, relative to the page view. This uses a weak hash.
- public hashlight: A very light hash.
- public include: Imports the specified namespace.
- public IsAttributeSet: Tests whether an attribute has been set.
- public isImported: Returns the object identifier.
- public log: Sends a message in the #100.3 message block.
- public logDebug: Sends a message in the #100.1 message block.
- public logError: Sends a message in the #100.5 message block.
- public logWarning: Sends a message in the #100.4 message block.
- public lookup: Verifies the specified hierarchy exists.
- public namespace: Creates a hierarchical object namespace from the supplied name.
- public newObject: Creates and optionally registers a new FrameworkObject ready for use within the framework.
- public prepareObject: Prepares and optionally registers a new FrameworkObject ready for use within the Hemi framework.
Examples
Create Framework Object
Demonstrate how to create a new Framework Object
Example Code
// Create a new object that is also registered
var oNewObject = Hemi.newObject("myObject","1.0", true);
var sId = oNewObject.getObjectId();
// Retrieve the object from the registry
var oLookup = Hemi.registry.service.getObject(sId);Prepare an Existing Object for the Framework
Demonstrate how to prepare an existing object for the framework and use a custom identifier.
Example Code
// Prepare an existing object and give it a custom id
var oObject = {};
oObject.object_id = "MyCustomId";
Hemi.prepareObject("myObject", "1.0", true, oObject);
// Retrieve the object from the registry
var oLookup = Hemi.registry.service.getObject("MyCustomId");Objects
DATATYPES
Enumeration of object types.
Properties
- TYPE_STRING as String: string
- TYPE_OBJECT as String: object
- TYPE_FUNCTION as String: function
- TYPE_UNDEFINED as String: undefined
- TYPE_NUMBER as String: number
FrameworkObject
API definition for any object created by the Hemi Framework.
Properties
- properties as object: A hash of primitive values (strings, ints, etc) for storing configuration, settings, and status.
- objects as object: A hash of object values for storing named object references.
- object_id as String: A globally unique identifier.
- object_type as String: The named type of the object.
- object_version as String: The version of the object.
- ready_state as int: State tracking mechanism, used primarily for determining object availability and destruction.
- object_config as object: Object on which the inner status and pointers objects are defined.
Methods
- String = getObjectId(
)
Returns the object identifier.
- String = getObjectType(
)
Returns the object identifier.
- String = getObjectVersion(
)
Returns the object version.
- int = getReadyState(
)
Returns the state of the object.
Properties
Syntax
String = Hemi.
Hemi. = String
Methods
_forName
Creates a specific internal object. Includes the definition for base_object, and supports external definitions via class imports. Method is private and should not be directly referenced.
Syntax
o = _forName(
s
)
Parameters
- s as String : Name of the object to return.
Returns
o as object: Object based on the specified name.
_implements
Implements a specified feature. Method is private and should not be directly referenced.
Syntax
void _implements(
o, n, v
)
Parameters
- o as object : Target object to merge features..
- n as String : Name of merge features.
- v as variant : Overloaded variant arguments to pass to the implementing object constructor.
getLibrary
Returns the specified namespace object.
Syntax
NamespaceObject = getLibrary(
sName
)
Parameters
- sName as String : Namespace or Library name of the imported script file.
Returns
NamespaceObject as object: Returns an internal namespace object.
GetSpecifiedAttribute
Returns the value of an attribute if it was specified and the length is greater than zero.
Syntax
v = GetSpecifiedAttribute(
o, n
)
Parameters
- o as Node : Node reference
- n as String : Name of the attribute to test.
Returns
v as String: Value of the attribute.
guid
Returns a globally unique identifier, relative to the page view. This uses a weak hash.
Syntax
sId = guid(
)
Returns
sId as String: A unique id.
hashlight
A very light hash.
Syntax
sHash = hashlight(
sData
)
Parameters
- sData as String : Data to be hashed.
Returns
sHash as String: A light hash of the input data.
include
Imports the specified namespace.
Syntax
NamespaceObject = include(
sName, sPath, bNoEval
)
Parameters
- sName as String : Namespace of the script file to import.
- sPath as String (optional): Path where the script file resides. Default to Framework/
- bNoEval as boolean (optional): Bit indicating whether the loaded script should not be executed.
Returns
NamespaceObject as object: Returns an internal namespace object.
IsAttributeSet
Tests whether an attribute has been set.
Syntax
b = IsAttributeSet(
o, n, b
)
Parameters
- o as Node : Node reference
- n as String : Name of the attribute to test.
- b as bit (optional): Bit indicating whether to return the attribute value instead of a positive bit.
Returns
b as bit: A bit indicating whether the specified attribute was set.
isImported
Returns the object identifier.
Syntax
bImported = isImported(
s
)
Parameters
- s as String : Namespace name.
Returns
bImported as boolean: Bit indicating whether the namespace has been imported.
log
Sends a message in the #100.3 message block.
Syntax
void log(
sMessage
)
Parameters
- sMessage as String : Message to send to the logger.
logDebug
Sends a message in the #100.1 message block.
Syntax
void logDebug(
sMessage
)
Parameters
- sMessage as String : Message to send to the logger.
logError
Sends a message in the #100.5 message block.
Syntax
void logError(
sMessage
)
Parameters
- sMessage as String : Message to send to the logger.
logWarning
Sends a message in the #100.4 message block.
Syntax
void logWarning(
sMessage
)
Parameters
- sMessage as String : Message to send to the logger.
lookup
Verifies the specified hierarchy exists.
Syntax
v = lookup(
sPath
)
Parameters
- sPath as String : Period-delimited hierarchy.
Returns
v as boolean: Returns true if the hierachy exists, or the matching object if bObjOut is set to true.
namespace
Creates a hierarchical object namespace from the supplied name.
Syntax
void namespace(
sPath, oBase, hContents, bService
)
Parameters
- sPath as String : Period-delimited hierarchy.
- oBase as object (optional): Base object, defaults to Hemi.Context (which default to window).
- hContents as object (optional): Object hash contents.
- bService as boolean (optional): Bit indicating the namespace defines service and serviceImpl members, and to instantiate the service.
newObject
Creates and optionally registers a new FrameworkObject ready for use within the framework.
Syntax
o = newObject(
t, v, r, d, h
)
Parameters
- t as String : The type of the object.
- v as String : The version of the object.
- r as boolean : Bit indicating whether the object should be registered with the Object Registry.
- d as boolean : Bit indicating whether the object should include a deconstructor.
- h as hash : Object members to include on this object.
Returns
o as FrameworkObject: The new framework object.
prepareObject
Prepares and optionally registers a new FrameworkObject ready for use within the Hemi framework.
Syntax
void prepareObject(
t, v, r, o, d
)
Parameters
- t as String : The type of the object.
- v as String : The version of the object.
- r as boolean : Bit indicating whether the object should be registered with the Object Registry.
- o as FrameworkObject : The object to be prepared for use in the Hemi framework.
- d as boolean : Bit indicating whether the object should include a deconstructor.
static registry.service
version 3.1.0
Static implementation of hemi.registry.serviceImpl
This class resides in the global namespace.
Index
Method Index
- public getApplyStatement: Returns a string statement that can be evaluated to return a reference to the specified method for the registered object.
- public getEvalStatement: Returns a string statement that can be evaluated to return a reference to the registered object.
Methods
getApplyStatement
Returns a string statement that can be evaluated to return a reference to the specified method for the registered object.
Syntax
sApplyCode = getApplyStatement(
o, f
)
Parameters
- o as object : Registered object.
- f as String : Name of a method on the registered object
Returns
sApplyCode as String: A javascript statement which, when evaluated, returns a reference to the function on the object.
getEvalStatement
Returns a string statement that can be evaluated to return a reference to the registered object.
Syntax
sEvalCode = getEvalStatement(
o
)
Parameters
- o as object : Registered object.
Returns
sEvalCode as String: A javascript statement which, when evaluated, returns a reference to the object.
registry.serviceImpl
version 3.1.0
Repository service for storing and discovering framework objects.
This class resides in the global namespace.
Index
Method Index
- public addObject: Adds the specified object to the registry, and automatically registers the object with the transaction service.
- public canRegister: Verifies whether an object can be added to the registry.
- public getObject: Returns the object matching the specified identifier or index.
- public getObjectsArray: Returns an array of registered objects.
- public getObjectsMap: Returns the object identifier mapping.
- public isRegistered: Returns true if the specified object is in the registry.
- public removeObject: Removes the specified object from the registry.
- public sendDestroyTo: Invokes the destroy method on the specified object. Object must be registered. This method will not remove the object from the registry.
- public sendSigterm: Sends a termination signal to all registered objects for preparation to be destroyed. This method causes all objects to be removed from the registry, and to have any sigterm method invoked.
Methods
addObject
Adds the specified object to the registry, and automatically registers the object with the transaction service.
Syntax
b = addObject(
o
)
Parameters
- o as object : Object to add to the registry
Returns
b as boolean: Returns true if the object was added to the registry.
canRegister
Verifies whether an object can be added to the registry.
Syntax
b = canRegister(
o
)
Parameters
- o as object : Object to test whether or not it can be registered.
Returns
b as boolean: Returns true if the specified object defines an
getObject
Returns the object matching the specified identifier or index.
Syntax
o = getObject(
v
)
Parameters
- v as variant : Index or name of the object to retrieve.
Returns
o as object: Object with the specified identifier or index.
getObjectsArray
Returns an array of registered objects.
Syntax
a = getObjectsArray(
)
Returns
a as array: Array of registered objects.
getObjectsMap
Returns the object identifier mapping.
Syntax
a = getObjectsMap(
)
Returns
a as array: Array of object identifiers directly mapped to the objects array.
isRegistered
Returns true if the specified object is in the registry.
Syntax
b = isRegistered(
o
)
Parameters
- o as object : Object in the registry
Returns
b as boolean: Returns true if the object is in the registry.
removeObject
Removes the specified object from the registry.
Syntax
b = removeObject(
o, b
)
Parameters
- o as object : Object to remove from the registry
- b as boolean : Bit indicating whether the
Returns
b as boolean: Returns true if the object was removed.
sendDestroyTo
Invokes the destroy method on the specified object. Object must be registered. This method will not remove the object from the registry.
Syntax
b = sendDestroyTo(
o
)
Parameters
- o as object : Object in the registry
Returns
b as boolean: Returns true if the object defined a destroy method and the method was invoked.
sendSigterm
Sends a termination signal to all registered objects for preparation to be destroyed. This method causes all objects to be removed from the registry, and to have any sigterm method invoked.
Syntax
void sendSigterm(
)
static message.service
version 3.1.0
Static implementation of hemi.message.serviceImpl
This class resides in the global namespace.
message.serviceImpl
version 3.1.0
Service that delegates subscriptions and publications at a global and object level.
This class resides in the global namespace.
Index
Object Index
- public Message: Object published to onsendmessage subscribers when the sendMessage method is invoked.
Method Index
- private _delayPublish (internal): End action for a delayed publication. Cached message is sent directly on to publication.
- private _publish (internal): Publishes the specified data to registered subscribers.
- public clearEntries: Clears message entries.
- public flush: Clears delayed delivery cache.
- public getDeliveryDelay: Returns the delay in milliseconds between publication and delivery.
- public getEntries: Returns the current message buffer.
- public getReportThreshold: Returns the report threshold for sendMessage. Messages sent below this level will not be propogated.
- public parseMessage: Parses a message object and returns a formatted construct suitable for printing to a log.
- public publish: Publishes the specified data to registered subscribers. If delayed delivery is in effect, caches the message data and sends it after the preset delay in milliseconds.
- public sendMessage: Sends the specified message as a Message to all onsendmessage subscribers.
- public setDeliveryDelay: Sets the delay in milliseconds between publication and delivery.
- public setReportThreshold: Sets the report threshold for sendMessage. Messages sent below this level will not be propogated.
- public sigterm: Termination signal indicating the message service should stop processing messages and subscriptions, and be prepared for destruction.
- public subscribe: Subscribes an object to receive message publications for the specified publication name.
- public unsubscribe: Unsubscribes an object from receiving message publications for the specified publication name.
Objects
Message
Object published to onsendmessage subscribers when the sendMessage method is invoked.
Properties
- message as variant: Variant message body.
- level as int: The message threshold.
- description as String: Description of the message origination, if the message type code was mapped to an internal definition.
Methods
_delayPublish
End action for a delayed publication. Cached message is sent directly on to publication. Method is private and should not be directly referenced.
Syntax
void _delayPublish(
i
)
Parameters
- i as String : Identifier of the cached message item to be delivered for the corresponding subscribers.
_publish
Publishes the specified data to registered subscribers. Method is private and should not be directly referenced.
Syntax
void _publish(
e, v
)
Parameters
- e as String : The name of the publication.
- v as variant : Data being published.
clearEntries
Clears message entries.
Syntax
void clearEntries(
)
flush
Clears delayed delivery cache.
Syntax
void flush(
)
getDeliveryDelay
Returns the delay in milliseconds between publication and delivery.
Syntax
d = getDeliveryDelay(
)
Returns
d as int: Delay in milliseconds between publication and delivery.
getEntries
Returns the current message buffer.
Syntax
aBuffer = getEntries(
)
Returns
aBuffer as array: Array of recent messages.
getReportThreshold
Returns the report threshold for sendMessage. Messages sent below this level will not be propogated.
Syntax
iThreshold = getReportThreshold(
)
Returns
iThreshold as int: The message threshold.
parseMessage
Parses a message object and returns a formatted construct suitable for printing to a log.
Syntax
sMessage = parseMessage(
o
)
Parameters
- o as Message : A Message object.
Returns
sMessage as String: Formatted message.
publish
Publishes the specified data to registered subscribers. If delayed delivery is in effect, caches the message data and sends it after the preset delay in milliseconds.
Syntax
void publish(
e, v
)
Parameters
- e as String : The name of the publication.
- v as variant : Data being published.
sendMessage
Sends the specified message as a Message to all onsendmessage subscribers.
Syntax
o = sendMessage(
d, s, p
)
Parameters
- d as String : The message data to be sent.
- s as String (optional): Numeric message code.
- p as boolean (optional): Bit indicating the message should raise an alert.
Returns
o as Message: The Message created for this message.
setDeliveryDelay
Sets the delay in milliseconds between publication and delivery.
Syntax
void setDeliveryDelay(
d
)
Parameters
- d as int : Sets the delay in milliseconds.
setReportThreshold
Sets the report threshold for sendMessage. Messages sent below this level will not be propogated.
Syntax
void setReportThreshold(
level
)
Parameters
- level as variant : Int or string value. Int values are 0 - 7, and String values are: ALL, DEBUG, ADVISORY, NORMAL, WARNING, ERROR, FATAL, NONE
sigterm
Termination signal indicating the message service should stop processing messages and subscriptions, and be prepared for destruction.
Syntax
void sigterm(
)
subscribe
Subscribes an object to receive message publications for the specified publication name.
Syntax
void subscribe(
o, e, f, v
)
Parameters
- o as object : The object for which the subscription will belong.
- e as String : The name of the publication.
- f as function : Function to be invoked on message publication.
- v as object : Reference object, such as the publication owner, used to filter publications to this subscription.
unsubscribe
Unsubscribes an object from receiving message publications for the specified publication name.
Syntax
b = unsubscribe(
o, e, f
)
Parameters
- o as object : The object for which the subscription belongs.
- e as String : The name of the publication.
- f as function : Function invoked on message publication.
Returns
b as boolean: Returns true if unsubscribed, false otherwise.
static xml
version 3.1.0
XML Utilities for making AJAX and JSON requests, result caching, request pooling, and XML-XHTML node manipulation.
This class resides in the global namespace.
Index
Example Index
Object Index
- private XmlHttp: Object representing a pooled XMLHTTP resource
- public XmlObject: Object passed to the event handler following an XML request using getXml or postXml.
Property Index
- public auto_content_type: Specifies whether to determine posted content type by included post value.
- public ax_http_control: Specifies the name of the registered ActiveX control to use for XML requests.
- public ax_http_control: Specifies the name of the registered ActiveX control to use for XML requests.
- public form_content_type: Specifies the content type to use when auto_content_type is true and the post value is a string.
- public gadget_base_path: Specifies the base path to use when operating in Gadget mode. The base path should be in the format of a file URI, such as file:///c:/....
- public gadget_control: Specifies the name of the registered ActiveX control to use for XML requests when in Gadget mode.
- public gadget_mode: Specifies whether the xml package is operating in a mode that better supports Windows Sidebar Gadgets.
- public text_content_type: Specifies the content type to use requesting and receiving text data (eg: JSON).
- public xml_content_type: Specifies the content type to use posting data.
Method Index
- private _request_xmlhttp: Assembles and opens an XMLHTTP Request.
- public clear: Clears the request maps and caches.
- public clearCache: Clears the response cache.
- public getCacheEnabled
- public getCDATAValue: Returns a concatenation of all CDATA values that are immediate children of the specified node.
- public getInnerText: Returns a concatenation of text nodes belonging to all children of the specified node.
- public getJSON: Retrieve a JSON object from the specified path.
- public getPoolEnabled
- public getRequestArray: Returns an array of XML requests.
- public getText: Retrieve text from the specified path.
- public getXml: Retrieve an XML document from the specified path.
- public getXmlHttpArray
- private getXmlHttpObjectFromPool: Retrieves the next available XmlHttp object from the pool of available resources.
- public JSONReviver (internal): Custom reviver for handling date values.
- public newXmlDocument
- private newXmlHttpObject: Creates a new XMLHTTPRequest object.
- public parseXmlDocument
- public postJSON: Posts a JSON object to the specified path and returns any JSON response.
- public postText: Posts text to the specified path and returns any text response.
- public postXml: Posts an XML document to the specified path and returns any XML response.
- public queryNode: Returns a DOM Node selected from the specified document and based on the specified parent node name, node name, and attribute name and values.
- public queryNodes: Returns an array of DOM Nodes selected from the specified document and based on the specified parent node name, node name, and attribute name and values.
- public removeChildren: Removes all child nodes of the specified node.
- public resetXmlHttpObjectPool: Resets the current pool with new instances of XMLHttpRequest objects.
- private returnXmlHttpObjectToPool: Returns an in-use XmlHttp object to the pool of available resources.
- public selectNodes: Returns an array of DOM Nodes selected from the specified document and based on the specified path.
- public selectSingleNode: Returns a DOM Node selected from the specified document and based on the specified path.
- public serialize: Returns a string representation of the specified node and its children.
- public setCacheEnabled
- public setInnerXHTML: Copies the child nodes of the specified source node into the specified target node.
- public setPoolEnabled
- public testXmlHttpObject: Tests whether an XMLHTTPRequest object can be created.
- public transformNode: Transforms the specified Document with the specified XSL document.
Message Index
- public onloadxml: Message published to all subscribers when an xml request has completed loading. This message is published for text and JSON requests made through the XML request.
Examples
Asynchronous GET
Make an asynchronous request for an XML document.
Syntax
[int] = getXml(path,custom_handler,1,{optional_id});
Example Code
function HandleXml(s,v){
var oXml = v.xdom;
}
Hemi.xml.getXml("/Data/Test1.xml",HandleXml,1);Asynchronous POST
Asynchronously post data to the server.
Syntax
[int] = postXml(path,data,custom_handler,1,{optional_id});
Example Code
function HandleXml(s,v){
var oResponseXml = v.xdom;
}
var oPostThis = Hemi.xml.newXmlDocument("Request");
var oResponseXml = Hemi.xml.postXml("/Data/TestData.aspx",oPostThis,HandlePostXml,1);Cached Asynchronous GET
Asynchronously request an XML document, and cached the result for later referal.
Syntax
[int] = getXml(path,custom_handler,1,request_id,1);
Example Code
function HandleXml(s,v){
var oXml = v.xdom;
}
Hemi.xml.getXml("/Data/Test1.xml",HandleXml,1,"cache-me",1);Synchronous GET
Make a synchronous request for an XML document.
Syntax
[xml_dom_object] = getXml(path);
Example Code
var oXml = Hemi.xml.getXml("/Data/Test1.xml");Synchronous POST
Synchronously post data to the server.
Syntax
[xml_dom_object] = postXml(path,data);
Example Code
var oPostThis = Hemi.xml.newXmlDocument("Request");
var oData = oPostThis.createElement("data");
oData.setAttribute("id","data-id");
oData.setAttribute("value","data-value");
oPostThis.documentElement.appendChild(oData);
var oResponseXml = Hemi.xml.postXml("/Data/TestData.aspx",oPostThis);Objects
XmlHttp
Object representing a pooled XMLHTTP resource Object is private and should not be directly referenced.
Properties
- xml_object as object: An XMLHttp object.
- in_use as boolean: Bit indicating whether the object is in use.
- vid as int: Integer identifying the variant object identifier.
- handler as function: Anonymous wrapper to invoke the internal readystate or complete handler for the specified identifier.
XmlObject
Object passed to the event handler following an XML request using getXml or postXml.
Properties
- xdom as XMLDocument: An XML Document object.
- id as String: Identifier used to distinguish the request for this XML Document from other requests.
Properties
auto_content_type
Specifies whether to determine posted content type by included post value.
Syntax
boolean = xml.auto_content_type
xml.auto_content_type = boolean
ax_http_control
Specifies the name of the registered ActiveX control to use for XML requests.
Syntax
String = xml.ax_http_control
xml.ax_http_control = String
ax_http_control
Specifies the name of the registered ActiveX control to use for XML requests.
Syntax
String = xml.ax_http_control
xml.ax_http_control = String
form_content_type
Specifies the content type to use when auto_content_type is true and the post value is a string.
Syntax
String = xml.form_content_type
xml.form_content_type = String
gadget_base_path
Specifies the base path to use when operating in Gadget mode. The base path should be in the format of a file URI, such as file:///c:/....
Syntax
String = xml.gadget_base_path
xml.gadget_base_path = String
gadget_control
Specifies the name of the registered ActiveX control to use for XML requests when in Gadget mode.
Syntax
String = xml.gadget_control
xml.gadget_control = String
gadget_mode
Specifies whether the xml package is operating in a mode that better supports Windows Sidebar Gadgets.
Syntax
boolean = xml.gadget_mode
xml.gadget_mode = boolean
text_content_type
Specifies the content type to use requesting and receiving text data (eg: JSON).
Syntax
String = xml.text_content_type
xml.text_content_type = String
Default Value
xml_content_type
Specifies the content type to use posting data.
Syntax
String = xml.xml_content_type
xml.xml_content_type = String
Default Value
Methods
_request_xmlhttp
Assembles and opens an XMLHTTP Request. Method is private and should not be directly referenced.
Syntax
v = _request_xmlhttp(
p, h, a, i, x, d, c, t
)
Parameters
- p as String : Path to the XML data source.
- h as function (optional): Handler invoked for asynchronous requests.
- a as boolean (optional): Bit indicating whether the request is asynchronous.
- i as String (optional): Identifier used to track the request and retrieve cached results.
- x as boolean (optional): Bit indicating whether the request is a post.
- d as XMLDocument (optional): XML Document to send with post request.
- c as boolean (optional): Bit indicating whether the response should be cached.
- t as int (optional): Int indicating whether the request and response as text (1) or JSON (2) instead of XML (0).
Returns
v as variant: Returns a boolean value for asynchronous requests, and an XML Document for synchronous requests.
clear
Clears the request maps and caches.
Syntax
void clear(
)
clearCache
Clears the response cache.
Syntax
void clearCache(
)
getCacheEnabled
Syntax
b = getCacheEnabled(
)
Returns
b as boolean: boolean indicating whether caching is enabled.
getCDATAValue
Returns a concatenation of all CDATA values that are immediate children of the specified node.
Syntax
v = getCDATAValue(
n
)
Parameters
- n as DOMNode : XML DOM Node.
Returns
v as String: Returns a concatenation of all child CDATA values.
getInnerText
Returns a concatenation of text nodes belonging to all children of the specified node.
Syntax
sTxt = getInnerText(
n
)
Parameters
Returns
sTxt as String: Returns the inner text of the specified node.
getJSON
Retrieve a JSON object from the specified path.
Syntax
v = getJSON(
p, h, a, i, c
)
Parameters
- p as String : Path of the JSON source. If specifying the server, note the server name and port must match the context host name and port.
- h as function (optional): Function to invoke when a response is received.
- a as boolean (optional): Bit indicating whether the request is an asynchronous operation.
- i as String (optional): Identifier to assign to the request.
- c as boolean (optional): Bit indicating whether the response should be cached.
Returns
v as variant: Returns boolean for asynchronous operations, and a JSON object for synchronous operations.
getPoolEnabled
Syntax
b = getPoolEnabled(
)
Returns
b as boolean: boolean indicating whether pooling is enabled.
getRequestArray
Returns an array of XML requests.
Syntax
aRequests = getRequestArray(
)
Returns
aRequests as array: An array of requests.
getText
Retrieve text from the specified path.
Syntax
v = getText(
p, h, a, i, c
)
Parameters
- p as String : Path of the text source. If specifying the server, note the server name and port must match the context host name and port.
- h as function (optional): Function to invoke when a response is received.
- a as boolean (optional): Bit indicating whether the request is an asynchronous operation.
- i as String (optional): Identifier to assign to the request.
- c as boolean (optional): Bit indicating whether the response should be cached.
Returns
v as variant: Returns boolean for asynchronous operations, and text for synchronous operations.
getXml
Retrieve an XML document from the specified path.
Syntax
v = getXml(
p, h, a, i, c
)
Parameters
- p as String : Path of the XML source. If specifying the server, note the server name and port must match the context host name and port.
- h as function (optional): Function to invoke when a response is received.
- a as boolean (optional): Bit indicating whether the request is an asynchronous operation.
- i as String (optional): Identifier to assign to the request.
- c as boolean (optional): Bit indicating whether the response should be cached.
Returns
v as variant: Returns boolean for asynchronous operations, and an XMLDocument object for synchronous operations.
getXmlHttpArray
Syntax
aXml = getXmlHttpArray(
)
Returns
aXml as array: Array of XmlHttp objects.
getXmlHttpObjectFromPool
Retrieves the next available XmlHttp object from the pool of available resources. Method is private and should not be directly referenced.
Syntax
oXml = getXmlHttpObjectFromPool(
y
)
Parameters
- y as boolean : Bit indicating whether the pool object is requested for asynchronous operation.
Returns
oXml as XmlHttp: An XmlHttp object.
JSONReviver
Custom reviver for handling date values.
Syntax
r = JSONReviver(
k, v
)
Parameters
- k as String : Key name.
- v as String : Key value.
Returns
r as String: Revived key value for use with JSON.
newXmlDocument
Syntax
oXml = newXmlDocument(
s
)
Parameters
- s as String : Name of root node to create in new document.
Returns
oXml as XMLDocument: XMLDocument object.
newXmlHttpObject
Creates a new XMLHTTPRequest object. Method is private and should not be directly referenced.
Syntax
v = newXmlHttpObject(
b, i, z
)
Parameters
- b as boolean : Bit indicating whether to wrap the new object in an internal XmlHttp object for use with pooling.
- i as int : Pool index to set on new XmlHttp object.
- z as boolean : Bit indicating whether this is a test operation, and to return true if the object was created, or false otherwise.
Returns
v as variant: Return value is determined by the specified parameters.
parseXmlDocument
Syntax
oXml = parseXmlDocument(
s
)
Parameters
- s as String : XML source text.
Returns
oXml as XMLDocument: XMLDocument object.
postJSON
Posts a JSON object to the specified path and returns any JSON response.
Syntax
v = postJSON(
p, d, h, a, i
)
Parameters
- p as String : Path of the XML source. If specifying the server, note the server name and port must match the context host name and port.
- d as XMLDocument : XMLDocument to post the server
- h as function (optional): Function to invoke when a response is received.
- a as boolean (optional): Bit indicating whether the request is an asynchronous operation.
- i as String (optional): Identifier to assign to the request.
Returns
v as variant: Returns boolean for asynchronous operations, and a JSON object for synchronous operations.
postText
Posts text to the specified path and returns any text response.
Syntax
v = postText(
p, d, h, a, i
)
Parameters
- p as String : Path of the XML source. If specifying the server, note the server name and port must match the context host name and port.
- d as XMLDocument : XMLDocument to post the server
- h as function (optional): Function to invoke when a response is received.
- a as boolean (optional): Bit indicating whether the request is an asynchronous operation.
- i as String (optional): Identifier to assign to the request.
Returns
v as variant: Returns boolean for asynchronous operations, and text for synchronous operations.
postXml
Posts an XML document to the specified path and returns any XML response.
Syntax
v = postXml(
p, d, h, a, i
)
Parameters
- p as String : Path of the XML source. If specifying the server, note the server name and port must match the context host name and port.
- d as XMLDocument : XMLDocument to post the server
- h as function (optional): Function to invoke when a response is received.
- a as boolean (optional): Bit indicating whether the request is an asynchronous operation.
- i as String (optional): Identifier to assign to the request.
Returns
v as variant: Returns boolean for asynchronous operations, and an XMLDocument object for synchronous operations.
queryNode
Returns a DOM Node selected from the specified document and based on the specified parent node name, node name, and attribute name and values.
Syntax
aNodes = queryNode(
d, p, n, a, v
)
Parameters
- d as XMLDocument : XMLDocument.
- p as String : Parent element name.
- n as String (optional): Element name. Defaults to parent if not specified.
- a as String (optional): Attribute name.
- v as String (optional): Attribute value.
Returns
aNodes as DOMNode: Returns a DOM Node based on the specified parent node name, node name, and attribute name and value.
queryNodes
Returns an array of DOM Nodes selected from the specified document and based on the specified parent node name, node name, and attribute name and values.
Syntax
aNodes = queryNodes(
d, p, n, a, v
)
Parameters
- d as XMLDocument : XMLDocument.
- p as String : Parent element name.
- n as String (optional): Element name. Defaults to parent if not specified.
- a as String (optional): Attribute name.
- v as String (optional): Attribute value.
Returns
aNodes as array: Returns an array of DOM Nodes based on the specified parent node name, node name, and attribute name and value.
removeChildren
Removes all child nodes of the specified node.
Syntax
void removeChildren(
o, b
)
Parameters
- o as DOMNode : DOM Node.
- b as boolean : Bit indicating to send a termination signal to any backing objects if a Hemi reference identifier is found.
resetXmlHttpObjectPool
Resets the current pool with new instances of XMLHttpRequest objects.
Syntax
void resetXmlHttpObjectPool(
)
returnXmlHttpObjectToPool
Returns an in-use XmlHttp object to the pool of available resources. Method is private and should not be directly referenced.
Syntax
void returnXmlHttpObjectToPool(
i, y
)
Parameters
- i as int : Pool index of the XmlHttp object to be returned.
- y as boolean : Bit indicating whether the pool object was requested for asynchronous operation.
selectNodes
Returns an array of DOM Nodes selected from the specified document and based on the specified path.
Syntax
aNodes = selectNodes(
d, p, c
)
Parameters
- d as XMLDocument : XMLDocument.
- p as String : XPath query.
- c as DOMNode : Context node.
Returns
aNodes as array: Returns an array of DOM Nodes based on the specified xpath query.
selectSingleNode
Returns a DOM Node selected from the specified document and based on the specified path.
Syntax
v = selectSingleNode(
d, p, c
)
Parameters
- d as XMLDocument : XMLDocument.
- p as String : XPath query.
- c as DOMNode : Context node.
Returns
v as String: Returns a DOM Node based on the specified xpath query.
serialize
Returns a string representation of the specified node and its children.
Syntax
s = serialize(
n
)
Parameters
- n as DOMNode : XML DOM Node.
Returns
s as String: String representation of the specified node.
setCacheEnabled
Syntax
void setCacheEnabled(
b
)
Parameters
- b as boolean : boolean indicating whether caching is enabled.
setInnerXHTML
Copies the child nodes of the specified source node into the specified target node.
Syntax
v = setInnerXHTML(
t, s, p, d, z, c, h, ch
)
Parameters
- t as DOMNode : DOM Node into which the source node children will be copied.
- s as DOMNode : DOM Node from which nodes will be copied into the target node.
- p as boolean (optional): Bit indicating whether to keep the children of the target node, or to remove them before copying in the new contents.
- d as Document (optional): Document object to use when creating elements for the target node.
- z as boolean (optional): Bit indicating whether recursion should be blocked.
- c as boolean (optional): Bit indicating whether whitespace should be preserved.
- h as boolean (optional): Bit indicating whether HTML source nodes should be cloned instead of incrementally recreated.
- ch as function (optional): Optional callback handler for substituting values prior to copying. Useful for templates.
Returns
v as variant: Depending on the type of copy operation, returns a reference to the newly created node.
setPoolEnabled
Syntax
void setPoolEnabled(
b
)
Parameters
- b as boolean : boolean indicating whether pooling is enabled.
testXmlHttpObject
Tests whether an XMLHTTPRequest object can be created.
Syntax
b = testXmlHttpObject(
)
Returns
b as boolean: Bit indicating whether a new XMLHTTPRequest object was created.
transformNode
Transforms the specified Document with the specified XSL document.
Syntax
v = transformNode(
x, s, n, i, j, p, t
)
Parameters
- x as variant : XML Document to be transformed. If specified as a string, the string is used as a path to request the XML Document.
- s as Document : XSL Document to transform the XML Document. If specified as a string, the string is used as a path to request the XSL Document.
- n as DOMNode (optional): DOMNode to transform.
- i as String (optional): Identifier used when requesting the XML Document.
- j as String (optional): Identifier used when requesting the XSL Document.
- p as boolean (optional): Bit indicating whether a request for the XSL Document should be cached.
- t as boolean (optional): Bit indicating whether the transformation should expect a type text/plain as a result.
Returns
v as variant: Depending on the type of copy operation, returns a reference to the newly created node.
Messages
onloadxml
Message published to all subscribers when an xml request has completed loading. This message is published for text and JSON requests made through the XML request.
Syntax
// User-specified script to subscribe to message
org.cote.js.message.MessageService.subscribe("onloadxml",_handle_message);
// Internal: how the message is published to subscribers
org.cote.js.message.MessageService.publish("onloadxml"
, oXml
);
// User-specified script to handle the message subscription
function _handle_message("onloadxml"
, oXml
){
// message handler code
}
Parameters
- oXml as XmlObject : The Hemi.xml object representing the request.
[ Hemi JavaScript Framework - Stephen W. Cote, 2002 - 2009. ]