Class Index | File Index

Classes


Namespace Sarissa


Defined in: sarissa.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 

Sarissa is a utility class.

Field Summary
Field Attributes Field Name and Description
<static>  
Sarissa.tableDataCache
Used for caching table data.
<static>  
The table data cache size, used for sorting HTML tables.
Method Summary
Method Attributes Method Name and Description
<static>  
Sarissa.clearChildNodes(oNode)

Deletes all child nodes of the given node

<static>  
Sarissa.copyChildNodes(nodeFrom, nodeTo, bPreserveExisting)

Copies the childNodes of nodeFrom to nodeTo

Note: The second object's original content is deleted before the copy operation, unless you supply a true third parameter

<static>  
Sarissa.escape(sXml)
Escape the given string chacters that correspond to the five predefined XML entities
<static>  
Sarissa.formToQueryString(oForm)
Creates an HTTP URL query string from the given HTML form data
<static>  
Sarissa.getArrayFromTableData(oElem, sRowName, sCellName, sHeadingName, bStripTags)
Get the data of the given element as a two-dimensional array.
<static>  
Sarissa.getDomDocument(sUri, sUri)

Factory method to obtain a new DOM Document object

<static>  
Sarissa.getFunctionName(oFunc)
Get the name of a function created like:
function functionName(){}
If a name is not found, attach the function to the window object with a new name and return that
<static>  
Sarissa.getParseErrorText(oDoc)

Returns a human readable description of the parsing error.

<static>  
Sarissa.getText(oNode, deep)
Get a string with the concatenated values of all string nodes under the given node
<static>  
Sarissa.moveChildNodes(nodeFrom, nodeTo, bPreserveExisting)

Moves the childNodes of nodeFrom to nodeTo

Note: The second object's original content is deleted before the move operation, unless you supply a true third parameter

<static>  
Sarissa.setRemoteJsonCallback(url, callback, callbackParam)
<static>  
Sarissa.setXpathNamespaces(oDoc, sNsSet)

Programmatically control namespace URI/prefix mappings for XPath queries.

<static>  
Sarissa.SORT_DATE_EU(a, b)
Function for comparing EU dates.
<static>  
Sarissa.SORT_DATE_US(a, b)
Function for comparing US dates.
<static>  
Sarissa.SORT_IGNORE_CASE(a, b)
Function for case-insensitive sorting or simple comparison.
<static>  
Sarissa.sortHtmlTableData(clickedElem, iFunc, bSkipCache, oCallbac)
Sort the table data based on the column corresponding to the given TH element (clickedElem).
<static>  
Sarissa.stripTags(s)
Strips tags from the given markup string.
<static>  
Sarissa.unescape(sXml)
Unescape the given string.
<static>  
Sarissa.updateContentFromForm(oForm, oTargetElement, xsltproc, callback)
Asynchronously update an element with response of an XMLHttpRequest-based emulation of a form submission.
<static>  
Sarissa.updateContentFromNode(oNode, oTargetElement, xsltproc)
Update an element's content with the given DOM node.
<static>  
Sarissa.updateContentFromURI(sFromUrl, oTargetElement, xsltproc, callback, skipCache)
Asynchronously update an element with response of a GET request on the given URL.
<static>  
Sarissa.updateTableData(oElem, sRowName, sCellName, sHeadingName, sHeadingName)
Update the data of the given element using the giventwo-dimensional array as a source.
<static>  
Sarissa.xmlize(anyObject, objectName, indentSpace, skipEscape)

Serialize any non DOM object to an XML string.

Namespace Detail
Sarissa

Sarissa is a utility class. Provides "static" methods for DOMDocument, DOM Node serialization to XML strings and other utility goodies.

Field Detail
<static> Sarissa.tableDataCache
Used for caching table data.
Defined in: sarissa-table-utils.js.

<static> Sarissa.tableDataCacheMaxSize
The table data cache size, used for sorting HTML tables. You can change it, default is 5 (tables). When a table is cached exceeding the cache size, the oldest entry is disgarded from the cache.
Defined in: sarissa-table-utils.js.
Method Detail
<static> Sarissa.clearChildNodes(oNode)

Deletes all child nodes of the given node

Parameters:
{DOMNode} oNode
the Node to empty

<static> Sarissa.copyChildNodes(nodeFrom, nodeTo, bPreserveExisting)

Copies the childNodes of nodeFrom to nodeTo

Note: The second object's original content is deleted before the copy operation, unless you supply a true third parameter

Parameters:
{DOMNode} nodeFrom
the Node to copy the childNodes from
{DOMNode} nodeTo
the Node to copy the childNodes to
{boolean} bPreserveExisting
whether to preserve the original content of nodeTo, default is false

<static> Sarissa.escape(sXml)
Escape the given string chacters that correspond to the five predefined XML entities
Parameters:
{String} sXml
the string to escape

<static> Sarissa.formToQueryString(oForm)
Creates an HTTP URL query string from the given HTML form data
Parameters:
{HTMLFormElement} oForm
the form to construct the query string from

<static> Sarissa.getArrayFromTableData(oElem, sRowName, sCellName, sHeadingName, bStripTags)
Get the data of the given element as a two-dimensional array. The given XML or HTML Element must match the structure of an HTML table, although element names may be different.
Defined in: sarissa-table-utils.js.
Parameters:
oElem
an HTML or XML table. The method works out of the box for table, tbody, thead or tfooter elements. For custom XML tables, the sRowName sCellName must be used.
sRowName
the row element names. Default is tr
sCellName
the row element names. Default is td
sHeadingName
the heading element names. If you use this, rows with headings will be skipped. To skip headings when reading HTML tables use th
bStripTags
whether to strip markup from cell contents. Default is false
Returns:
a two-dimensional array with the data found in the given element's rows

<static> {DOMDOcument} Sarissa.getDomDocument(sUri, sUri)

Factory method to obtain a new DOM Document object

Parameters:
{String} sUri
the namespace of the root node (if any)
{String} sUri
the local name of the root node (if any)
Returns:
{DOMDOcument} a new DOM Document

<static> Sarissa.getFunctionName(oFunc)
Get the name of a function created like:
function functionName(){}
If a name is not found, attach the function to the window object with a new name and return that
Parameters:
{Function} oFunc
the function object

<static> {String} Sarissa.getParseErrorText(oDoc)

Returns a human readable description of the parsing error. Usefull for debugging. Tip: append the returned error string in a <pre> element if you want to render it.

Many thanks to Christian Stocker for the initial patch.

Parameters:
{DOMDocument} oDoc
The target DOM document
Returns:
{String} The parsing error description of the target Document in human readable form (preformated text)

<static> Sarissa.getText(oNode, deep)
Get a string with the concatenated values of all string nodes under the given node
Parameters:
{DOMNode} oNode
the given DOM node
{boolean} deep
whether to recursively scan the children nodes of the given node for text as well. Default is false

<static> Sarissa.moveChildNodes(nodeFrom, nodeTo, bPreserveExisting)

Moves the childNodes of nodeFrom to nodeTo

Note: The second object's original content is deleted before the move operation, unless you supply a true third parameter

Parameters:
{DOMNode} nodeFrom
the Node to copy the childNodes from
{DOMNode} nodeTo
the Node to copy the childNodes to
{boolean} bPreserveExisting
whether to preserve the original content of nodeTo, default is

<static> Sarissa.setRemoteJsonCallback(url, callback, callbackParam)
Parameters:
url
callback
callbackParam

<static> Sarissa.setXpathNamespaces(oDoc, sNsSet)

Programmatically control namespace URI/prefix mappings for XPath queries.

This method comes especially handy when used to apply XPath queries on XML documents with a default namespace, as there is no other way of mapping that to a prefix.

Using no namespace prefix in DOM Level 3 XPath queries, implies you are looking for elements in the null namespace. If you need to look for nodes in the default namespace, you need to map a prefix to it first like:

Sarissa.setXpathNamespaces(oDoc, "xmlns:myprefix'http://mynsURI'");

Note 1 : Use this method only if the source document features a default namespace (without a prefix) or contains namespace declarations with a scope that does not cover the entire document (i.e. declared but not within the root element node). Otherwise just use IE's setProperty. You will need to map that namespace to a prefix for queries to work. Moz/FF will resolve non-default namespaces automatically if those are declared in the root element.

Note 2 : This method calls IE's setProperty method to set the appropriate namespace-prefix mappings, so you dont have to do that.


Defined in: sarissa_ieemu_xpath.js.
Parameters:
oDoc
The target XMLDocument to set the namespace mappings for.
sNsSet
A whilespace-seperated list of namespace declarations as those would appear in an XML document. E.g.: "xmlns:xhtml='http://www.w3.org/1999/xhtml' xmlns:'http://www.w3.org/1999/XSL/Transform'"
Throws:
An error if the format of the given namespace declarations is bad.

<static> Sarissa.SORT_DATE_EU(a, b)
Function for comparing EU dates. Can be used as a parameter to Array.sort().
Defined in: sarissa-table-utils.js.
Parameters:
a
a string
b
a string
Returns:
-1, 0 or 1 depending on whether a is "less than", equal or "greater than" b

<static> Sarissa.SORT_DATE_US(a, b)
Function for comparing US dates. Can be used as a parameter to Array.sort().
Defined in: sarissa-table-utils.js.
Parameters:
a
a string
b
a string
Returns:
-1, 0 or 1 depending on whether a is "less than", equal or "greater than" b

<static> Sarissa.SORT_IGNORE_CASE(a, b)
Function for case-insensitive sorting or simple comparison. Can be used as a parameter to Array.sort().
Defined in: sarissa-table-utils.js.
Parameters:
a
a string
b
a string
Returns:
-1, 0 or 1 depending on whether a is "less than", equal or "greater than" b

<static> Sarissa.sortHtmlTableData(clickedElem, iFunc, bSkipCache, oCallbac)
Sort the table data based on the column corresponding to the given TH element (clickedElem).
Defined in: sarissa-table-utils.js.
Parameters:
{Node} clickedElem
the table heading (th) initiating the sort.
{Function} iFunc
the custom sort function if needed. Default (null) is case-sensitive sort. You can also use Sarissa.SORT_IGNORE_CASE, Sarissa.SORT_DATE_US, and Sarissa.SORT_DATE_EU
{boolean} bSkipCache
whether to skip the data cache and read table data all over again. Setting this to true means the cache for the table, if it exists, will not be updated either. Defaul is false
{Function} oCallbac
a callback function to be executed when the table is sorted and updated. The callback function may be used for effects for example. The parameters passed to the callback are the table as a DOM node and the sort column index (zero based int)
Requires:
Sarissa sarissa.js

<static> Sarissa.stripTags(s)
Strips tags from the given markup string. If the given string is undefined, null or empty, it is returned as is.
Parameters:
{String} s
the string to strip the tags from

<static> Sarissa.unescape(sXml)
Unescape the given string. This turns the occurences of the predefined XML entities to become the characters they represent correspond to the five predefined XML entities
Parameters:
{String} sXml
the string to unescape

<static> Sarissa.updateContentFromForm(oForm, oTargetElement, xsltproc, callback)
Asynchronously update an element with response of an XMLHttpRequest-based emulation of a form submission.

The form action and method attributess will be followed. Passing a configured XSLT processor will result in transforming and updating the server response before using it to update the target element. You can also pass a callback function to be executed when the update is finished. The function will be called as functionName(oNode, oTargetElement);

Here is an example of using this in a form element:

<div id="targetId"> this content will be updated</div>
<form action="/my/form/handler" method="post" 
    onbeforesubmit="return Sarissa.updateContentFromForm(this, document.getElementById('targetId'));">

If JavaScript is supported, the form will not be submitted. Instead, Sarissa will scan the form and make an appropriate AJAX request, also adding a parameter to signal to the server that this is an AJAX call. The parameter is constructed as Sarissa.REMOTE_CALL_FLAG = "=true" so you can change the name in your webpage simply by assigning another value to Sarissa.REMOTE_CALL_FLAG. If JavaScript is not supported the form will be submitted normally.

Parameters:
{HTMLFormElement} oForm
the form submition to emulate
{DOMElement} oTargetElement
the element to update
{XSLTProcessor} xsltproc
(optional) the transformer to use on the returned content before updating the target element with it
{Function} callback
(optional) a Function object to execute once the update is finished successfuly, called as callback(oNode, oTargetElement). In case an exception occurs during excecution and a callback function was provided, the exception is cought and the callback is called as callback(oForm, oTargetElement, exception)

<static> Sarissa.updateContentFromNode(oNode, oTargetElement, xsltproc)
Update an element's content with the given DOM node. Passing a configured XSLT processor will result in transforming and updating oNode before using it to update oTargetElement. You can also pass a callback function to be executed when the update is finished. The function will be called as functionName(oNode, oTargetElement);
Parameters:
{DOMNode} oNode
the URL to make the request to
{DOMElement} oTargetElement
the element to update
{XSLTProcessor} xsltproc
(optional) the transformer to use on the given DOM node before updating the target element with it

<static> Sarissa.updateContentFromURI(sFromUrl, oTargetElement, xsltproc, callback, skipCache)
Asynchronously update an element with response of a GET request on the given URL. Passing a configured XSLT processor will result in transforming and updating oNode before using it to update oTargetElement. You can also pass a callback function to be executed when the update is finished. The function will be called as functionName(oNode, oTargetElement);
Parameters:
{String} sFromUrl
the URL to make the request to
{DOMElement} oTargetElement
the element to update
{XSLTProcessor} xsltproc
(optional) the transformer to use on the returned content before updating the target element with it
{Function} callback
(optional) a Function object to execute once the update is finished successfuly, called as callback(sFromUrl, oTargetElement). In case an exception is thrown during execution, the callback is called as called as callback(sFromUrl, oTargetElement, oException)
{boolean} skipCache
(optional) whether to skip any cache

<static> Sarissa.updateTableData(oElem, sRowName, sCellName, sHeadingName, sHeadingName)
Update the data of the given element using the giventwo-dimensional array as a source. The given XML or HTML Element must match the structure of an HTML table.
Defined in: sarissa-table-utils.js.
Parameters:
oElem
an HTML or XML table. The method works out of the box for table, tbody, thead or tfooter elements. For custom XML tables, the sRowName sCellName must be used.
sRowName
the row element names. Default is tr
sCellName
the row element names. Default is td
sHeadingName
the heading element names. If you use this, rows with headings will be skipped. To skip headings when reading HTML tables use th
sHeadingName

<static> {String} Sarissa.xmlize(anyObject, objectName, indentSpace, skipEscape)

Serialize any non DOM object to an XML string. All properties are serialized using the property name as the XML element name. Array elements are rendered as array-item elements, using their index/key as the value of the key attribute.

Parameters:
{Object} anyObject
the object to serialize
{String} objectName
a name for that object, to be used as the root element name
{String} indentSpace
Optional, the indentation space to use, default is an empty string. A single space character is added in any recursive call.
{noolean} skipEscape
Optional, whether to skip escaping characters that map to the five predefined XML entities. Default is false.
Returns:
{String} the XML serialization of the given object as a string

Documentation generated by JsDoc Toolkit 2.0.0 on Thu Jun 08 2017 12:20:08 GMT+0300 (EEST)