Namespace Sarissa
Defined in: sarissa.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Sarissa is a utility class. |
Field Attributes | Field Name and Description |
---|---|
<static> |
Sarissa.tableDataCache
Used for caching table data.
|
<static> |
Sarissa.tableDataCacheMaxSize
The table data cache size, used for sorting HTML tables.
|
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. |
Sarissa is a utility class. Provides "static" methods for DOMDocument, DOM Node serialization to XML strings and other utility goodies.
Defined in: sarissa-table-utils.js.
Defined in: sarissa-table-utils.js.
Deletes all child nodes of the given node
- Parameters:
- {DOMNode} oNode
- the Node to empty
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
- Parameters:
- {String} sXml
- the string to escape
- Parameters:
- {HTMLFormElement} oForm
- the form to construct the query string from
Defined in: sarissa-table-utils.js.
- Parameters:
- oElem
- an HTML or XML table. The method works out of the box
for
table
,tbody
,thead
ortfooter
elements. For custom XML tables, thesRowName
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
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
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
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)
- 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
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
- Parameters:
- url
- callback
- callbackParam
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.
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
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
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
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
, andSarissa.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 isfalse
- {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
undefined
, null
or empty, it is returned as is.
- Parameters:
- {String} s
- the string to strip the tags from
- Parameters:
- {String} sXml
- the string to unescape
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 ascallback(oForm, oTargetElement, exception)
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
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 ascallback(sFromUrl, oTargetElement, oException)
- {boolean} skipCache
- (optional) whether to skip any cache
Defined in: sarissa-table-utils.js.
- Parameters:
- oElem
- an HTML or XML table. The method works out of the box
for
table
,tbody
,thead
ortfooter
elements. For custom XML tables, thesRowName
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
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