|
Zapatec Utils | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object | +--Zapatec.Transport
Defined in transport.js
Field Summary | |
<static> Object |
pickActiveXVersion
|
Constructor Summary | |
Zapatec.Transport()
|
Method Summary | |
<static> object
|
createXmlHttpRequest()
Creates cross browser XMLHttpRequest object. |
<static> void
|
evalGlobalScope(<string> sScript)
Evaluates javascript in global scope. |
<static> object
|
fetch(<object> oArg)
Fetches specified URL using new XMLHttpRequest object. |
<static> object
|
fetchJsonObj(<object> oArg)
Fetches and parses JSON object from the specified URL. |
<static> object
|
fetchXmlDoc(<object> oArg)
Fetches and parses XML document from the specified URL. |
<static> string
|
getPath(<string> sScriptFileName)
Returns path to the specified js file. |
<static> void
|
include(<string> sSrc, <string> sId, <boolean> bForce)
Writes script tag to the document. |
<static> void
|
includeCSS(<string> sHref)
Includes CSS file into the page. |
<static> void
|
includeJS(<string> sSrc, <string> sId)
Includes JS file into the page. |
<static> void
|
loadCss(<object> oArg)
Fetches style sheet using fetch and loads it into the document. |
<static> void
|
loadCssList(<object> oArg)
Loads several CSS files one by one it into the document. |
<static> void
|
loadJS(<object> oArg)
Fetches JS file using fetch and evaluates it in global scope. |
<static> object
|
parseHtml(<string> sHtml)
Parses HTML fragment into HTMLElement object. |
<static> object
|
parseJson(<object> oArg)
Parses JSON string into object. |
<static> object
|
parseXml(<object> oArg)
Parses XML string into XMLDocument object. |
<static> void
|
preloadImages(<object> oArg)
Preloads one or several images at once. |
<static> void
|
removeBusy(<object> oArg)
Removes animated GIF which was put by Zapatec.Transport.showBusy() from the specified div. |
<static> string
|
serializeJsonObj(<object> v)
Serializes JSON object into JSON string. |
<static> string
|
serializeXmlDoc(<object> oDoc)
Serializes XMLDocument object into XML string. |
<static> void
|
setInnerHtml(<object> oArg)
Assigns passed HTML fragment to the specified element's innerHTML property and evaluates in global scope javascripts found in the fragment. |
<static> void
|
showBusy(<object> oArg)
Shows animated GIF in the specified div. |
<static> string
|
translateUrl(<object> oArg)
Translates a URL to the URL relative to the specified or to absolute URL. |
Field Detail |
<static> Object pickActiveXVersion
Constructor Detail |
Zapatec.Transport()
Method Detail |
<static> object createXmlHttpRequest()
<static> void evalGlobalScope(<string> sScript)
Note: Global variables must be declared without "var" keyword. Otherwise they will be ignored by Safari.
sScript
- Script to evaluate
<static> object fetch(<object> oArg)
Asynchronous mode is recommended because it is safer and there is no risk of having your script hang in case of network problem. Synchronous mode means that the code will hang until a response comes back. When request is completed, one of provided callback functions is called: onLoad on success or onError on error. In synchronous mode onLoad callback can be omitted. Instead use returned object. onLoad callback function receives XMLHttpRequest object as argument and may use its various properties like responseText, responseXML, etc. onError callback function receives following object: { errorCode: server status number (404, etc.) [number], errorDescription: human readable error description [string] } Note: Some browsers implement caching for GET requests. Caching can be prevented by adding 'r=' + Math.random() parameter to URL. If you use POST method, content argument should be something like 'var1=value1&var2=value2' with urlencoded values. If you wish to send other content, set appropriate contentType. E.g. 'multipart/form-data', 'text/xml', etc. If server response contains non-ASCII characters, server must send corresponding content-type header. E.g. "Content-type: text/plain; charset=utf-8" or "Content-type: text/plain; charset=windows-1251". Arguments object format: { url: [string] relative or absolute URL to fetch, method: [string, optional] method ('GET', 'POST', 'HEAD', 'PUT'), async: [boolean, optional] use asynchronous mode (default: true), contentType: [string, optional] content type when using POST, content: [string or object, optional] postable string or DOM object data when using POST, onLoad: [function, optional] function reference to call on success, onError: [function, optional] function reference to call on error, username: [string, optional] username, password: [string, optional] password, busyContainer: [object or string, optional] element or id of element where to put "Busy" animated GIF, busyImage: [string, optional] standard image name or custom image URL, busyImageWidth: [number or string, optional] image width, busyImageHeight: [number or string, optional] image height }
oArg
- Arguments object
<static> object fetchJsonObj(<object> oArg)
When JSON object is fetched and parsed, one of provided callback functions is called: onLoad on success or onError on error. In synchronous mode onLoad callback can be omitted. Instead use returned object. onLoad callback function receives JSON object as argument. onError callback function receives following object: { errorCode: error code [number], errorDescription: human readable error description [string] } Error code will be 0 unless there was a problem during fetching. Note: Some browsers implement caching for GET requests. Caching can be prevented by adding 'r=' + Math.random() parameter to URL. If you use POST method, content argument should be something like 'var1=value1&var2=value'. If you wish to send other content, set appropriate contentType. E.g. to send XML string, you should set contentType: 'text/xml'. If server response contains non-ASCII characters, server must send corresponding content-type header. E.g. "Content-type: text/plain; charset=utf-8" or "Content-type: text/plain; charset=windows-1251". Arguments object format: { url: [string] relative or absolute URL to fetch, reliable: [boolean, optional] false (string will be parsed) or true (evaluated) (default: false), method: [string, optional] method ('GET', 'POST', 'HEAD', 'PUT'), async: [boolean, optional] use asynchronous mode (default: true), contentType: [string, optional] content type when using POST, content: [string or object, optional] postable string or DOM object data when using POST, onLoad: [function, optional] function reference to call on success, onError: [function, optional] function reference to call on error, username: [string, optional] username, password: [string, optional] password, busyContainer: [object or string, optional] element or id of element where to put "Busy" animated GIF, busyImage: [string, optional] standard image name or custom image URL, busyImageWidth: [number or string, optional] image width, busyImageHeight: [number or string, optional] image height }
oArg
- Arguments object
<static> object fetchXmlDoc(<object> oArg)
When XML document is fetched and parsed, one of provided callback functions is called: onLoad on success or onError on error. In synchronous mode onLoad callback can be omitted. Instead use returned object. onLoad callback function receives XMLDocument object as argument and may use its documentElement and other properties. onError callback function receives following object: { errorCode: error code [number], errorDescription: human readable error description [string] } Error code will be 0 unless Zapatec.Transport.fetch was used to fetch URL and there was a problem during fetching. If method argument is not defined, more efficient XMLDOM in IE and document.implementation.createDocument in Mozilla will be used to fetch and parse document. Otherwise Zapatec.Transport.fetch will be used to fetch document and Zapatec.Transport.parseXml to parse. Note: Some browsers implement caching for GET requests. Caching can be prevented by adding 'r=' + Math.random() parameter to URL. If you use POST method, content argument should be something like 'var1=value1&var2=value'. If you wish to send other content, set appropriate contentType. E.g. to send XML string, you should set contentType: 'text/xml'. If server response contains non-ASCII characters, encoding must be specified. E.g. or . If server response contains non-ASCII characters, server must send corresponding content-type header. E.g. "Content-type: text/xml; charset=utf-8" or "Content-type: text/xml; charset=windows-1251". Arguments object format: { url: [string] relative or absolute URL to fetch, method: [string, optional] method ('GET', 'POST', 'HEAD', 'PUT'), async: [boolean, optional] use asynchronous mode (default: true), contentType: [string, optional] content type when using POST, content: [string or object, optional] postable string or DOM object data when using POST, onLoad: [function, optional] function reference to call on success, onError: [function, optional] function reference to call on error, username: [string, optional] username, password: [string, optional] password, busyContainer: [object or string, optional] element or id of element where to put "Busy" animated GIF, busyImage: [string, optional] standard image name or custom image URL, busyImageWidth: [number or string, optional] image width, busyImageHeight: [number or string, optional] image height }
oArg
- Arguments object
<static> string getPath(<string> sScriptFileName)
sScriptFileName
- Script file name, e.g. 'zpmywidget.js'
<static> void include(<string> sSrc, <string> sId, <boolean> bForce)
Note: This function must be invoked during page load because it uses document.write method. If special Zapatec.doNotInclude flag is set, this function does nothing.
sSrc
- Src attribute value of the script element
sId
- Optional. Id of the script element
bForce
- Optional. Force reload if it is already loaded
<static> void includeCSS(<string> sHref)
sHref
- Href attribute value of the link element
<static> void includeJS(<string> sSrc, <string> sId)
sSrc
- Src attribute value of the script element
sId
- Optional. Id of the script element
<static> void loadCss(<object> oArg)
When stylesheet is loaded successfully, onLoad callback function is called without arguments. URL is added into Zapatec.Transport.loadedCss array and will not be fetched again on next function call unless force argument is set to true. onError callback function receives following object: { errorCode: server status number (404, etc.) [number], errorDescription: human readable error description [string] } Arguments object format: { url: absolute or relative URL of CSS file [string], async: [boolean, optional] use asynchronous mode (default: true), force: [boolean, optional] force reload if it is already loaded, onLoad: [function, optional] function reference to call on success, onError: [function, optional] function reference to call on error } Note: If "force" is used, you should add 'r=' + Math.random() parameter to URL to prevent loading from browser cache.
oArg
- Arguments object
<static> void loadCssList(<object> oArg)
This function behaves differently from other Zapatec.Transport functions. onLoad callback function will be called in any case, even if errors occured during loading. If there are multiple errors, onError callback function will be called once for every passed URL that wasn't loaded successfully. onLoad callback function is called without arguments. onError callback function receives following object: { errorCode: server status number (404, etc.) [number], errorDescription: human readable error description [string] } Arguments object format: { urls: array of absolute or relative URLs of CSS files to load [object] (files will be loaded in order they appear in the array), async: [boolean, optional] use asynchronous mode (default: true), force: [boolean, optional] force reload if it is already loaded, onLoad: function reference to call on completion [function] (optional), onError: function reference to call on error [function] (optional) } Note: If "force" is used, you should add 'r=' + Math.random() parameter to URL to prevent loading from browser cache.
oArg
- Arguments object
<static> void loadJS(<object> oArg)
When JS file is loaded successfully, onLoad callback function is called without arguments. URL is added into Zapatec.Transport.loadedJS array and will not be fetched again on next function call unless force argument is set to true. onError callback function receives following object: { errorCode: [number] server status number (404, etc.), errorDescription: [string] human readable error description } One of the arguments: module or url is required. When url is passed, module argument is ignored. If module argument is used, function gets all "script" elements using getElementsByTagName and searches for the first element having "src" attribute value ending with (relativeModule + ".js") (default relativeModule value is "transport"). Path to the module is taken from that src attribute value and will be the same as path to relativeModule file. Arguments object format: { url: [string, optional] absolute or relative URL of JS file, module: [string, optional] module name (file name without .js extension); ignored when "url" is defined, path: [string, optional] path where to search "module" (default is Zapatec.zapatecPath if it is defined); ignored when "url" is defined, async: [boolean, optional] use asynchronous mode (default: true), force: [boolean, optional] force reload if it is already loaded, onLoad: [function, optional] function reference to call on success, onError: [function, optional] function reference to call on error } Note: If "force" is used, you should add 'r=' + Math.random() parameter to URL to prevent loading from browser cache. Note: Global variables must be declared without "var" keyword. Otherwise they will be ignored by Safari. If special Zapatec.doNotInclude flag is set, this function just calls onLoad callback function.
oArg
- Arguments object
<static> object parseHtml(<string> sHtml)
sHtml
- HTML fragment
<static> object parseJson(<object> oArg)
When JSON string is parsed, one of provided callback functions is called: onLoad on success or onError on error. onLoad callback function receives JSON object as argument. onError callback function receives following object: { errorCode: error code [number], errorDescription: human readable error description [string] } Error code will be always 0. Returns JSON object, so onLoad callback function is optional. Returned value should be checked before use because it can be null. Arguments object format: { strJson: JSON string to parse [string], reliable: false (string will be parsed) or true (evaluated) [boolean] (optional, false by default), onLoad: function reference to call on success [function] (optional), onError: function reference to call on error [function] (optional) }
oArg
- Arguments object
<static> object parseXml(<object> oArg)
When XML string is parsed, one of provided callback functions is called: onLoad on success or onError on error. In synchronous mode onLoad callback can be omitted. Instead use returned object. onLoad callback function receives XMLDocument object as argument and may use its documentElement and other properties. onError callback function receives following object: { errorCode: error code [number], errorDescription: human readable error description [string] } Error code will be always 0. Returns XMLDocument object, so onLoad callback function is optional. Returned value and its documentElement property should be checked before use because they can be null or undefined. If XML string contains non-ASCII characters, encoding must be specified. E.g. or . Arguments object format: { strXml: XML string to parse [string], onLoad: function reference to call on success [function] (optional), onError: function reference to call on error [function] (optional) }
oArg
- Arguments object
<static> void preloadImages(<object> oArg)
Arguments object format: { urls: [object] array of absolute or relative image URLs to preload, onLoad: [function, optional] onload event handler, timeout: [number, optional] number of milliseconds to wait for onload event before forcing it }
oArg
- Arguments object
<static> void removeBusy(<object> oArg)
Arguments object format: { busyContainer: [object or string] element where to put animated GIF, busyImage: [string, optional] standard image name or custom image URL }
oArg
- Arguments object
<static> string serializeJsonObj(<object> v)
v
- JSON object
<static> string serializeXmlDoc(<object> oDoc)
oDoc
- XMLDocument object
<static> void setInnerHtml(<object> oArg)
Arguments object format: { html: [string] HTML fragment, container: [object or string, optional] element or id of element to put HTML fragment into }
Note: Scripts are executed after HTML fragment is assigned to innerHTML. If external scripts are used, they are loaded asynchronously and execution sequence is not preserved.
Note: Global variables must be declared without "var" keyword. Otherwise they will be ignored by Safari.
oArg
- Arguments object
<static> void showBusy(<object> oArg)
Arguments object format: { busyContainer: [object or string] element where to put animated GIF, busyImage: [string, optional] standard image name or custom image URL, busyImageWidth: [number or string, optional] image width, busyImageHeight: [number or string, optional] image height }
oArg
- Arguments object
<static> string translateUrl(<object> oArg)
Arguments object format: { url [string]: absolute or relative URL to translate; if absolute, will be returned as is, relativeTo [string, optional]: "url" will be translated to the URL relative to this absolute or relative URL; default: current page URL }
oArg
- Arguments object
|
Zapatec Utils | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |