You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ko...@apache.org on 2014/08/18 15:49:53 UTC
[2/2] git commit: [OLINGO-408] add more comments
[OLINGO-408] add more comments
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/commit/24598e5f
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/tree/24598e5f
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/diff/24598e5f
Branch: refs/heads/master
Commit: 24598e5f9cab6d366d190530372eb20cb48a0d55
Parents: b59d0b2
Author: Sven Kobler <sv...@sap.com>
Authored: Mon Aug 18 15:49:38 2014 +0200
Committer: Sven Kobler <sv...@sap.com>
Committed: Mon Aug 18 15:49:38 2014 +0200
----------------------------------------------------------------------
datajs/demo/scripts/.gitignore | 1 +
datajs/src/lib/cache.js | 17 ++-
datajs/src/lib/cache/source.js | 6 +-
datajs/src/lib/datajs.js | 1 +
datajs/src/lib/datajs/deferred.js | 10 +-
datajs/src/lib/datajs/utils.js | 57 +++----
datajs/src/lib/datajs/xml.js | 165 ++++++++++-----------
datajs/src/lib/odata.js | 7 +-
datajs/src/lib/odata/batch.js | 85 +++++------
datajs/src/lib/odata/handler.js | 64 ++++----
datajs/src/lib/odata/json.js | 128 ++++++++--------
datajs/src/lib/odata/metadata.js | 32 ++--
datajs/src/lib/odata/net.js | 41 +++---
datajs/src/lib/odata/utils.js | 204 +++++++++++++-------------
datajs/src/lib/store.js | 19 ++-
datajs/src/lib/store/dom.js | 6 +-
datajs/src/lib/store/indexeddb.js | 5 +-
datajs/src/lib/store/memory.js | 5 +-
datajs/tests/odata-json-parse-tests.html | 1 +
datajs/tests/odata-json-parse-tests.js | 12 +-
20 files changed, 459 insertions(+), 407 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/demo/scripts/.gitignore
----------------------------------------------------------------------
diff --git a/datajs/demo/scripts/.gitignore b/datajs/demo/scripts/.gitignore
index 863d40c..f7f55d4 100644
--- a/datajs/demo/scripts/.gitignore
+++ b/datajs/demo/scripts/.gitignore
@@ -1 +1,2 @@
datajs-2*
+tmp/
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/cache.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/cache.js b/datajs/src/lib/cache.js
index 68c571c..4afc5cc 100644
--- a/datajs/src/lib/cache.js
+++ b/datajs/src/lib/cache.js
@@ -43,11 +43,7 @@ var getJsonValueArraryLength = utils.getJsonValueArraryLength;
var sliceJsonValueArray = utils.sliceJsonValueArray;
var concatJsonValueArray = utils.concatJsonValueArray;
-/** estimateSize (see {@link estimateSize}) */
-exports.estimateSize = estimateSize;
-/** createDataCache */
-exports.createDataCache = createDataCache;
/** Appends a page's data to the operation data.
* @param {Object} operation - Operation with (i)ndex, (c)ount and (d)ata.
@@ -363,17 +359,21 @@ function DataCacheOperation(stateMachine, promise, isCancelable, index, count, d
}
};
+
+
/** Transitions this operation to a new state.
* @method DataCacheOperation#transition
* @param {Object} state - State to transition the operation to.
* @param {Object} [data] -
*/
- that.transition = function (state, data) {
+ var transition = function (state, data) {
that.s = state;
stateData = data;
operationStateMachine(state, cacheState, data);
};
-
+
+ that.transition = transition;
+
return that;
}
@@ -1436,3 +1436,8 @@ function createDataCache (options) {
};
+/** estimateSize (see {@link estimateSize}) */
+exports.estimateSize = estimateSize;
+
+/** createDataCache */
+exports.createDataCache = createDataCache;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/cache/source.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/cache/source.js b/datajs/src/lib/cache/source.js
index 34780ff..edc41b2 100644
--- a/datajs/src/lib/cache/source.js
+++ b/datajs/src/lib/cache/source.js
@@ -25,8 +25,7 @@ var odataRequest = require("./../odata.js");
var parseInt10 = utils.parseInt10;
var normalizeURICase = utils.normalizeURICase;
-/** ODataCacheSource (see {@link ODataCacheSource}) */
-exports.ODataCacheSource = ODataCacheSource;
+
/** Appends the specified escaped query option to the specified URI.
@@ -202,3 +201,6 @@ function ODataCacheSource (options) {
}
+
+/** ODataCacheSource (see {@link ODataCacheSource}) */
+exports.ODataCacheSource = ODataCacheSource;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/datajs.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/datajs.js b/datajs/src/lib/datajs.js
index 6803f5f..3c1e67a 100644
--- a/datajs/src/lib/datajs.js
+++ b/datajs/src/lib/datajs.js
@@ -17,6 +17,7 @@
* under the License.
*/
+/** @module datajs */
//expose all external usable functions via self.apiFunc = function
exports.version = {
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/datajs/deferred.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/datajs/deferred.js b/datajs/src/lib/datajs/deferred.js
index ac06820..7d5fd68 100644
--- a/datajs/src/lib/datajs/deferred.js
+++ b/datajs/src/lib/datajs/deferred.js
@@ -19,11 +19,7 @@
/** @module datajs/deferred */
-/** createDeferred (see {@link createDeferred}) */
-exports.createDeferred = createDeferred;
-/** DjsDeferred (see {@link DjsDeferred}) */
-exports.DjsDeferred = DjsDeferred;
/** Creates a new function to forward a call.
* @param {Object} thisValue - Value to use as the 'this' object.
@@ -185,3 +181,9 @@ function createDeferred() {
+
+/** createDeferred (see {@link module:datajs/deferred~createDeferred}) */
+exports.createDeferred = createDeferred;
+
+/** DjsDeferred (see {@link DjsDeferred}) */
+exports.DjsDeferred = DjsDeferred;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/datajs/utils.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/datajs/utils.js b/datajs/src/lib/datajs/utils.js
index cf586db..5d33207 100644
--- a/datajs/src/lib/datajs/utils.js
+++ b/datajs/src/lib/datajs/utils.js
@@ -19,33 +19,6 @@
/** @module datajs/utils */
-exports.activeXObject = activeXObject;
-exports.assigned = assigned;
-exports.contains = contains;
-exports.defined = defined;
-exports.delay = delay;
-exports.djsassert = djsassert;
-exports.extend = extend;
-exports.find = find;
-exports.getURIInfo = getURIInfo;
-exports.isArray = isArray;
-exports.isDate = isDate;
-exports.isObject = isObject;
-exports.normalizeURI = normalizeURI;
-exports.normalizeURICase = normalizeURICase;
-exports.parseInt10 = parseInt10;
-exports.renameProperty = renameProperty;
-exports.throwErrorCallback = throwErrorCallback;
-exports.trimString = trimString;
-exports.undefinedDefault = undefinedDefault;
-exports.decodeBase64 = decodeBase64;
-exports.convertByteArrayToHexString = convertByteArrayToHexString;
-exports.getJsonValueArraryLength = getJsonValueArraryLength;
-exports.sliceJsonValueArray = sliceJsonValueArray;
-exports.concatJsonValueArray = concatJsonValueArray;
-exports.startsWith = startsWith;
-exports.endsWith = endsWith;
-exports.getFormatKind = getFormatKind;
/** Creates a new ActiveXObject from the given progId.
@@ -574,4 +547,32 @@ function getFormatKind(format, defaultFormatKind) {
}
-
\ No newline at end of file
+
+
+exports.activeXObject = activeXObject;
+exports.assigned = assigned;
+exports.contains = contains;
+exports.defined = defined;
+exports.delay = delay;
+exports.djsassert = djsassert;
+exports.extend = extend;
+exports.find = find;
+exports.getURIInfo = getURIInfo;
+exports.isArray = isArray;
+exports.isDate = isDate;
+exports.isObject = isObject;
+exports.normalizeURI = normalizeURI;
+exports.normalizeURICase = normalizeURICase;
+exports.parseInt10 = parseInt10;
+exports.renameProperty = renameProperty;
+exports.throwErrorCallback = throwErrorCallback;
+exports.trimString = trimString;
+exports.undefinedDefault = undefinedDefault;
+exports.decodeBase64 = decodeBase64;
+exports.convertByteArrayToHexString = convertByteArrayToHexString;
+exports.getJsonValueArraryLength = getJsonValueArraryLength;
+exports.sliceJsonValueArray = sliceJsonValueArray;
+exports.concatJsonValueArray = concatJsonValueArray;
+exports.startsWith = startsWith;
+exports.endsWith = endsWith;
+exports.getFormatKind = getFormatKind;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/datajs/xml.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/datajs/xml.js b/datajs/src/lib/datajs/xml.js
index 16e505f..b8af4fe 100644
--- a/datajs/src/lib/datajs/xml.js
+++ b/datajs/src/lib/datajs/xml.js
@@ -17,6 +17,9 @@
* under the License.
*/
+
+/** @module datajs/xml */
+
var utils = require('./utils.js');
var activeXObject = utils.activeXObject;
@@ -39,27 +42,27 @@ var mozillaParserErroNS = http + "www.mozilla.org/newlayout/xml/parsererror.xml"
* @param {String} text - String to check.
* @returns {Boolean} true if text has any leading or trailing whitespace; false otherwise.
*/
-var hasLeadingOrTrailingWhitespace = function (text) {
+function hasLeadingOrTrailingWhitespace(text) {
var re = /(^\s)|(\s$)/;
return re.test(text);
-};
+}
/** Determines whether the specified text is empty or whitespace.
* @param {String} text - Value to inspect.
* @returns {Boolean} true if the text value is empty or all whitespace; false otherwise.
*/
-var isWhitespace = function (text) {
+function isWhitespace(text) {
var ws = /^\s*$/;
return text === null || ws.test(text);
-};
+}
/** Determines whether the specified element has xml:space='preserve' applied.
* @param domElement - Element to inspect.
* @returns {Boolean} Whether xml:space='preserve' is in effect.
*/
-var isWhitespacePreserveContext = function (domElement) {
+function isWhitespacePreserveContext(domElement) {
while (domElement !== null && domElement.nodeType === 1) {
@@ -74,36 +77,36 @@ var isWhitespacePreserveContext = function (domElement) {
}
return false;
-};
+}
/** Determines whether the attribute is a XML namespace declaration.
* @param domAttribute - Element to inspect.
* @return {Boolean} True if the attribute is a namespace declaration (its name is 'xmlns' or starts with 'xmlns:'; false otherwise.
*/
-var isXmlNSDeclaration = function (domAttribute) {
+function isXmlNSDeclaration(domAttribute) {
var nodeName = domAttribute.nodeName;
return nodeName == "xmlns" || nodeName.indexOf("xmlns:") === 0;
-};
+}
/** Safely set as property in an object by invoking obj.setProperty.
* @param obj - Object that exposes a setProperty method.
* @param {String} name - Property name
* @param value - Property value.
*/
-var safeSetProperty = function (obj, name, value) {
+function safeSetProperty(obj, name, value) {
try {
obj.setProperty(name, value);
} catch (_) { }
-};
+}
/** Creates an configures new MSXML 3.0 ActiveX object.
* @returns {Object} New MSXML 3.0 ActiveX object.
* This function throws any exception that occurs during the creation
* of the MSXML 3.0 ActiveX object.
*/
-var msXmlDom3 = function () {
+function msXmlDom3() {
var msxml3 = activeXObject("Msxml2.DOMDocument.3.0");
if (msxml3) {
safeSetProperty(msxml3, "ProhibitDTD", true);
@@ -112,7 +115,7 @@ var msXmlDom3 = function () {
safeSetProperty(msxml3, "AllowXsltScript", false);
}
return msxml3;
-};
+}
/** Creates an configures new MSXML 6.0 or MSXML 3.0 ActiveX object.
* @returns {Object} New MSXML 3.0 ActiveX object.
@@ -121,7 +124,7 @@ var msXmlDom3 = function () {
* happens during the creation of the MSXML 6.0 will be handled by the function while
* the ones that happend during the creation of the MSXML 3.0 will be thrown.
*/
-var msXmlDom = function () {
+function msXmlDom() {
try {
var msxml = activeXObject("Msxml2.DOMDocument.6.0");
if (msxml) {
@@ -131,7 +134,7 @@ var msXmlDom = function () {
} catch (_) {
return msXmlDom3();
}
-};
+}
/** Parses an XML string using the MSXML DOM.
* @returns {Object} New MSXML DOMDocument node representing the parsed XML string.
@@ -139,7 +142,7 @@ var msXmlDom = function () {
* of the MSXML ActiveX object. It also will throw an exception
* in case of a parsing error.
*/
-var msXmlParse = function (text) {
+function msXmlParse(text) {
var dom = msXmlDom();
if (!dom) {
return null;
@@ -151,27 +154,27 @@ var msXmlParse = function (text) {
xmlThrowParserError(parseError.reason, parseError.srcText, text);
}
return dom;
-};
+}
/** Throws a new exception containing XML parsing error information.
* @param exceptionOrReason - String indicating the reason of the parsing failure or Object detailing the parsing error.
* @param {String} srcText - String indicating the part of the XML string that caused the parsing error.
* @param {String} errorXmlText - XML string for wich the parsing failed.
*/
-var xmlThrowParserError = function (exceptionOrReason, srcText, errorXmlText) {
+function xmlThrowParserError(exceptionOrReason, srcText, errorXmlText) {
if (typeof exceptionOrReason === "string") {
exceptionOrReason = { message: exceptionOrReason };
}
throw extend(exceptionOrReason, { srcText: srcText || "", errorXmlText: errorXmlText || "" });
-};
+}
/** Returns an XML DOM document from the specified text.
* @param {String} text - Document text.
* @returns XML DOM document.
* This function will throw an exception in case of a parse error
*/
-var xmlParse = function (text) {
+function xmlParse(text) {
var domParser = window.DOMParser && new window.DOMParser();
var dom;
@@ -219,22 +222,22 @@ var xmlParse = function (text) {
}
return dom;
-};
+}
/** Builds a XML qualified name string in the form of "prefix:name".
* @param {String} prefix - Prefix string (may be null)
* @param {String} name - Name string to qualify with the prefix.
* @returns {String} Qualified name.
*/
-var xmlQualifiedName = function (prefix, name) {
+function xmlQualifiedName(prefix, name) {
return prefix ? prefix + ":" + name : name;
-};
+}
/** Appends a text node into the specified DOM element node.
* @param domNode - DOM node for the element.
* @param {String} text - Text to append as a child of element.
*/
-var xmlAppendText = function (domNode, textNode) {
+function xmlAppendText(domNode, textNode) {
if (hasLeadingOrTrailingWhitespace(textNode.data)) {
var attr = xmlAttributeNode(domNode, xmlNS, "space");
if (!attr) {
@@ -245,19 +248,19 @@ var xmlAppendText = function (domNode, textNode) {
}
domNode.appendChild(textNode);
return domNode;
-};
+}
/** Iterates through the XML element's attributes and invokes the callback function for each one.
* @param element - Wrapped element to iterate over.
* @param {Function} onAttributeCallback - Callback function to invoke with wrapped attribute nodes.
*/
-var xmlAttributes = function (element, onAttributeCallback) {
+function xmlAttributes(element, onAttributeCallback) {
var attributes = element.attributes;
var i, len;
for (i = 0, len = attributes.length; i < len; i++) {
onAttributeCallback(attributes.item(i));
}
-};
+}
/** Returns the value of a DOM element's attribute.
* @param domNode - DOM node for the owning element.
@@ -265,11 +268,11 @@ var xmlAttributes = function (element, onAttributeCallback) {
* @param {String} nsURI - Namespace URI of the attribute.
* @returns {String} - The attribute value, null if not found (may be null)
*/
-var xmlAttributeValue = function (domNode, localName, nsURI) {
+function xmlAttributeValue(domNode, localName, nsURI) {
var attribute = xmlAttributeNode(domNode, localName, nsURI);
return attribute ? xmlNodeValue(attribute) : null;
-};
+}
/** Gets an attribute node from a DOM element.
* @param domNode - DOM node for the owning element.
@@ -277,7 +280,7 @@ var xmlAttributeValue = function (domNode, localName, nsURI) {
* @param {String} nsURI - Namespace URI of the attribute.
* @returns The attribute node, null if not found.
*/
-var xmlAttributeNode = function (domNode, localName, nsURI) {
+function xmlAttributeNode(domNode, localName, nsURI) {
var attributes = domNode.attributes;
if (attributes.getNamedItemNS) {
@@ -285,25 +288,25 @@ var xmlAttributeNode = function (domNode, localName, nsURI) {
}
return attributes.getQualifiedItem(localName, nsURI) || null;
-};
+}
/** Gets the value of the xml:base attribute on the specified element.
* @param domNode - Element to get xml:base attribute value from.
* @param [baseURI] - Base URI used to normalize the value of the xml:base attribute ( may be null)
* @returns {String} Value of the xml:base attribute if found; the baseURI or null otherwise.
*/
-var xmlBaseURI = function (domNode, baseURI) {
+function xmlBaseURI(domNode, baseURI) {
var base = xmlAttributeNode(domNode, "base", xmlNS);
return (base ? normalizeURI(base.value, baseURI) : baseURI) || null;
-};
+}
/** Iterates through the XML element's child DOM elements and invokes the callback function for each one.
* @param element - DOM Node containing the DOM elements to iterate over.
* @param {Function} onElementCallback - Callback function to invoke for each child DOM element.
*/
-var xmlChildElements = function (domNode, onElementCallback) {
+function xmlChildElements(domNode, onElementCallback) {
xmlTraverse(domNode, /*recursive*/false, function (child) {
if (child.nodeType === 1) {
@@ -312,7 +315,7 @@ var xmlChildElements = function (domNode, onElementCallback) {
// continue traversing.
return true;
});
-};
+}
/** Gets the descendant element under root that corresponds to the specified path and namespace URI.
* @param root - DOM element node from which to get the descendant element.
@@ -322,14 +325,14 @@ var xmlChildElements = function (domNode, onElementCallback) {
* All the elements in the path are matched against namespaceURI.
* The function will stop searching on the first element that doesn't match the namespace and the path.
*/
-var xmlFindElementByPath = function (root, namespaceURI, path) {
+function xmlFindElementByPath(root, namespaceURI, path) {
var parts = path.split("/");
var i, len;
for (i = 0, len = parts.length; i < len; i++) {
root = root && xmlFirstChildElement(root, namespaceURI, parts[i]);
}
return root || null;
-};
+}
/** Gets the DOM element or DOM attribute node under root that corresponds to the specified path and namespace URI.
* @param root - DOM element node from which to get the descendant node.
@@ -341,7 +344,7 @@ var xmlFindElementByPath = function (root, namespaceURI, path) {
* The traversal stops when the whole path has been exahusted or a node that doesn't belogong the specified namespace is encountered.
* The last segment of the path may be decorated with a starting @ character to indicate that the desired node is a DOM attribute.
*/
-var xmlFindNodeByPath = function (root, namespaceURI, path) {
+function xmlFindNodeByPath(root, namespaceURI, path) {
var lastSegmentStart = path.lastIndexOf("/");
@@ -356,7 +359,7 @@ var xmlFindNodeByPath = function (root, namespaceURI, path) {
return xmlFirstChildElement(node, namespaceURI, nodePath);
}
return null;
-};
+}
/** Returns the first child DOM element under the specified DOM node that matches the specified namespace URI and local name.
* @param domNode - DOM node from which the child DOM element is going to be retrieved.
@@ -364,10 +367,10 @@ var xmlFindNodeByPath = function (root, namespaceURI, path) {
* @param {String} [localName] -
* @return The node's first child DOM element that matches the specified namespace URI and local name; null otherwise.</returns>
*/
-var xmlFirstChildElement = function (domNode, namespaceURI, localName) {
+function xmlFirstChildElement(domNode, namespaceURI, localName) {
return xmlFirstElementMaybeRecursive(domNode, namespaceURI, localName, /*recursive*/false);
-};
+}
/** Returns the first descendant DOM element under the specified DOM node that matches the specified namespace URI and local name.
* @param domNode - DOM node from which the descendant DOM element is going to be retrieved.
@@ -375,13 +378,13 @@ var xmlFirstChildElement = function (domNode, namespaceURI, localName) {
* @param {String} [localName] -
* @return The node's first descendant DOM element that matches the specified namespace URI and local name; null otherwise.
*/
-var xmlFirstDescendantElement = function (domNode, namespaceURI, localName) {
+function xmlFirstDescendantElement(domNode, namespaceURI, localName) {
if (domNode.getElementsByTagNameNS) {
var result = domNode.getElementsByTagNameNS(namespaceURI, localName);
return result.length > 0 ? result[0] : null;
}
return xmlFirstElementMaybeRecursive(domNode, namespaceURI, localName, /*recursive*/true);
-};
+}
/** Returns the first descendant DOM element under the specified DOM node that matches the specified namespace URI and local name.
* @param domNode - DOM node from which the descendant DOM element is going to be retrieved.
@@ -392,7 +395,7 @@ var xmlFirstDescendantElement = function (domNode, namespaceURI, localName) {
* - False if the search should be scoped only to the direct children of the DOM node.
* @return The node's first descendant DOM element that matches the specified namespace URI and local name; null otherwise.
*/
-var xmlFirstElementMaybeRecursive = function (domNode, namespaceURI, localName, recursive) {
+function xmlFirstElementMaybeRecursive(domNode, namespaceURI, localName, recursive) {
var firstElement = null;
xmlTraverse(domNode, recursive, function (child) {
@@ -407,13 +410,13 @@ var xmlFirstElementMaybeRecursive = function (domNode, namespaceURI, localName,
return firstElement === null;
});
return firstElement;
-};
+}
/** Gets the concatenated value of all immediate child text and CDATA nodes for the specified element.
* @param domElement - Element to get values for.
* @returns {String} Text for all direct children.
*/
-var xmlInnerText = function (xmlElement) {
+function xmlInnerText(xmlElement) {
var result = null;
var root = (xmlElement.nodeType === 9 && xmlElement.documentElement) ? xmlElement.documentElement : xmlElement;
@@ -454,37 +457,37 @@ var xmlInnerText = function (xmlElement) {
return true;
});
return result;
-};
+}
/** Returns the localName of a XML node.
* @param domNode - DOM node to get the value from.
* @returns {String} localName of domNode.
*/
-var xmlLocalName = function (domNode) {
+function xmlLocalName(domNode) {
return domNode.localName || domNode.baseName;
-};
+}
/** Returns the namespace URI of a XML node.
* @param node - DOM node to get the value from.
* @returns {String} Namespace URI of domNode.
*/
-var xmlNamespaceURI = function (domNode) {
+function xmlNamespaceURI(domNode) {
return domNode.namespaceURI || null;
-};
+}
/** Returns the value or the inner text of a XML node.
* @param node - DOM node to get the value from.
* @return Value of the domNode or the inner text if domNode represents a DOM element node.
*/
-var xmlNodeValue = function (domNode) {
+function xmlNodeValue(domNode) {
if (domNode.nodeType === 1) {
return xmlInnerText(domNode);
}
return domNode.nodeValue;
-};
+}
/** Walks through the descendants of the domNode and invokes a callback for each node.
* @param domNode - DOM node whose descendants are going to be traversed.
@@ -493,7 +496,7 @@ var xmlNodeValue = function (domNode) {
* - False if the traversal should be scoped only to the direct children of the DOM node.
* @returns {String} Namespace URI of node.
*/
-var xmlTraverse = function (domNode, recursive, onChildCallback) {
+function xmlTraverse(domNode, recursive, onChildCallback) {
var subtrees = [];
var child = domNode.firstChild;
@@ -507,7 +510,7 @@ var xmlTraverse = function (domNode, recursive, onChildCallback) {
child = child.nextSibling || subtrees.shift();
}
}
-};
+}
/** Returns the next sibling DOM element of the specified DOM node.
* @param domNode - DOM node from which the next sibling is going to be retrieved.
@@ -515,7 +518,7 @@ var xmlTraverse = function (domNode, recursive, onChildCallback) {
* @param {String} [localName] -
* @return The node's next sibling DOM element, null if there is none.</returns>
*/
-var xmlSiblingElement = function (domNode, namespaceURI, localName) {
+function xmlSiblingElement(domNode, namespaceURI, localName) {
var sibling = domNode.nextSibling;
while (sibling) {
@@ -530,7 +533,7 @@ var xmlSiblingElement = function (domNode, namespaceURI, localName) {
sibling = sibling.nextSibling;
}
return null;
-};
+}
/** Creates a new empty DOM document node.
* @return New DOM document node.</returns>
@@ -542,14 +545,12 @@ var xmlSiblingElement = function (domNode, namespaceURI, localName) {
* for creating an MXSML 3.0 DOM will be made. If this last attemp fails or
* the browser doesn't support ActiveXObject then an exception will be thrown.
*/
-var xmlDom = function () {
-
-
+function xmlDom() {
var implementation = window.document.implementation;
return (implementation && implementation.createDocument) ?
implementation.createDocument(null, null, null) :
msXmlDom();
-};
+}
/** Appends a collection of child nodes or string values to a parent DOM node.
* @param parent - DOM node to which the children will be appended.
@@ -558,7 +559,7 @@ var xmlDom = function () {
* If a value in the children collection is a string, then a new DOM text node is going to be created
* for it and then appended to the parent.
*/
-var xmlAppendChildren = function (parent, children) {
+function xmlAppendChildren(parent, children) {
if (!isArray(children)) {
return xmlAppendChild(parent, children);
}
@@ -568,7 +569,7 @@ var xmlAppendChildren = function (parent, children) {
children[i] && xmlAppendChild(parent, children[i]);
}
return parent;
-};
+}
/** Appends a child node or a string value to a parent DOM node.
* @param parent - DOM node to which the child will be appended.
@@ -577,7 +578,7 @@ var xmlAppendChildren = function (parent, children) {
* If child is a string value, then a new DOM text node is going to be created
* for it and then appended to the parent.
*/
-var xmlAppendChild = function (parent, child) {
+function xmlAppendChild(parent, child) {
djsassert(parent !== child, "xmlAppendChild() - parent and child are one and the same!");
if (child) {
@@ -591,7 +592,7 @@ var xmlAppendChild = function (parent, child) {
}
}
return parent;
-};
+}
/** Creates a new DOM attribute node.
* @param dom - DOM document used to create the attribute.
@@ -599,7 +600,7 @@ var xmlAppendChild = function (parent, child) {
* @param {String} namespaceURI - Namespace URI.
* @return DOM attribute node for the namespace declaration.
*/
-var xmlNewAttribute = function (dom, namespaceURI, qualifiedName, value) {
+function xmlNewAttribute(dom, namespaceURI, qualifiedName, value) {
var attribute =
dom.createAttributeNS && dom.createAttributeNS(namespaceURI, qualifiedName) ||
@@ -607,7 +608,7 @@ var xmlNewAttribute = function (dom, namespaceURI, qualifiedName, value) {
attribute.value = value || "";
return attribute;
-};
+}
/** Creates a new DOM element node.
* @param dom - DOM document used to create the DOM element.
@@ -618,13 +619,13 @@ var xmlNewAttribute = function (dom, namespaceURI, qualifiedName, value) {
* If a value in the children collection is a string, then a new DOM text node is going to be created
* for it and then appended to the new DOM element.
*/
-var xmlNewElement = function (dom, nampespaceURI, qualifiedName, children) {
+function xmlNewElement(dom, nampespaceURI, qualifiedName, children) {
var element =
dom.createElementNS && dom.createElementNS(nampespaceURI, qualifiedName) ||
dom.createNode(1, qualifiedName, nampespaceURI || undefined);
return xmlAppendChildren(element, children || []);
-};
+}
/** Creates a namespace declaration attribute.
* @param dom - DOM document used to create the attribute.
@@ -632,16 +633,16 @@ var xmlNewElement = function (dom, nampespaceURI, qualifiedName, children) {
* @param {String} prefix - Namespace prefix.
* @return DOM attribute node for the namespace declaration.</returns>
*/
-var xmlNewNSDeclaration = function (dom, namespaceURI, prefix) {
+function xmlNewNSDeclaration(dom, namespaceURI, prefix) {
return xmlNewAttribute(dom, xmlnsNS, xmlQualifiedName("xmlns", prefix), namespaceURI);
-};
+}
/** Creates a new DOM document fragment node for the specified xml text.
* @param dom - DOM document from which the fragment node is going to be created.
* @param {String} text XML text to be represented by the XmlFragment.
* @return New DOM document fragment object.
*/
-var xmlNewFragment = function (dom, text) {
+function xmlNewFragment(dom, text) {
var value = "<c>" + text + "</c>";
var tempDom = xmlParse(value);
@@ -655,16 +656,16 @@ var xmlNewFragment = function (dom, text) {
importedChild = importedChild.nextSibling;
}
return fragment;
-};
+}
/** Creates new DOM text node.
* @param dom - DOM document used to create the text node.
* @param {String} text - Text value for the DOM text node.
* @return DOM text node.</returns>
*/
-var xmlNewText = function (dom, text) {
+function xmlNewText(dom, text) {
return dom.createTextNode(text);
-};
+}
/** Creates a new DOM element or DOM attribute node as specified by path and appends it to the DOM tree pointed by root.
* @param dom - DOM document used to create the new node.
@@ -679,7 +680,7 @@ var xmlNewText = function (dom, text) {
* The last segment of the path may be decorated with a starting @ character. In this case a new DOM attribute node
* will be created.
*/
-var xmlNewNodeByPath = function (dom, root, namespaceURI, prefix, path) {
+function xmlNewNodeByPath(dom, root, namespaceURI, prefix, path) {
var name = "";
var parts = path.split("/");
var xmlFindNode = xmlFirstChildElement;
@@ -703,13 +704,13 @@ var xmlNewNodeByPath = function (dom, root, namespaceURI, prefix, path) {
xmlNode = childNode;
}
return xmlNode;
-};
+}
/** Returns the text representation of the document to which the specified node belongs.
* @param root - Wrapped element in the document to serialize.
* @returns {String} Serialized document.
*/
-var xmlSerialize = function (domNode) {
+function xmlSerialize(domNode) {
var xmlSerializer = window.XMLSerializer;
if (xmlSerializer) {
var serializer = new xmlSerializer();
@@ -721,13 +722,13 @@ var xmlSerialize = function (domNode) {
}
throw { message: "XML serialization unsupported" };
-};
+}
/** Returns the XML representation of the all the descendants of the node.
* @param domNode - Node to serialize.</param>
* @returns {String} The XML representation of all the descendants of the node.
*/
-var xmlSerializeDescendants = function (domNode) {
+function xmlSerializeDescendants(domNode) {
var children = domNode.childNodes;
var i, len = children.length;
if (len === 0) {
@@ -758,13 +759,13 @@ var xmlSerializeDescendants = function (domNode) {
}
return xml;
-};
+}
/** Returns the XML representation of the node and all its descendants.
* @param domNode - Node to serialize
* @returns {String} The XML representation of the node and all its descendants.
*/
-var xmlSerializeNode = function (domNode) {
+function xmlSerializeNode(domNode) {
var xml = domNode.xml;
if (xml !== undefined) {
@@ -777,7 +778,7 @@ var xmlSerializeNode = function (domNode) {
}
throw { message: "XML serialization unsupported" };
-};
+}
exports.http = http;
exports.w3org = w3org;
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/odata.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/odata.js b/datajs/src/lib/odata.js
index 36343fb..d971025 100644
--- a/datajs/src/lib/odata.js
+++ b/datajs/src/lib/odata.js
@@ -17,6 +17,8 @@
* under the License.
*/
+ /** @module odata */
+
// Imports
var odataUtils = exports.utils = require('./odata/utils.js');
var odataHandler = exports.handler = require('./odata/handler.js');
@@ -25,7 +27,7 @@ var odataNet = exports.net = require('./odata/net.js');
var odataJson = exports.json = require('./odata/json.js');
exports.batch = require('./odata/batch.js');
-exports.metadataHandler = odataMetadata.metadataHandler;
+
var utils = require('./datajs/utils.js');
var assigned = utils.assigned;
@@ -47,7 +49,7 @@ var handlers = [odataJson.jsonHandler, odataHandler.textHandler];
* @param {Object} requestOrResponse - request/response argument for delegated call.
* @param {Object} context - context argument for delegated call.
*/
-var dispatchHandler = function (handlerMethod, requestOrResponse, context) {
+function dispatchHandler(handlerMethod, requestOrResponse, context) {
var i, len;
for (i = 0, len = handlers.length; i < len && !handlers[i][handlerMethod](requestOrResponse, context); i++) {
@@ -173,3 +175,4 @@ exports.parseMetadata = function (csdlMetadataDocument) {
// Configure the batch handler to use the default handler for the batch parts.
exports.batch.batchHandler.partHandler = exports.defaultHandler;
+exports.metadataHandler = odataMetadata.metadataHandler;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/odata/batch.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/odata/batch.js b/datajs/src/lib/odata/batch.js
index a6d850e..5b006ff 100644
--- a/datajs/src/lib/odata/batch.js
+++ b/datajs/src/lib/odata/batch.js
@@ -17,17 +17,12 @@
* under the License.
*/
-/* {
- oldname:'odata-batch.js',
- updated:'20140514 12:59'
-}*/
+/** @module odata/batch */
var utils = require('./../datajs.js').utils;
var odataUtils = require('./utils.js');
var odataHandler = require('./handler.js');
-// Imports
-
var extend = utils.extend;
var isArray = utils.isArray;
var trimString = utils.trimString;
@@ -40,6 +35,14 @@ var normalizeHeaders = odataUtils.normalizeHeaders;
//TODO var payloadTypeOf = odata.payloadTypeOf;
var prepareRequest = odataUtils.prepareRequest;
+
+
+
+
+// Imports
+
+
+
// CONTENT START
var batchMediaType = "multipart/mixed";
var responseStatusRegex = /^HTTP\/1\.\d (\d{3}) (.*)$/i;
@@ -48,37 +51,37 @@ var responseHeaderRegex = /^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/;
/* Calculates a random 16 bit number and returns it in hexadecimal format.
* @returns {String} A 16-bit number in hex format.
*/
-var hex16 = function () {
+function hex16() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substr(1);
-};
+}
/* Creates a string that can be used as a multipart request boundary.
* @param {String} [prefix] -
* @returns {String} Boundary string of the format: <prefix><hex16>-<hex16>-<hex16>
*/
-var createBoundary = function (prefix) {
+function createBoundary(prefix) {
return prefix + hex16() + "-" + hex16() + "-" + hex16();
-};
+}
/* Gets the handler for data serialization of individual requests / responses in a batch.
* @param context - Context used for data serialization.
* @returns Handler object
*/
-var partHandler = function (context) {
+function partHandler(context) {
return context.handler.partHandler;
-};
+}
/* Gets the current boundary used for parsing the body of a multipart response.
* @param context - Context used for parsing a multipart response.
* @returns {String} Boundary string.
*/
-var currentBoundary = function (context) {
+function currentBoundary(context) {
var boundaries = context.boundaries;
return boundaries[boundaries.length - 1];
-};
+}
/** Parses a batch response.
* @param handler - This handler.
@@ -86,11 +89,11 @@ var currentBoundary = function (context) {
* @param {Object} context - Object with parsing context.
* @return An object representation of the batch.
*/
-var batchParser = function (handler, text, context) {
+function batchParser(handler, text, context) {
var boundary = context.contentType.properties["boundary"];
return { __batchResponses: readBatch(text, { boundaries: [boundary], handlerContext: context }) };
-};
+}
/** Serializes a batch object representation into text.
* @param handler - This handler.
@@ -98,20 +101,20 @@ var batchParser = function (handler, text, context) {
* @param {Object} context - Object with parsing context.
* @return An text representation of the batch object; undefined if not applicable.#
*/
-var batchSerializer = function (handler, data, context) {
+function batchSerializer(handler, data, context) {
var cType = context.contentType = context.contentType || contentType(batchMediaType);
if (cType.mediaType === batchMediaType) {
return writeBatch(data, context);
}
-};
+}
/* Parses a multipart/mixed response body from from the position defined by the context.
* @param {String} text - Body of the multipart/mixed response.
* @param context - Context used for parsing.
* @return Array of objects representing the individual responses.
*/
-var readBatch = function (text, context) {
+function readBatch(text, context) {
var delimiter = "--" + currentBoundary(context);
// Move beyond the delimiter and read the complete batch
@@ -130,7 +133,7 @@ var readBatch = function (text, context) {
var changeResponses;
if (partContentType && partContentType.mediaType === batchMediaType) {
- context.boundaries.push(partContentType.properties["boundary"]);
+ context.boundaries.push(partContentType.properties.boundary);
try {
changeResponses = readBatch(text, context);
} catch (e) {
@@ -168,7 +171,7 @@ var readBatch = function (text, context) {
readLine(text, context);
}
return responses;
-};
+}
/* Parses the http headers in the text from the position defined by the context.
* @param {String} text - Text containing an http response's headers</param>
@@ -176,7 +179,7 @@ var readBatch = function (text, context) {
* @returns Object containing the headers as key value pairs.
* This function doesn't support split headers and it will stop reading when it hits two consecutive line breaks.
*/
-var readHeaders = function (text, context) {
+function readHeaders(text, context) {
var headers = {};
var parts;
var line;
@@ -197,7 +200,7 @@ var readHeaders = function (text, context) {
normalizeHeaders(headers);
return headers;
-};
+}
/* Parses an HTTP response.
* @param {String} text -Text representing the http response.
@@ -205,7 +208,7 @@ var readHeaders = function (text, context) {
* @param {String} delimiter -String used as delimiter of the multipart response parts.
* @return Object representing the http response.
*/
-var readResponse = function (text, context, delimiter) {
+function readResponse(text, context, delimiter) {
// Read the status line.
var pos = context.position;
var match = responseStatusRegex.exec(readLine(text, context));
@@ -229,17 +232,17 @@ var readResponse = function (text, context, delimiter) {
headers: headers,
body: readTo(text, context, "\r\n" + delimiter)
};
-};
+}
/** Returns a substring from the position defined by the context up to the next line break (CRLF).
* @param {String} text - Input string.
* @param context - Context used for reading the input string.
* @returns {String} Substring to the first ocurrence of a line break or null if none can be found.
*/
-var readLine = function (text, context) {
+function readLine(text, context) {
return readTo(text, context, "\r\n");
-};
+}
/** Returns a substring from the position given by the context up to value defined by the str parameter and increments the position in the context.
* @param {String} text - Input string.</param>
@@ -247,7 +250,7 @@ var readLine = function (text, context) {
* @param {String} [str] - Substring to read up to.
* @returns {String} Substring to the first ocurrence of str or the end of the input string if str is not specified. Null if the marker is not found.
*/
-var readTo = function (text, context, str) {
+function readTo(text, context, str) {
var start = context.position || 0;
var end = text.length;
if (str) {
@@ -261,14 +264,14 @@ var readTo = function (text, context, str) {
}
return text.substring(start, end);
-};
+}
/** Serializes a batch request object to a string.
* @param data - Batch request object in payload representation format
* @param context - Context used for the serialization
* @returns {String} String representing the batch request
*/
-var writeBatch = function (data, context) {
+function writeBatch(data, context) {
if (!isBatch(data)) {
throw { message: "Data is not a batch object." };
}
@@ -288,21 +291,21 @@ var writeBatch = function (data, context) {
contentTypeProperties.boundary = batchBoundary;
return batch;
-};
+}
/** Creates the delimiter that indicates that start or end of an individual request.
* @param {String} boundary Boundary string used to indicate the start of the request</param>
* @param {Boolean} close - Flag indicating that a close delimiter string should be generated
* @returns {String} Delimiter string
*/
-var writeBatchPartDelimiter = function (boundary, close) {
+function writeBatchPartDelimiter(boundary, close) {
var result = "\r\n--" + boundary;
if (close) {
result += "--";
}
return result + "\r\n";
-};
+}
/** Serializes a part of a batch request to a string. A part can be either a GET request or
* a change set grouping several CUD (create, update, delete) requests.
@@ -312,7 +315,7 @@ var writeBatchPartDelimiter = function (boundary, close) {
* @returns {String} String representing the serialized part
* A change set is an array of request objects and they cannot be nested inside other change sets.
*/
-var writeBatchPart = function (part, context, nested) {
+function writeBatchPart(part, context, nested) {
var changeSet = part.__changeRequests;
@@ -343,13 +346,13 @@ var writeBatchPart = function (part, context, nested) {
}
return result;
-};
+}
/* Serializes a request object to a string.
* @param request - Request object to serialize</param>
* @returns {String} String representing the serialized request
*/
-var writeRequest = function (request) {
+function writeRequest(request) {
var result = (request.method ? request.method : "GET") + " " + request.requestUri + " HTTP/1.1\r\n";
for (var name in request.headers) {
if (request.headers[name]) {
@@ -364,11 +367,11 @@ var writeRequest = function (request) {
}
return result;
-};
+}
+
-exports.batchHandler = handler(batchParser, batchSerializer, batchMediaType, MAX_DATA_SERVICE_VERSION);
-// DATAJS INTERNAL START
+/** batchHandler (see {@link module:odata/batch~batchParser}) */
+exports.batchHandler = handler(batchParser, batchSerializer, batchMediaType, MAX_DATA_SERVICE_VERSION);
exports.batchSerializer = batchSerializer;
-exports.writeRequest = writeRequest;
-// DATAJS INTERNAL END
+exports.writeRequest = writeRequest;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/odata/handler.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/odata/handler.js b/datajs/src/lib/odata/handler.js
index 01e368f..3e85a1e 100644
--- a/datajs/src/lib/odata/handler.js
+++ b/datajs/src/lib/odata/handler.js
@@ -17,6 +17,9 @@
* under the License.
*/
+/** @module odata/handler */
+
+
var utils = require('./../datajs.js').utils;
var oDataUtils = require('./utils.js');
@@ -31,7 +34,7 @@ var MAX_DATA_SERVICE_VERSION = "4.0";
* @param {String} str - String with media type to parse.
* @return null if the string is empty; an object with 'mediaType' and a 'properties' dictionary otherwise.
*/
-var contentType = function (str) {
+function contentType(str) {
if (!str) {
return null;
@@ -47,13 +50,13 @@ var contentType = function (str) {
}
return { mediaType: trimString(contentTypeParts[0]), properties: properties };
-};
+}
/** Serializes an object with media type and properties dictionary into a string.
* @param contentType - Object with media type and properties dictionary to serialize.
* @return String representation of the media type object; undefined if contentType is null or undefined.</returns>
*/
-var contentTypeToString = function (contentType) {
+function contentTypeToString(contentType) {
if (!contentType) {
return undefined;
}
@@ -64,7 +67,7 @@ var contentTypeToString = function (contentType) {
result += ";" + property + "=" + contentType.properties[property];
}
return result;
-};
+}
/** Creates an object that is going to be used as the context for the handler's parser and serializer.
* @param contentType - Object with media type and properties dictionary.
@@ -73,7 +76,7 @@ var contentTypeToString = function (contentType) {
* @param handler - Handler object that is processing a resquest or response.
* @return Context object.</returns>
*/
-var createReadWriteContext = function (contentType, dataServiceVersion, context, handler) {
+function createReadWriteContext(contentType, dataServiceVersion, context, handler) {
var rwContext = {};
extend(rwContext, context);
@@ -84,14 +87,14 @@ var createReadWriteContext = function (contentType, dataServiceVersion, context,
});
return rwContext;
-};
+}
/** Sets a request header's value. If the header has already a value other than undefined, null or empty string, then this method does nothing.
* @param request - Request object on which the header will be set.
* @param {String} name - Header name.
* @param {String} value - Header value.
*/
-var fixRequestHeader = function (request, name, value) {
+function fixRequestHeader(request, name, value) {
if (!request) {
return;
}
@@ -100,48 +103,48 @@ var fixRequestHeader = function (request, name, value) {
if (!headers[name]) {
headers[name] = value;
}
-};
+}
/** Sets the DataServiceVersion header of the request if its value is not yet defined or of a lower version.
* @param request - Request object on which the header will be set.
* @param {String} version - Version value.
* If the request has already a version value higher than the one supplied the this function does nothing.
*/
-var fixDataServiceVersionHeader = function (request, version) {
+function fixDataServiceVersionHeader(request, version) {
if (request) {
var headers = request.headers;
var dsv = headers["OData-Version"];
headers["OData-Version"] = dsv ? maxVersion(dsv, version) : version;
}
-};
+}
/** Gets the value of a request or response header.
* @param requestOrResponse - Object representing a request or a response.
* @param {String} name - Name of the header to retrieve.
* @returns {String} String value of the header; undefined if the header cannot be found.
*/
-var getRequestOrResponseHeader = function (requestOrResponse, name) {
+function getRequestOrResponseHeader(requestOrResponse, name) {
var headers = requestOrResponse.headers;
return (headers && headers[name]) || undefined;
-};
+}
/** Gets the value of the Content-Type header from a request or response.
* @param requestOrResponse - Object representing a request or a response.
* @returns {Object} Object with 'mediaType' and a 'properties' dictionary; null in case that the header is not found or doesn't have a value.
*/
-var getContentType = function (requestOrResponse) {
+function getContentType(requestOrResponse) {
return contentType(getRequestOrResponseHeader(requestOrResponse, "Content-Type"));
-};
+}
var versionRE = /^\s?(\d+\.\d+);?.*$/;
/** Gets the value of the DataServiceVersion header from a request or response.
* @param requestOrResponse - Object representing a request or a response.
* @returns {String} Data service version; undefined if the header cannot be found.
*/
-var getDataServiceVersion = function (requestOrResponse) {
+function getDataServiceVersion(requestOrResponse) {
var value = getRequestOrResponseHeader(requestOrResponse, "OData-Version");
if (value) {
@@ -152,7 +155,7 @@ var getDataServiceVersion = function (requestOrResponse) {
}
// Fall through and return undefined.
-};
+}
/** Checks that a handler can process a particular mime type.
* @param handler - Handler object that is processing a resquest or response.
@@ -162,9 +165,9 @@ var getDataServiceVersion = function (requestOrResponse) {
* The following check isn't as strict because if cType.mediaType = application/; it will match an accept value of "application/xml";
* however in practice we don't not expect to see such "suffixed" mimeTypes for the handlers.
*/
-var handlerAccepts = function (handler, cType) {
+function handlerAccepts(handler, cType) {
return handler.accept.indexOf(cType.mediaType) >= 0;
-};
+}
/** Invokes the parser associated with a handler for reading the payload of a HTTP response.
* @param handler - Handler object that is processing the response.
@@ -173,7 +176,7 @@ var handlerAccepts = function (handler, cType) {
* @param context - Object used as the context for processing the response.
* @returns {Boolean} True if the handler processed the response payload and the response.data property was set; false otherwise.
*/
-var handlerRead = function (handler, parseCallback, response, context) {
+function handlerRead(handler, parseCallback, response, context) {
if (!response || !response.headers) {
return false;
@@ -195,7 +198,7 @@ var handlerRead = function (handler, parseCallback, response, context) {
}
return false;
-};
+}
/** Invokes the serializer associated with a handler for generating the payload of a HTTP request.
* @param handler - Handler object that is processing the request.
@@ -204,7 +207,7 @@ var handlerRead = function (handler, parseCallback, response, context) {
* @param context - Object used as the context for serializing the request.
* @returns {Boolean} True if the handler serialized the request payload and the request.body property was set; false otherwise.
*/
-var handlerWrite = function (handler, serializeCallback, request, context) {
+function handlerWrite(handler, serializeCallback, request, context) {
if (!request || !request.headers) {
return false;
}
@@ -228,7 +231,7 @@ var handlerWrite = function (handler, serializeCallback, request, context) {
}
return false;
-};
+}
/** Creates a handler object for processing HTTP requests and responses.
* @param {Function} parseCallback - Parser function that will process the response payload.
@@ -237,7 +240,7 @@ var handlerWrite = function (handler, serializeCallback, request, context) {
* @param {String} maxDataServiceVersion - String indicating the highest version of the protocol that this handler can work with.
* @returns {Object} Handler object.
*/
-var handler = function (parseCallback, serializeCallback, accept, maxDataServiceVersion) {
+function handler(parseCallback, serializeCallback, accept, maxDataServiceVersion) {
return {
accept: accept,
@@ -251,19 +254,22 @@ var handler = function (parseCallback, serializeCallback, accept, maxDataService
return handlerWrite(this, serializeCallback, request, context);
}
};
-};
+}
-var textParse = function (handler, body /*, context */) {
+function textParse(handler, body /*, context */) {
return body;
-};
+}
-var textSerialize = function (handler, data /*, context */) {
+function textSerialize(handler, data /*, context */) {
if (assigned(data)) {
return data.toString();
} else {
return undefined;
}
-};
+}
+
+
+
exports.textHandler = handler(textParse, textSerialize, "text/plain", MAX_DATA_SERVICE_VERSION);
@@ -275,4 +281,4 @@ exports.fixRequestHeader = fixRequestHeader;
exports.getRequestOrResponseHeader = getRequestOrResponseHeader;
exports.getContentType = getContentType;
exports.getDataServiceVersion = getDataServiceVersion;
-exports.MAX_DATA_SERVICE_VERSION = MAX_DATA_SERVICE_VERSION;
+exports.MAX_DATA_SERVICE_VERSION = MAX_DATA_SERVICE_VERSION;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/odata/json.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/odata/json.js b/datajs/src/lib/odata/json.js
index 61558e7..224e881 100644
--- a/datajs/src/lib/odata/json.js
+++ b/datajs/src/lib/odata/json.js
@@ -17,6 +17,10 @@
* under the License.
*/
+/** @module odata/json */
+
+
+
var utils = require('./../datajs.js').utils;
var oDataUtils = require('./utils.js');
var oDataHandler = require('./handler.js');
@@ -93,7 +97,7 @@ var jsonDateRE = /^\/Date\((-?\d+)(\+|-)?(\d+)?\)\/$/;
* @param {Number} minutes - Number of minutes to format.
* @returns {String} The minutes in (+/-)hh:mm format.
*/
-var minutesToOffset = function (minutes) {
+function minutesToOffset(minutes) {
var sign;
if (minutes < 0) {
@@ -107,13 +111,13 @@ var minutesToOffset = function (minutes) {
minutes = minutes - (60 * hours);
return sign + formatNumberWidth(hours, 2) + ":" + formatNumberWidth(minutes, 2);
-};
+}
/** Parses the JSON Date representation into a Date object.
* @param {String} value - String value.
* @returns {Date} A Date object if the value matches one; falsy otherwise.
*/
-var parseJsonDateString = function (value) {
+function parseJsonDateString(value) {
var arr = value && jsonDateRE.exec(value);
if (arr) {
@@ -138,7 +142,7 @@ var parseJsonDateString = function (value) {
}
// Allow undefined to be returned.
-};
+}
// Some JSON implementations cannot produce the character sequence \/
// which is needed to format DateTime and DateTimeOffset into the
@@ -152,7 +156,7 @@ var parseJsonDateString = function (value) {
* @param {Object} context - Object with parsing context.
* @return An object representation of the OData payload.</returns>
*/
-var jsonParser = function (handler, text, context) {
+function jsonParser(handler, text, context) {
var recognizeDates = defined(context.recognizeDates, handler.recognizeDates);
var model = context.metadata;
@@ -178,18 +182,18 @@ var jsonParser = function (handler, text, context) {
else {
return json;
}
-};
+}
-var addType = function(data, name, value ) {
+function addType(data, name, value ) {
var fullName = name + '@odata.type';
if ( data[fullName] === undefined) {
data[fullName] = value;
}
-};
+}
-var addTypeNoEdm = function(data, name, value ) {
+function addTypeNoEdm(data, name, value ) {
var fullName = name + '@odata.type';
if ( data[fullName] === undefined) {
@@ -200,9 +204,9 @@ var addTypeNoEdm = function(data, name, value ) {
}
}
-};
+}
-var addTypeColNoEdm = function(data, name, value ) {
+function addTypeColNoEdm(data, name, value ) {
var fullName = name + '@odata.type';
if ( data[fullName] === undefined) {
@@ -212,7 +216,7 @@ var addTypeColNoEdm = function(data, name, value ) {
data[fullName] = 'Collection('+value+ ')';
}
}
-};
+}
/* Adds typeinformation for String, Boolean and numerical EDM-types.
@@ -221,8 +225,8 @@ var addTypeColNoEdm = function(data, name, value ) {
* @param {Boolean} recognizeDates - True if strings formatted as datetime values should be treated as datetime values. False otherwise.
* @returns An object representation of the OData payload.
*/
-var readPayloadFull = function (data, model, recognizeDates) {
-
+function readPayloadFull(data, model, recognizeDates) {
+ var type;
if (utils.isObject(data)) {
for (var key in data) {
if (data.hasOwnProperty(key)) {
@@ -235,7 +239,7 @@ var readPayloadFull = function (data, model, recognizeDates) {
if (data[key] !== null) {
//don't step into geo.. objects
var isGeo = false;
- var type = data[key+'@odata.type'];
+ type = data[key+'@odata.type'];
if (type && (isGeographyEdmType(type) || isGeometryEdmType(type))) {
// is gemometry type
} else {
@@ -243,7 +247,7 @@ var readPayloadFull = function (data, model, recognizeDates) {
}
}
} else {
- var type = data[key + '@odata.type'];
+ type = data[key + '@odata.type'];
// On .Net OData library, some basic EDM type is omitted, e.g. Edm.String, Edm.Int, and etc.
// For the full metadata payload, we need to full fill the @data.type for each property if it is missing.
@@ -276,7 +280,7 @@ var readPayloadFull = function (data, model, recognizeDates) {
}
return data;
-};
+}
/** Serializes the data by returning its string representation.
* @param handler - This handler.
@@ -284,7 +288,7 @@ var readPayloadFull = function (data, model, recognizeDates) {
* @param {Object} context - Object with serialization context.
* @returns {String} The string representation of data.
*/
-var jsonSerializer = function (handler, data, context) {
+function jsonSerializer(handler, data, context) {
var dataServiceVersion = context.dataServiceVersion || "4.0";
var cType = context.contentType = context.contentType || jsonContentType;
@@ -298,9 +302,9 @@ var jsonSerializer = function (handler, data, context) {
}
return undefined;
-};
+}
-var formatJsonRequestPayload = function (data) {
+function formatJsonRequestPayload(data) {
if (!data) {
return data;
}
@@ -327,7 +331,7 @@ var formatJsonRequestPayload = function (data) {
}
return newdata;
-};
+}
/** JSON replacer function for converting a value to its JSON representation.
* @param {Object} value - Value to convert.</param>
@@ -335,7 +339,7 @@ var formatJsonRequestPayload = function (data) {
* This method is used during JSON serialization and invoked only by the JSON.stringify function.
* It should never be called directly.
*/
-var jsonReplacer = function (_, value) {
+function jsonReplacer(_, value) {
if (value && value.__edmType === "Edm.Time") {
@@ -343,7 +347,7 @@ var jsonReplacer = function (_, value) {
} else {
return value;
}
-};
+}
/** Creates an object containing information for the json payload.
@@ -351,14 +355,14 @@ var jsonReplacer = function (_, value) {
* @param {String} typeName - Type name of the JSON payload.
* @returns {Object} Object with kind and type fields.
*/
-var jsonMakePayloadInfo = function (kind, type) {
+function jsonMakePayloadInfo(kind, type) {
/// TODO docu
/// <field name="kind" type="String">Kind of the JSON payload. One of the PAYLOADTYPE_XXX constant values.</field>
/// <field name="type" type="String">Data type of the JSON payload.</field>
return { kind: kind, type: type || null };
-};
+}
/** Creates an object containing information for the context
* TODO check dou layout
@@ -368,7 +372,7 @@ var jsonMakePayloadInfo = function (kind, type) {
* @returns {Object.typeName(optional)} name of the type
* @returns {Object.type(optional)} object containing type information for entity- and complex-types ( null if a typeName is a primitive)
*/
-var parseContextUriFragment = function( fragments, model ) {
+function parseContextUriFragment( fragments, model ) {
var ret = {};
if (fragments.indexOf('/') === -1 ) {
@@ -552,7 +556,7 @@ var parseContextUriFragment = function( fragments, model ) {
}
return ret;
-};
+}
/** Infers the information describing the JSON payload from its metadata annotation, structure, and data model.
* @param {Object} data - Json response payload object.
@@ -563,7 +567,7 @@ var parseContextUriFragment = function( fragments, model ) {
* and allows the user to control how the library behaves with an ambigous JSON payload.
* @return Object with kind and type fields. Null if there is no metadata annotation or the payload info cannot be obtained..
*/
-var createPayloadInfo = function (data, model) {
+function createPayloadInfo(data, model) {
var metadataUri = data[contextUrlAnnotation];
@@ -578,7 +582,7 @@ var createPayloadInfo = function (data, model) {
var fragment = metadataUri.substring(fragmentStart + 1);
return parseContextUriFragment(fragment,model);
-};
+}
/** Processe a JSON response payload with metadata-minimal
* @param {Object} data - Json response payload object
@@ -586,7 +590,7 @@ var createPayloadInfo = function (data, model) {
* @param {Boolean} recognizeDates - Flag indicating whether datetime literal strings should be converted to JavaScript Date objects.
* @returns {Object} Object in the library's representation.
*/
-var readPayloadMinimal = function (data, model, recognizeDates) {
+function readPayloadMinimal(data, model, recognizeDates) {
if (!assigned(model) || isArray(model)) {
return data;
@@ -613,14 +617,14 @@ var readPayloadMinimal = function (data, model, recognizeDates) {
}
return data;
-};
+}
/** Gets the key of an entry.
* @param {Object} data - JSON entry.
*
* @returns {string} Entry instance key.
*/
-var jsonGetEntryKey = function (data, entityModel) {
+function jsonGetEntryKey(data, entityModel) {
var entityInstanceKey;
var entityKeys = entityModel.key[0].propertyRef;
@@ -643,9 +647,9 @@ var jsonGetEntryKey = function (data, entityModel) {
}
entityInstanceKey += ")";
return entityInstanceKey;
-};
+}
-var readPayloadMinimalProperty = function (data, model, collectionInfo, baseURI, recognizeDates) {
+function readPayloadMinimalProperty(data, model, collectionInfo, baseURI, recognizeDates) {
if (collectionInfo.type !== null) {
readPayloadMinimalObject(data, collectionInfo, baseURI, model, recognizeDates);
} else {
@@ -653,9 +657,9 @@ var readPayloadMinimalProperty = function (data, model, collectionInfo, baseURI,
//data['value@odata.type'] = '#'+collectionInfo.typeName;
}
return data;
-};
+}
-var readPayloadMinimalCollection = function (data, model, collectionInfo, baseURI, recognizeDates) {
+function readPayloadMinimalCollection(data, model, collectionInfo, baseURI, recognizeDates) {
//data['@odata.type'] = '#Collection('+collectionInfo.typeName + ')';
addTypeColNoEdm(data,'', collectionInfo.typeName);
@@ -686,8 +690,9 @@ var readPayloadMinimalCollection = function (data, model, collectionInfo, baseUR
data.value = entries;
}
return data;
-};
-var readPayloadMinimalFeed = function (data, model, feedInfo, baseURI, recognizeDates) {
+}
+
+function readPayloadMinimalFeed(data, model, feedInfo, baseURI, recognizeDates) {
var entries = [];
var items = data.value;
for (i = 0, len = items.length; i < len; i++) {
@@ -712,18 +717,18 @@ var readPayloadMinimalFeed = function (data, model, feedInfo, baseURI, recognize
}
data.value = entries;
return data;
-};
+}
-var readPayloadMinimalEntry = function (data, model, entryInfo, baseURI, recognizeDates) {
+function readPayloadMinimalEntry(data, model, entryInfo, baseURI, recognizeDates) {
return readPayloadMinimalObject(data, entryInfo, baseURI, model, recognizeDates);
-};
+}
/** Formats a value according to Uri literal format
* @param value - Value to be formatted.
* @param type - Edm type of the value
* @returns {string} Value after formatting
*/
-var formatLiteral = function (value, type) {
+function formatLiteral(value, type) {
value = "" + formatRowLiteral(value, type);
value = encodeURIComponent(value.replace("'", "''"));
@@ -755,18 +760,18 @@ var formatLiteral = function (value, type) {
default:
return value;
}
-};
+}
-var formatRowLiteral = function (value, type) {
+function formatRowLiteral(value, type) {
switch (type) {
case "Edm.Binary":
return convertByteArrayToHexString(value);
default:
return value;
}
-};
+}
-var convertDates = function (data, propertyName,type) {
+function convertDates(data, propertyName,type) {
if (type === 'Edm.Date') {
data[propertyName] = oDataUtils.parseDate(data[propertyName], true);
} else if (type === 'Edm.DateTimeOffset') {
@@ -776,9 +781,9 @@ var convertDates = function (data, propertyName,type) {
} else if (type === 'Edm.Time') {
data[propertyName] = oDataUtils.parseTime(data[propertyName], true);
}
-};
+}
-var convertDatesNoEdm = function (data, propertyName,type) {
+function convertDatesNoEdm(data, propertyName,type) {
if (type === 'Date') {
data[propertyName] = oDataUtils.parseDate(data[propertyName], true);
} else if (type === 'DateTimeOffset') {
@@ -788,9 +793,9 @@ var convertDatesNoEdm = function (data, propertyName,type) {
} else if (type === 'Time') {
data[propertyName] = oDataUtils.parseTime(data[propertyName], true);
}
-};
+}
-var checkProperties = function (data, objectInfoType, baseURI, model, recognizeDates) {
+function checkProperties(data, objectInfoType, baseURI, model, recognizeDates) {
for (var name in data) {
if (name.indexOf("@") === -1) {
var curType = objectInfoType;
@@ -825,9 +830,9 @@ var checkProperties = function (data, objectInfoType, baseURI, model, recognizeD
}
}
}
-};
+}
-var readPayloadMinimalComplexObject = function (data, property, baseURI, model, recognizeDates) {
+function readPayloadMinimalComplexObject(data, property, baseURI, model, recognizeDates) {
var type = property.type;
if (isCollectionType(property.type)) {
type =property.type.substring(11,property.type.length-1);
@@ -843,9 +848,9 @@ var readPayloadMinimalComplexObject = function (data, property, baseURI, model,
}
checkProperties(data, propertyType, baseURI, model, recognizeDates);
-};
+}
-var readPayloadMinimalObject = function (data, objectInfo, baseURI, model, recognizeDates) {
+function readPayloadMinimalObject(data, objectInfo, baseURI, model, recognizeDates) {
//data['@odata.type'] = '#'+objectInfo.typeName;
addType(data,'',objectInfo.typeName);
@@ -867,11 +872,11 @@ var readPayloadMinimalObject = function (data, objectInfo, baseURI, model, recog
checkProperties(data, objectInfo.type, baseURI, model, recognizeDates);
return data;
-};
+}
var jsonSerializableMetadata = ["@odata.id", "@odata.type"];
-var isJsonSerializableProperty = function (property) {
+function isJsonSerializableProperty(property) {
if (!property) {
return false;
}
@@ -889,22 +894,25 @@ var isJsonSerializableProperty = function (property) {
}
return false;
-};
+}
/** Determines whether a type name is a primitive type in a JSON payload.
* @param {String} typeName - Type name to test.
* @returns {Boolean} True if the type name an EDM primitive type or an OData spatial type; false otherwise.
*/
-var jsonIsPrimitiveType = function (typeName) {
+function jsonIsPrimitiveType(typeName) {
return isPrimitiveEdmType(typeName) || isGeographyEdmType(typeName) || isGeometryEdmType(typeName);
-};
+}
var jsonHandler = oDataHandler.handler(jsonParser, jsonSerializer, jsonMediaType, MAX_DATA_SERVICE_VERSION);
jsonHandler.recognizeDates = false;
+
+
+exports.createPayloadInfo = createPayloadInfo;
exports.jsonHandler = jsonHandler;
exports.jsonParser = jsonParser;
exports.jsonSerializer = jsonSerializer;
-exports.parseJsonDateString = parseJsonDateString;
+exports.parseJsonDateString = parseJsonDateString;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/odata/metadata.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/odata/metadata.js b/datajs/src/lib/odata/metadata.js
index 582da7d..5ad70b6 100644
--- a/datajs/src/lib/odata/metadata.js
+++ b/datajs/src/lib/odata/metadata.js
@@ -17,10 +17,14 @@
* under the License.
*/
+/** @module odata/metadata */
+
var utils = require('./../datajs.js').utils;
var oDSxml = require('./../datajs.js').xml;
var odataHandler = require('./handler.js');
+
+
// imports
var contains = utils.contains;
var normalizeURI = utils.normalizeURI;
@@ -51,7 +55,7 @@ var xmlMediaType = "application/xml";
* If a child element name ends with * then it is understood by the schema that that child element can appear 0 or more times.
* @returns {Object} Object with attributes, elements, text, and ns fields.
*/
-var schemaElement = function (attributes, elements, text, ns) {
+function schemaElement(attributes, elements, text, ns) {
return {
attributes: attributes,
@@ -59,7 +63,7 @@ var schemaElement = function (attributes, elements, text, ns) {
text: text || false,
ns: ns
};
-};
+}
// It's assumed that all elements may have Documentation children and Annotation elements.
// See http://docs.oasis-open.org/odata/odata/v4.0/cs01/part3-csdl/odata-v4.0-cs01-part3-csdl.html for a CSDL reference.
@@ -361,7 +365,7 @@ var schema = {
* @returns {String} Converted text.
* If the text starts with multiple uppercase characters, it is left as-is.</remarks>
*/
-var scriptCase = function (text) {
+function scriptCase(text) {
if (!text) {
return text;
@@ -377,14 +381,14 @@ var scriptCase = function (text) {
}
return text.charAt(0).toLowerCase();
-};
+}
/** Gets the schema node for the specified element.
* @param {Object} parentSchema - Schema of the parent XML node of 'element'.
* @param candidateName - XML element name to consider.
* @returns {Object} The schema that describes the specified element; null if not found.
*/
-var getChildSchema = function (parentSchema, candidateName) {
+function getChildSchema(parentSchema, candidateName) {
var elements = parentSchema.elements;
if (!elements) {
@@ -407,22 +411,22 @@ var getChildSchema = function (parentSchema, candidateName) {
}
return null;
-};
+}
/** Checks whether the specifies namespace URI is one of the known CSDL namespace URIs.
* @param {String} nsURI - Namespace URI to check.
* @returns {Boolean} true if nsURI is a known CSDL namespace; false otherwise.
*/
-var isEdmNamespace = function (nsURI) {
+function isEdmNamespace(nsURI) {
return nsURI === edmNs1;
-};
+}
/** Parses a CSDL document.
* @param element - DOM element to parse.
* @returns {Object} An object describing the parsed element.
*/
-var parseConceptualModelElement = function (element) {
+function parseConceptualModelElement(element) {
var localName = xmlLocalName(element);
var nsURI = xmlNamespaceURI(element);
@@ -494,19 +498,21 @@ var parseConceptualModelElement = function (element) {
}
return item;
-};
+}
/** Parses a metadata document.
* @param handler - This handler.
* @param {String} text - Metadata text.
* @returns An object representation of the conceptual model.</returns>
*/
-var metadataParser = function (handler, text) {
+function metadataParser(handler, text) {
var doc = xmlParse(text);
var root = xmlFirstChildElement(doc);
return parseConceptualModelElement(root) || undefined;
-};
+}
+
+
exports.metadataHandler = odataHandler.handler(metadataParser, null, xmlMediaType, MAX_DATA_SERVICE_VERSION);
@@ -514,4 +520,4 @@ exports.schema = schema;
exports.scriptCase = scriptCase;
exports.getChildSchema = getChildSchema;
exports.parseConceptualModelElement = parseConceptualModelElement;
-exports.metadataParser = metadataParser;
+exports.metadataParser = metadataParser;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/24598e5f/datajs/src/lib/odata/net.js
----------------------------------------------------------------------
diff --git a/datajs/src/lib/odata/net.js b/datajs/src/lib/odata/net.js
index 655a961..9821892 100644
--- a/datajs/src/lib/odata/net.js
+++ b/datajs/src/lib/odata/net.js
@@ -17,6 +17,10 @@
* under the License.
*/
+/** @module odata/net */
+
+
+
var utils = require('./../datajs.js').utils;
// Imports.
@@ -35,24 +39,24 @@ var ticks = 0;
* We allow data to come in a different format, as the servers SHOULD honor the Accept
* request but may in practice return content with a different MIME type.
*/
-var canUseJSONP = function (request) {
+function canUseJSONP(request) {
if (request.method && request.method !== "GET") {
return false;
}
return true;
-};
+}
/** Creates an IFRAME tag for loading the JSONP script
* @param {String} url - The source URL of the script
* @returns {HTMLElement} The IFRAME tag
*/
-var createIFrame = function (url) {
+function createIFrame(url) {
var iframe = window.document.createElement("IFRAME");
iframe.style.display = "none";
- var attributeEncodedUrl = url.replace(/&/g, "&").replace(/"/g, """).replace(/\</g, "<");
+ var attributeEncodedUrl = url.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
var html = "<html><head><script type=\"text/javascript\" src=\"" + attributeEncodedUrl + "\"><\/script><\/head><body><\/body><\/html>";
var body = window.document.getElementsByTagName("BODY")[0];
@@ -65,7 +69,7 @@ var createIFrame = function (url) {
/** Creates a XmlHttpRequest object.
* @returns {XmlHttpRequest} XmlHttpRequest object.
*/
-var createXmlHttpRequest = function () {
+function createXmlHttpRequest() {
if (window.XMLHttpRequest) {
return new window.XMLHttpRequest();
}
@@ -84,23 +88,23 @@ var createXmlHttpRequest = function () {
exception = { message: "XMLHttpRequest not supported" };
}
throw exception;
-};
+}
/** Checks whether the specified URL is an absolute URL.
* @param {String} url - URL to check.
* @returns {Boolean} true if the url is an absolute URL; false otherwise.
*/
-var isAbsoluteUrl = function (url) {
+function isAbsoluteUrl(url) {
return url.indexOf("http://") === 0 ||
url.indexOf("https://") === 0 ||
url.indexOf("file://") === 0;
-};
+}
/** Checks whether the specified URL is local to the current context.
* @param {String} url - URL to check.
* @returns {Boolean} true if the url is a local URL; false otherwise.
*/
-var isLocalUrl = function (url) {
+function isLocalUrl(url) {
if (!isAbsoluteUrl(url)) {
return true;
@@ -110,13 +114,13 @@ var isLocalUrl = function (url) {
var location = window.location;
var locationDomain = location.protocol + "//" + location.host + "/";
return (url.indexOf(locationDomain) === 0);
-};
+}
/** Removes a callback used for a JSONP request.
* @param {String} name - Function name to remove.
* @param {Number} tick - Tick count used on the callback.
*/
-var removeCallback = function (name, tick) {
+function removeCallback(name, tick) {
try {
delete window[name];
} catch (err) {
@@ -131,7 +135,7 @@ var removeCallback = function (name, tick) {
* @param {Object} iframe - The iframe to remove.
* @returns {Object} Null value to be assigned to iframe reference.
*/
-var removeIFrame = function (iframe) {
+function removeIFrame(iframe) {
if (iframe) {
writeHtmlToIFrame(iframe, "");
iframe.parentNode.removeChild(iframe);
@@ -144,7 +148,7 @@ var removeIFrame = function (iframe) {
* @param {XMLHttpRequest} xhr - HTTP request with response available.
* @param {Array} headers - Target array to fill with name/value pairs.
*/
-var readResponseHeaders = function (xhr, headers) {
+function readResponseHeaders(xhr, headers) {
var responseHeaders = xhr.getAllResponseHeaders().split(/\r?\n/);
var i, len;
@@ -154,18 +158,18 @@ var readResponseHeaders = function (xhr, headers) {
headers[header[0]] = header[1];
}
}
-};
+}
/** Writes HTML to an IFRAME document.
* @param {HTMLElement} iframe - The IFRAME element to write to.
* @param {String} html - The HTML to write.
*/
-var writeHtmlToIFrame = function (iframe, html) {
+function writeHtmlToIFrame(iframe, html) {
var frameDocument = (iframe.contentWindow) ? iframe.contentWindow.document : iframe.contentDocument.document;
frameDocument.open();
frameDocument.write(html);
frameDocument.close();
-};
+}
exports.defaultHttpClient = {
callbackParameterName: "$callback",
@@ -329,7 +333,8 @@ exports.defaultHttpClient = {
}
};
+
+
exports.canUseJSONP = canUseJSONP;
exports.isAbsoluteUrl = isAbsoluteUrl;
-exports.isLocalUrl = isLocalUrl;
-
+exports.isLocalUrl = isLocalUrl;
\ No newline at end of file