io.js.html revision eb9b6f817df5c660be9f00fc5d27fe33479fdc98
<html>
<head>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<h3>io <span class="subtitle">3.00PR1</span></h3>
<p>
> io.js (source view)
</p>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form name="yui-classopts-form">
<span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> Show Private</span>
<span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> Show Protected</span>
<span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> Show Deprecated</span>
</form>
<div id="srcout">
<style>
#doc3 #classopts { display:none; }
</style>
<div class="highlight" ><pre><span class="nx">YUI</span><span class="o">.</span><span class="nx">add</span><span class="o">(</span><span class="s2">"io"</span><span class="o">,</span> <span class="k">function</span> <span class="o">(</span><span class="nx">Y</span><span class="o">)</span> <span class="o">{</span>
<span class="c">/**</span>
<span class="c"> * HTTP communications module.</span>
<span class="c"> * @module io</span>
<span class="c"> */</span>
<span class="c">/**</span>
<span class="c"> * The io class is a utility that brokers HTTP requests through a simplified</span>
<span class="c"> * interface. Specifically, it allows JavaScript to make HTTP requests to</span>
<span class="c"> * a resource without a page reload. The underlying transport for making</span>
<span class="c"> * Flash, if specified as a transport, for cross-domain requests.</span>
<span class="c"> *</span>
<span class="c"> * @class io</span>
<span class="c"> */</span>
<span class="c">/**</span>
<span class="c"> * @event io:xdrReady</span>
<span class="c"> * @description This event is fired by YUI.io when a transaction is initiated..</span>
<span class="c"> * @type Event Custom</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">E_XDR_READY</span> <span class="o">=</span> <span class="s1">'io:xdrReady'</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * @event io:start</span>
<span class="c"> * @description This event is fired by YUI.io when a transaction is initiated..</span>
<span class="c"> * @type Event Custom</span>
<span class="c"> */</span>
<span class="nx">E_START</span> <span class="o">=</span> <span class="s1">'io:start'</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * @event io:complete</span>
<span class="c"> * @description This event is fired by YUI.io when a transaction is complete and</span>
<span class="c"> * all response data are available.</span>
<span class="c"> * @type Event Custom</span>
<span class="c"> */</span>
<span class="nx">E_COMPLETE</span> <span class="o">=</span> <span class="s1">'io:complete'</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * @event io:success</span>
<span class="c"> * @description This event is fired by YUI.io when a transaction is complete and</span>
<span class="c"> * the HTTP status resolves to HTTP2xx.</span>
<span class="c"> * @type Event Custom</span>
<span class="c"> */</span>
<span class="nx">E_SUCCESS</span> <span class="o">=</span> <span class="s1">'io:success'</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * @event io:failure</span>
<span class="c"> * @description This event is fired by YUI.io when a transaction is complete and</span>
<span class="c"> * the HTTP status resolves to HTTP4xx, 5xx and above.</span>
<span class="c"> * @type Event Custom</span>
<span class="c"> */</span>
<span class="nx">E_FAILURE</span> <span class="o">=</span> <span class="s1">'io:failure'</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * @event io:abort</span>
<span class="c"> * @type Event Custom</span>
<span class="c"> */</span>
<span class="nx">E_ABORT</span> <span class="o">=</span> <span class="s1">'io:abort'</span><span class="o">,</span>
<span class="c">// Window reference</span>
<span class="c"></span> <span class="nx">w</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">config</span><span class="o">.</span><span class="nx">win</span><span class="o">,</span>
<span class="nx">d</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">config</span><span class="o">.</span><span class="nx">doc</span><span class="o">,</span>
<span class="c">//--------------------------------------</span>
<span class="c"></span> <span class="c">// Properties</span>
<span class="c"></span> <span class="c">//--------------------------------------</span>
<span class="c"></span> <span class="c">/**</span>
<span class="c"> * @description A transaction counter that increments for each transaction.</span>
<span class="c"> *</span>
<span class="c"> * @property transactionId</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @type int</span>
<span class="c"> */</span>
<span class="nx">transactionId</span> <span class="o">=</span> <span class="m">0</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * @description Object of default HTTP headers to be initialized and sent</span>
<span class="c"> * for all transactions.</span>
<span class="c"> *</span>
<span class="c"> * @property _headers</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @type object</span>
<span class="c"> */</span>
<span class="nx">_headers</span> <span class="o">=</span> <span class="o">{</span>
<span class="s1">'X-Requested-With'</span> <span class="o">:</span> <span class="s1">'XMLHttpRequest'</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * @description Object that stores timeout values for any transaction with</span>
<span class="c"> * a defined "timeout" configuration property.</span>
<span class="c"> *</span>
<span class="c"> * @property _timeOut</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @type object</span>
<span class="c"> */</span>
<span class="nx">_timeout</span> <span class="o">=</span> <span class="o">{},</span>
<span class="c">/**</span>
<span class="c"> * @description Object that stores callback handlers for cross-domain requests,</span>
<span class="c"> *</span>
<span class="c"> * @property _fn</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @type object</span>
<span class="c"> */</span>
<span class="nx">_fn</span> <span class="o">=</span> <span class="o">{},</span>
<span class="c">/**</span>
<span class="c"> * @description Map of transports created for cross-domain requests.</span>
<span class="c"> *</span>
<span class="c"> * @property _xdr</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @type object</span>
<span class="c"> */</span>
<span class="nx">_xdr</span> <span class="o">=</span> <span class="o">{</span>
<span class="nx">flash</span><span class="o">:</span><span class="kc">null</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * @description Array of transactions queued for processing</span>
<span class="c"> *</span>
<span class="c"> * @property _q</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @type array</span>
<span class="c"> */</span>
<span class="nx">_q</span> <span class="o">=</span> <span class="o">[],</span>
<span class="c">/**</span>
<span class="c"> * @description Property to determine whether the queue is set to</span>
<span class="c"> * 1 (active) or 0 (inactive). When inactive, transactions</span>
<span class="c"> * will be stored in the queue until the queue is set to active.</span>
<span class="c"> *</span>
<span class="c"> * @property _qState</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @type int</span>
<span class="c"> */</span>
<span class="nx">_qState</span> <span class="o">=</span> <span class="m">1</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * @description Queue property to set a maximum queue storage size. When</span>
<span class="c"> * this property is set, the queue will not store any more transactions</span>
<span class="c"> * until the queue size os reduced below this threshold. There is no</span>
<span class="c"> * maximum queue size until it is explicitly set.</span>
<span class="c"> *</span>
<span class="c"> * @property _qMaxSize</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @type int</span>
<span class="c"> */</span>
<span class="nx">_qMaxSize</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="c">//--------------------------------------</span>
<span class="c"></span> <span class="c">// Methods</span>
<span class="c"></span> <span class="c">//--------------------------------------</span>
<span class="c"></span> <span class="c">/**</span>
<span class="c"> * @description Method for requesting a transaction, and queueing the</span>
<span class="c"> * request before it is sent to the resource.</span>
<span class="c"> *</span>
<span class="c"> * @method _queue</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @return int</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_queue</span><span class="o">(</span><span class="nx">uri</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">_qMaxSize</span> <span class="o">===</span> <span class="kc">false</span> <span class="o">||</span> <span class="nx">_q</span><span class="o">.</span><span class="nx">length</span> <span class="o"><</span> <span class="nx">_qMaxSize</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">_id</span><span class="o">();</span>
<span class="nx">_q</span><span class="o">.</span><span class="nx">push</span><span class="o">({</span> <span class="nx">uri</span><span class="o">:</span> <span class="nx">uri</span><span class="o">,</span> <span class="nx">id</span><span class="o">:</span> <span class="nx">id</span><span class="o">,</span> <span class="nx">cfg</span><span class="o">:</span><span class="nx">c</span> <span class="o">});</span>
<span class="o">}</span>
<span class="k">else</span> <span class="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Unable to queue transaction object. Maximum queue size reached.'</span><span class="o">,</span> <span class="s1">'warn'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">_qState</span> <span class="o">===</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_shift</span><span class="o">();</span>
<span class="o">}</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Object queued. Transaction id is'</span> <span class="o">+</span> <span class="nx">id</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="k">return</span> <span class="nx">id</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method for promoting a transaction to the top of the queue.</span>
<span class="c"> *</span>
<span class="c"> * @method _unshift</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_unshift</span><span class="o">(</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">r</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">_q</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">_q</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">id</span> <span class="o">===</span> <span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">r</span> <span class="o">=</span> <span class="nx">_q</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">i</span><span class="o">,</span> <span class="m">1</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="nx">_q</span><span class="o">.</span><span class="nx">unshift</span><span class="o">(</span><span class="nx">r</span><span class="o">[</span><span class="m">0</span><span class="o">]);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Object promoted to top of queue. Transaction id is'</span> <span class="o">+</span> <span class="nx">id</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="k">break</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method for removing a transaction from the top of the</span>
<span class="c"> * queue, and sending the transaction to _io().</span>
<span class="c"> *</span>
<span class="c"> * @method _shift</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_shift</span><span class="o">()</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">_q</span><span class="o">.</span><span class="nx">shift</span><span class="o">();</span>
<span class="nx">_io</span><span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">uri</span><span class="o">,</span> <span class="nx">c</span><span class="o">.</span><span class="nx">cfg</span><span class="o">,</span> <span class="nx">c</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method to query the current size of the queue, or to</span>
<span class="c"> * set a maximum queue size.</span>
<span class="c"> *</span>
<span class="c"> * @method _size</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @return int</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_size</span><span class="o">(</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_qMaxSize</span> <span class="o">=</span> <span class="nx">i</span><span class="o">;</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Queue size set to '</span> <span class="o">+</span> <span class="nx">i</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="k">return</span> <span class="nx">i</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">else</span> <span class="o">{</span>
<span class="k">return</span> <span class="nx">_q</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method for setting the queue to active. If there are</span>
<span class="c"> * transactions pending in the queue, they will be processed from the</span>
<span class="c"> * queue in FIFO order.</span>
<span class="c"> *</span>
<span class="c"> * @method _start</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_start</span><span class="o">()</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">len</span> <span class="o">=</span> <span class="o">(</span><span class="nx">_q</span><span class="o">.</span><span class="nx">length</span> <span class="o">></span> <span class="nx">_qMaxSize</span> <span class="o">></span> <span class="m">0</span><span class="o">)</span> <span class="o">?</span> <span class="nx">_qMaxSize</span> <span class="o">:</span> <span class="nx">_q</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">len</span> <span class="o">></span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">len</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
<span class="nx">_shift</span><span class="o">();</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">else</span> <span class="o">{</span>
<span class="nx">_shift</span><span class="o">();</span>
<span class="o">}</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Queue started.'</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method for setting queue processing to inactive.</span>
<span class="c"> * not processed until the queue is reset to "active".</span>
<span class="c"> *</span>
<span class="c"> * @method _stop</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_stop</span><span class="o">()</span> <span class="o">{</span>
<span class="nx">_qState</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Queue stopped.'</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method for removing a specific, pending transaction from</span>
<span class="c"> * the queue.</span>
<span class="c"> *</span>
<span class="c"> * @method _purge</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_purge</span><span class="o">(</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">id</span><span class="o">))</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">_q</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">_q</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">id</span> <span class="o">===</span> <span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_q</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">i</span><span class="o">,</span> <span class="m">1</span><span class="o">);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Object purged from queue. Transaction id is'</span> <span class="o">+</span> <span class="nx">id</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="k">break</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">/* End Queue Functions */</span>
<span class="c">/**</span>
<span class="c"> * @description Method for requesting a transaction. _io() is implemented as</span>
<span class="c"> * properties are:</span>
<span class="c"> *</span>
<span class="c"> * not defined, the default value will be GET.</span>
<span class="c"> *</span>
<span class="c"> * data: This is the name-value string that will be sent as the transaction</span>
<span class="c"> * data. If the request is HTTP GET, the data become part of</span>
<span class="c"> * querystring. If HTTP POST, the data are sent in the message body.</span>
<span class="c"> *</span>
<span class="c"> * xdr: Defines the transport to be used for cross-domain requests. By</span>
<span class="c"> * setting this property, the transaction will use the specified</span>
<span class="c"> * transport instead of XMLHttpRequest. Currently, the only alternate</span>
<span class="c"> *</span>
<span class="c"> * form: This is a defined object used to process HTML form as data. The</span>
<span class="c"> * properties are:</span>
<span class="c"> * {</span>
<span class="c"> * id: object, //HTML form object or id of HTML form</span>
<span class="c"> * useDisabled: boolean, //Allow disabled HTML form field values</span>
<span class="c"> * to be sent as part of the data.</span>
<span class="c"> * }</span>
<span class="c"> *</span>
<span class="c"> * on: This is a defined object used to create and handle specific</span>
<span class="c"> * events during a transaction lifecycle. These events will fire in</span>
<span class="c"> * addition to the global io events. The events are:</span>
<span class="c"> * start - This event is fired when a request is sent to a resource.</span>
<span class="c"> * complete - This event fires when the transaction is complete.</span>
<span class="c"> * success - This event fires when the response status resolves to</span>
<span class="c"> * HTTP 2xx.</span>
<span class="c"> * failure - This event fires when the response status resolves to</span>
<span class="c"> * HTTP 4xx, 5xx, and beyond.</span>
<span class="c"> * abort - This even is fired when a transaction abort is fire by</span>
<span class="c"> * timeout, or when it is manually aborted.</span>
<span class="c"> *</span>
<span class="c"> * The properties are:</span>
<span class="c"> * {</span>
<span class="c"> * start: function(id, args){},</span>
<span class="c"> * complete: function(id, responseobject, args){},</span>
<span class="c"> * success: function(id, responseobject, args){},</span>
<span class="c"> * failure: function(id, responseobject, args){},</span>
<span class="c"> * abort: function(id, args){}</span>
<span class="c"> * }</span>
<span class="c"> * Each property can reference a function or be written as an</span>
<span class="c"> * inline function.</span>
<span class="c"> *</span>
<span class="c"> * context: Object reference for an event handler when it is implemented</span>
<span class="c"> * as a method of a base object. Defining "context" will preserve</span>
<span class="c"> * the proper reference of "this" used in the event handler.</span>
<span class="c"> * headers: This is a defined object of client headers, as many as.</span>
<span class="c"> * desired for the transaction. These headers are sentThe object</span>
<span class="c"> * pattern is:</span>
<span class="c"> * {</span>
<span class="c"> * header: value</span>
<span class="c"> * }</span>
<span class="c"> *</span>
<span class="c"> * timeout: This value, defined as milliseconds, is a time threshold for the</span>
<span class="c"> * transaction. When this threshold is reached, and the transaction's</span>
<span class="c"> * Complete event has not yet fired, the transaction will be aborted.</span>
<span class="c"> * arguments: Object, array, string, or number passed to all registered</span>
<span class="c"> * event handlers. This value is available as the second</span>
<span class="c"> * argument in the "start" and "abort" event handlers; and, it is</span>
<span class="c"> * the third argument in the "complete", "success", and "failure"</span>
<span class="c"> * event handlers.</span>
<span class="c"> *</span>
<span class="c"> * @method _io</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {string} uri - qualified path to transaction resource.</span>
<span class="c"> * @param {object} c - configuration object for the transaction.</span>
<span class="c"> * @return object</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_io</span><span class="o">(</span><span class="nx">uri</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">c</span> <span class="o">||</span> <span class="o">{};</span>
<span class="k">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="nx">_create</span><span class="o">((</span><span class="nx">arguments</span><span class="o">.</span><span class="nx">length</span> <span class="o">===</span> <span class="m">3</span><span class="o">)</span> <span class="o">?</span> <span class="nx">arguments</span><span class="o">[</span><span class="m">2</span><span class="o">]</span> <span class="o">:</span> <span class="kc">null</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">method</span><span class="o">)</span> <span class="o">?</span> <span class="nx">c</span><span class="o">.</span><span class="nx">method</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">:</span> <span class="s1">'GET'</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">d</span> <span class="o">=</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">data</span><span class="o">)</span> <span class="o">?</span> <span class="nx">c</span><span class="o">.</span><span class="nx">data</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
<span class="c">/* Determine configuration properties */</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">form</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Serialize the HTML form into a string of name-value pairs.</span>
<span class="c"></span> <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">_serialize</span><span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">form</span><span class="o">);</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">d</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">f</span> <span class="o">+=</span> <span class="s2">"&"</span> <span class="o">+</span> <span class="nx">d</span><span class="o">;</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Configuration object.data added to serialized HTML form data. The string is: '</span> <span class="o">+</span> <span class="nx">f</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">m</span> <span class="o">===</span> <span class="s1">'POST'</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">d</span> <span class="o">=</span> <span class="nx">f</span><span class="o">;</span>
<span class="nx">_setHeader</span><span class="o">(</span><span class="s1">'Content-Type'</span><span class="o">,</span> <span class="s1">'application/x-www-form-urlencoded'</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">m</span> <span class="o">===</span> <span class="s1">'GET'</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">uri</span> <span class="o">=</span> <span class="nx">_concat</span><span class="o">(</span><span class="nx">uri</span><span class="o">,</span> <span class="nx">f</span><span class="o">);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Configuration object.data added to serialized HTML form data. The querystring is: '</span> <span class="o">+</span> <span class="nx">uri</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">d</span> <span class="o">&&</span> <span class="nx">m</span> <span class="o">===</span> <span class="s1">'GET'</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">uri</span> <span class="o">=</span> <span class="nx">_concat</span><span class="o">(</span><span class="nx">uri</span><span class="o">,</span> <span class="nx">c</span><span class="o">.</span><span class="nx">data</span><span class="o">);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Configuration object data added to URI. The querystring is: '</span> <span class="o">+</span> <span class="nx">uri</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">d</span> <span class="o">&&</span> <span class="nx">m</span> <span class="o">===</span> <span class="s1">'POST'</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_setHeader</span><span class="o">(</span><span class="s1">'Content-Type'</span><span class="o">,</span> <span class="s1">'application/x-www-form-urlencoded; charset=UTF-8'</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">xdr</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">]</span> <span class="o">=</span> <span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">d</span> <span class="o">&&</span> <span class="nx">m</span> <span class="o">!==</span> <span class="s1">'GET'</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">c</span><span class="o">.</span><span class="nx">data</span> <span class="o">=</span> <span class="nx">d</span><span class="o">;</span>
<span class="o">}</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">send</span><span class="o">(</span><span class="nx">uri</span><span class="o">,</span> <span class="nx">c</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
<span class="k">return</span> <span class="nx">o</span><span class="o">;</span>
<span class="o">}</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">timeout</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_startTimeout</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">/* End Configuration Properties */</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">onreadystatechange</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span> <span class="nx">_readyState</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span> <span class="o">};</span>
<span class="nx">_open</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">,</span> <span class="nx">m</span><span class="o">,</span> <span class="nx">uri</span><span class="o">);</span>
<span class="nx">_setHeaders</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">,</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">headers</span> <span class="o">||</span> <span class="o">{}));</span>
<span class="c">// Do not pass null, in the absence of data, as this</span>
<span class="c"></span> <span class="c">// results in a POST request with no Content-Length</span>
<span class="c"></span> <span class="c">// defined.</span>
<span class="c"></span> <span class="nx">_async</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="o">(</span><span class="nx">d</span> <span class="o">||</span> <span class="s1">''</span><span class="o">),</span> <span class="nx">c</span><span class="o">);</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">abort</span> <span class="o">=</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
<span class="nx">_ioAbort</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="o">}</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">isInProgress</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">return</span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">readyState</span> <span class="o">!==</span> <span class="m">4</span> <span class="o">&&</span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">readyState</span> <span class="o">!==</span> <span class="m">0</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">return</span> <span class="nx">o</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method for creating and subscribing transaction events.</span>
<span class="c"> *</span>
<span class="c"> * @method _tPubSub</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {string} e - event to be published</span>
<span class="c"> * @param {object} c - configuration object for the transaction.</span>
<span class="c"> *</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_tPubSub</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">c</span><span class="o">){</span>
<span class="k">var</span> <span class="nx">event</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">Target</span><span class="o">().</span><span class="nx">publish</span><span class="o">(</span><span class="s1">'transaction:'</span> <span class="o">+</span> <span class="nx">e</span><span class="o">);</span>
<span class="nx">event</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">[</span><span class="nx">e</span><span class="o">],</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">context</span> <span class="o">||</span> <span class="k">this</span><span class="o">),</span> <span class="nx">c</span><span class="o">.</span><span class="nx">arguments</span><span class="o">);</span>
<span class="k">return</span> <span class="nx">event</span><span class="o">;</span>
<span class="o">};</span>
<span class="k">function</span> <span class="nx">_ioXdrReady</span><span class="o">(</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">E_XDR_READY</span><span class="o">,</span> <span class="nx">id</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">/**</span>
<span class="c"> * @description Fires event "io:start" and creates, fires a</span>
<span class="c"> * defined.</span>
<span class="c"> *</span>
<span class="c"> * @method _ioStart</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {number} id - transaction id</span>
<span class="c"> * @param {object} c - configuration object for the transaction.</span>
<span class="c"> *</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_ioStart</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Set default value of argument c, property "on" to Object if</span>
<span class="c"></span> <span class="c">// the property is null or undefined.</span>
<span class="c"></span> <span class="nx">c</span><span class="o">.</span><span class="nx">on</span> <span class="o">=</span> <span class="nx">c</span><span class="o">.</span><span class="nx">on</span> <span class="o">||</span> <span class="o">{};</span>
<span class="k">var</span> <span class="nx">event</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">_fn</span><span class="o">[</span><span class="nx">id</span><span class="o">]</span> <span class="o">&&</span> <span class="nx">_fn</span><span class="o">[</span><span class="nx">id</span><span class="o">].</span><span class="nx">start</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">.</span><span class="nx">start</span> <span class="o">=</span> <span class="nx">_fn</span><span class="o">[</span><span class="nx">id</span><span class="o">].</span><span class="nx">start</span><span class="o">;</span>
<span class="o">}</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">E_START</span><span class="o">,</span> <span class="nx">id</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">.</span><span class="nx">start</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">event</span> <span class="o">=</span> <span class="nx">_tPubSub</span><span class="o">(</span><span class="s1">'start'</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="nx">event</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">id</span><span class="o">);</span>
<span class="o">}</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Transaction '</span> <span class="o">+</span> <span class="nx">id</span> <span class="o">+</span> <span class="s1">' started.'</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Fires event "io:complete" and creates, fires a</span>
<span class="c"> * defined.</span>
<span class="c"> *</span>
<span class="c"> * @method _ioComplete</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} id - transaction object.</span>
<span class="c"> * @param {object} c - configuration object for the transaction.</span>
<span class="c"> *</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_ioComplete</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Set default value of argument c, property "on" to Object if</span>
<span class="c"></span> <span class="c">// the property is null or undefined.</span>
<span class="c"></span> <span class="nx">c</span><span class="o">.</span><span class="nx">on</span> <span class="o">=</span> <span class="nx">c</span><span class="o">.</span><span class="nx">on</span> <span class="o">||</span> <span class="o">{};</span>
<span class="k">var</span> <span class="nx">event</span><span class="o">;</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">E_COMPLETE</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">.</span><span class="nx">complete</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">event</span> <span class="o">=</span> <span class="nx">_tPubSub</span><span class="o">(</span><span class="s1">'complete'</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="nx">event</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">);</span>
<span class="o">}</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Transaction '</span> <span class="o">+</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">' completed.'</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">/**</span>
<span class="c"> * @description Fires event "io:success" and creates, fires a</span>
<span class="c"> * defined.</span>
<span class="c"> *</span>
<span class="c"> * @method _ioSuccess</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} o - transaction object.</span>
<span class="c"> * @param {object} c - configuration object for the transaction.</span>
<span class="c"> *</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_ioSuccess</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Set default value of argument c, property "on" to Object if</span>
<span class="c"></span> <span class="c">// the property is null or undefined.</span>
<span class="c"></span> <span class="nx">c</span><span class="o">.</span><span class="nx">on</span> <span class="o">=</span> <span class="nx">c</span><span class="o">.</span><span class="nx">on</span> <span class="o">||</span> <span class="o">{};</span>
<span class="k">var</span> <span class="nx">event</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">]</span> <span class="o">&&</span> <span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">].</span><span class="nx">success</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">.</span><span class="nx">success</span> <span class="o">=</span> <span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">].</span><span class="nx">success</span><span class="o">;</span>
<span class="nx">delete</span> <span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">];</span>
<span class="c"></span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">responseText</span> <span class="o">=</span> <span class="nb">decodeURI</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">responseText</span><span class="o">);</span>
<span class="o">}</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">E_SUCCESS</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">.</span><span class="nx">success</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">event</span> <span class="o">=</span> <span class="nx">_tPubSub</span><span class="o">(</span><span class="s1">'success'</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="nx">event</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">);</span>
<span class="o">}</span>
<span class="nx">_destroy</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">xdr</span><span class="o">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span> <span class="o">);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'HTTP Status evaluates to Success. The transaction is: '</span> <span class="o">+</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">/**</span>
<span class="c"> * @description Fires event "io:failure" and creates, fires a</span>
<span class="c"> * defined.</span>
<span class="c"> *</span>
<span class="c"> * @method _ioFailure</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} o - transaction object.</span>
<span class="c"> * @param {object} c - configuration object for the transaction.</span>
<span class="c"> *</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_ioFailure</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Set default value of argument c, property "on" to Object if</span>
<span class="c"></span> <span class="c">// the property is null or undefined.</span>
<span class="c"></span> <span class="nx">c</span><span class="o">.</span><span class="nx">on</span> <span class="o">=</span> <span class="nx">c</span><span class="o">.</span><span class="nx">on</span> <span class="o">||</span> <span class="o">{};</span>
<span class="k">var</span> <span class="nx">event</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">]</span> <span class="o">&&</span> <span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">].</span><span class="nx">failure</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">.</span><span class="nx">failure</span> <span class="o">=</span> <span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">].</span><span class="nx">failure</span><span class="o">;</span>
<span class="nx">delete</span> <span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">];</span>
<span class="c"></span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">responseText</span> <span class="o">=</span> <span class="nb">decodeURI</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">responseText</span><span class="o">);</span>
<span class="o">}</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">E_FAILURE</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">.</span><span class="nx">failure</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">event</span> <span class="o">=</span> <span class="nx">_tPubSub</span><span class="o">(</span><span class="s1">'failure'</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="nx">event</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">);</span>
<span class="o">}</span>
<span class="nx">_destroy</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">xdr</span><span class="o">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span> <span class="o">);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'HTTP Status evaluates to Failure. The transaction is: '</span> <span class="o">+</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">/**</span>
<span class="c"> * @description Fires event "io:abort" and creates, fires a</span>
<span class="c"> * defined.</span>
<span class="c"> *</span>
<span class="c"> * @method _ioAbort</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} o - Transaction object generated by _create().</span>
<span class="c"> *</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_ioAbort</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Set default value of argument c, property "on" to Object if</span>
<span class="c"></span> <span class="c">// the property is null or undefined.</span>
<span class="c"></span> <span class="nx">c</span><span class="o">.</span><span class="nx">on</span> <span class="o">=</span> <span class="nx">c</span><span class="o">.</span><span class="nx">on</span> <span class="o">||</span> <span class="o">{};</span>
<span class="k">var</span> <span class="nx">event</span><span class="o">;</span>
<span class="k">if</span><span class="o">(</span><span class="nx">o</span> <span class="o">&&</span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">c</span><span class="o">.</span><span class="nx">xdr</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Terminate the transaction</span>
<span class="c"></span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">abort</span><span class="o">();</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// Clear the timeout poll for this specific transaction.</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">timeout</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_clearTimeout</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">]</span> <span class="o">&&</span> <span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">].</span><span class="nx">abort</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">.</span><span class="nx">abort</span> <span class="o">=</span> <span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">].</span><span class="nx">abort</span><span class="o">;</span>
<span class="nx">delete</span> <span class="nx">_fn</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">];</span>
<span class="o">}</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">E_ABORT</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">on</span><span class="o">.</span><span class="nx">abort</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">event</span> <span class="o">=</span> <span class="nx">_tPubSub</span><span class="o">(</span><span class="s1">'abort'</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="nx">event</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">id</span><span class="o">);</span>
<span class="o">}</span>
<span class="nx">_destroy</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">xdr</span><span class="o">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span> <span class="o">);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Transaction timeout or explicit abort. The transaction is: '</span> <span class="o">+</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">/**</span>
<span class="c"> * @description Method that creates the XMLHttpRequest transport</span>
<span class="c"> *</span>
<span class="c"> * @method _xhr</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @return object</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_xhr</span><span class="o">()</span> <span class="o">{</span>
<span class="k">return</span> <span class="o">(</span><span class="nx">w</span><span class="o">.</span><span class="nx">XMLHttpRequest</span><span class="o">)</span> <span class="o">?</span> <span class="k">new</span> <span class="nx">XMLHttpRequest</span><span class="o">()</span> <span class="o">:</span> <span class="k">new</span> <span class="nx">ActiveXObject</span><span class="o">(</span><span class="s1">'Microsoft.XMLHTTP'</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method that creates the Flash transport swf.</span>
<span class="c"> *</span>
<span class="c"> * @method _swf</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {string} yid - string representation of YUI instance.</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_swf</span><span class="o">(</span><span class="nx">uri</span><span class="o">,</span> <span class="nx">yid</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">b</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Node</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">"body"</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">swf</span> <span class="o">=</span> <span class="s1">'<object id="yuiSwfIo" type="application/x-shockwave-flash" data="'</span> <span class="o">+</span> <span class="nx">uri</span> <span class="o">+</span> <span class="s1">'" width="0" height="0">'</span><span class="o">;</span>
<span class="nx">swf</span> <span class="o">+=</span> <span class="s1">'<param name="movie" value="'</span> <span class="o">+</span> <span class="nx">uri</span> <span class="o">+</span> <span class="s1">'">'</span><span class="o">;</span>
<span class="nx">swf</span> <span class="o">+=</span> <span class="s1">'<param name="FlashVars" value="yid='</span> <span class="o">+</span> <span class="nx">yid</span> <span class="o">+</span> <span class="s1">'">'</span><span class="o">;</span>
<span class="nx">swf</span> <span class="o">+=</span> <span class="s1">'<param name="allowScriptAccess" value="sameDomain">'</span><span class="o">;</span>
<span class="nx">swf</span> <span class="o">+=</span> <span class="s1">'</object>'</span><span class="o">;</span>
<span class="nx">b</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">Node</span><span class="o">.</span><span class="nx">create</span><span class="o">(</span><span class="nx">swf</span><span class="o">))</span>
<span class="nx">_xdr</span><span class="o">.</span><span class="nx">flash</span> <span class="o">=</span> <span class="nx">d</span><span class="o">.</span><span class="nx">getElementById</span><span class="o">(</span><span class="s1">'yuiSwfIo'</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method that increments _transactionId for each transaction.</span>
<span class="c"> *</span>
<span class="c"> * @method _id</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @return int</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_id</span><span class="o">()</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">transactionId</span><span class="o">;</span>
<span class="nx">transactionId</span><span class="o">++;</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Transaction id generated. The id is: '</span> <span class="o">+</span> <span class="nx">id</span><span class="o">,</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="k">return</span> <span class="nx">id</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method that creates a unique transaction object for each</span>
<span class="c"> * request..</span>
<span class="c"> *</span>
<span class="c"> * @method _create</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {number} s - URI or root data.</span>
<span class="c"> * @param {number} c - configuration object</span>
<span class="c"> * @return object</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_create</span><span class="o">(</span><span class="nx">i</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="o">{};</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">i</span><span class="o">)</span> <span class="o">?</span> <span class="nx">i</span> <span class="o">:</span> <span class="nx">_id</span><span class="o">();</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">c</span> <span class="o">&&</span> <span class="nx">c</span><span class="o">.</span><span class="nx">xdr</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">c</span> <span class="o">=</span> <span class="nx">_xdr</span><span class="o">[</span><span class="nx">c</span><span class="o">.</span><span class="nx">xdr</span><span class="o">.</span><span class="nx">use</span><span class="o">];</span>
<span class="o">}</span>
<span class="k">else</span> <span class="o">{</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">c</span> <span class="o">=</span> <span class="nx">_xhr</span><span class="o">();</span>
<span class="o">}</span>
<span class="k">return</span> <span class="nx">o</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method that concatenates string data for HTTP GET transactions.</span>
<span class="c"> *</span>
<span class="c"> * @method _concat</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {string} s - URI or root data.</span>
<span class="c"> * @param {string} d - data to be concatenated onto URI.</span>
<span class="c"> * @return int</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_concat</span><span class="o">(</span><span class="nx">s</span><span class="o">,</span> <span class="nx">d</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">s</span> <span class="o">+=</span> <span class="o">((</span><span class="nx">s</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">'?'</span><span class="o">)</span> <span class="o">==</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">?</span> <span class="s1">'?'</span> <span class="o">:</span> <span class="s1">'&'</span><span class="o">)</span> <span class="o">+</span> <span class="nx">d</span><span class="o">;</span>
<span class="k">return</span> <span class="nx">s</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method that stores default client headers for all transactions.</span>
<span class="c"> * If a label is passed with no value argument, the header will be deleted.</span>
<span class="c"> *</span>
<span class="c"> * @method _setHeader</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {string} l - HTTP header</span>
<span class="c"> * @param {string} v - HTTP header value</span>
<span class="c"> * @return int</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_setHeader</span><span class="o">(</span><span class="nx">l</span><span class="o">,</span> <span class="nx">v</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">v</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_headers</span><span class="o">[</span><span class="nx">l</span><span class="o">]</span> <span class="o">=</span> <span class="nx">v</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">else</span> <span class="o">{</span>
<span class="nx">delete</span> <span class="nx">_headers</span><span class="o">[</span><span class="nx">l</span><span class="o">];</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method to initialize the desired transport medium.</span>
<span class="c"> *</span>
<span class="c"> * @method _initTransport</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} o - object of transport configurations.</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_initTransport</span><span class="o">(</span><span class="nx">o</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">switch</span> <span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">case</span> <span class="s1">'flash'</span><span class="o">:</span>
<span class="nx">_swf</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">src</span><span class="o">,</span> <span class="nx">o</span><span class="o">.</span><span class="nx">yid</span><span class="o">);</span>
<span class="k">break</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method that sets all HTTP headers to be sent in a transaction.</span>
<span class="c"> *</span>
<span class="c"> * @method _setHeaders</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} o - XHR instance for the specific transaction.</span>
<span class="c"> * @param {object} h - HTTP headers for the specific transaction, as defined</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_setHeaders</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">h</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">p</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">p</span> <span class="k">in</span> <span class="nx">_headers</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">_headers</span><span class="o">.</span><span class="nx">hasOwnProperty</span><span class="o">(</span><span class="nx">p</span><span class="o">))</span> <span class="o">{</span>
<span class="nx">h</span><span class="o">[</span><span class="nx">p</span><span class="o">]</span> <span class="o">=</span> <span class="nx">_headers</span><span class="o">[</span><span class="nx">p</span><span class="o">];</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'Default HTTP header '</span> <span class="o">+</span> <span class="nx">p</span> <span class="o">+</span> <span class="s1">' found with value of '</span> <span class="o">+</span> <span class="nx">_headers</span><span class="o">[</span><span class="nx">p</span><span class="o">],</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">p</span> <span class="k">in</span> <span class="nx">h</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">h</span><span class="o">.</span><span class="nx">hasOwnProperty</span><span class="o">(</span><span class="nx">p</span><span class="o">))</span> <span class="o">{</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">setRequestHeader</span><span class="o">(</span><span class="nx">p</span><span class="o">,</span> <span class="nx">h</span><span class="o">[</span><span class="nx">p</span><span class="o">]);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'HTTP Header '</span> <span class="o">+</span> <span class="nx">p</span> <span class="o">+</span> <span class="s1">' set with value of '</span> <span class="o">+</span> <span class="nx">h</span><span class="o">[</span><span class="nx">p</span><span class="o">],</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="k">function</span> <span class="nx">_open</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">m</span><span class="o">,</span> <span class="nx">uri</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">open</span><span class="o">(</span><span class="nx">m</span><span class="o">,</span> <span class="nx">uri</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method that sends the transaction request.</span>
<span class="c"> *</span>
<span class="c"> * @method _async</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} o - Transaction object generated by _create().</span>
<span class="c"> * @param {string} d - Transaction data.</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_async</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">d</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">send</span><span class="o">(</span><span class="nx">d</span><span class="o">);</span>
<span class="nx">_ioStart</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Starts timeout count if config,timeout is defined.</span>
<span class="c"> *</span>
<span class="c"> * @method _startTimeout</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} o - Transaction object generated by _create().</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_startTimeout</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_timeout</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">]</span> <span class="o">=</span> <span class="nx">w</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span> <span class="nx">_ioAbort</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span> <span class="o">},</span> <span class="nx">c</span><span class="o">.</span><span class="nx">timeout</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Clears the timeout interval started by _startTimeout().</span>
<span class="c"> *</span>
<span class="c"> * @method _clearTimeout</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {number} id - Transaction id.</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_clearTimeout</span><span class="o">(</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">w</span><span class="o">.</span><span class="nx">clearTimeout</span><span class="o">(</span><span class="nx">_timeout</span><span class="o">[</span><span class="nx">id</span><span class="o">]);</span>
<span class="nx">delete</span> <span class="nx">_timeout</span><span class="o">[</span><span class="nx">id</span><span class="o">];</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Event handler bound to onreadystatechange.</span>
<span class="c"> *</span>
<span class="c"> * @method _readyState</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} o - Transaction object generated by _create().</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_readyState</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">readyState</span> <span class="o">===</span> <span class="m">4</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">c</span><span class="o">.</span><span class="nx">timeout</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_clearTimeout</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
<span class="o">}</span>
<span class="nx">_ioComplete</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="nx">_handleResponse</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method that determines if a transaction response qualifies</span>
<span class="c"> * as success or failure, based on the response HTTP status code, and</span>
<span class="c"> * fires the appropriate success or failure events.</span>
<span class="c"> *</span>
<span class="c"> * @method _handleResponse</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} o - Transaction object generated by _create().</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_handleResponse</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">status</span><span class="o">;</span>
<span class="k">try</span><span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">status</span> <span class="o">&&</span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">status</span> <span class="o">!==</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">status</span> <span class="o">=</span> <span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">status</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">else</span> <span class="o">{</span>
<span class="nx">status</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">catch</span><span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">status</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'HTTP status unreadable. The transaction is: '</span> <span class="o">+</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="s1">'warn'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">/*</span>
<span class="c"> * IE reports HTTP 204 as HTTP 1223.</span>
<span class="c"> * However, the response data are still available.</span>
<span class="c"> */</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">status</span> <span class="o">>=</span> <span class="m">200</span> <span class="o">&&</span> <span class="nx">status</span> <span class="o"><</span> <span class="m">300</span> <span class="o">||</span> <span class="nx">status</span> <span class="o">===</span> <span class="m">1223</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_ioSuccess</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">else</span> <span class="o">{</span>
<span class="nx">_ioFailure</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">c</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="k">function</span> <span class="nx">_destroy</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">isXdr</span><span class="o">)</span> <span class="o">{</span>
<span class="c">// IE6 will throw a "Type Mismatch" error if the event handler is set to "null".</span>
<span class="c"></span> <span class="k">if</span><span class="o">(</span><span class="nx">w</span><span class="o">.</span><span class="nx">XMLHttpRequest</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">isXdr</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">c</span><span class="o">.</span><span class="nx">onreadystatechange</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="nx">o</span><span class="o">.</span><span class="nx">c</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="nx">o</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * @description Method to enumerate through an HTML form's elements collection</span>
<span class="c"> * and return a string comprised of key-value pairs.</span>
<span class="c"> *</span>
<span class="c"> * @method _serialize</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} c - Configuration object specific to form operations..</span>
<span class="c"> * @return string</span>
<span class="c"> */</span>
<span class="k">function</span> <span class="nx">_serialize</span><span class="o">(</span><span class="nx">o</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">str</span> <span class="o">=</span> <span class="s1">''</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span> <span class="o">===</span> <span class="s1">'object'</span><span class="o">)</span> <span class="o">?</span> <span class="nx">o</span><span class="o">.</span><span class="nx">id</span> <span class="o">:</span> <span class="nx">d</span><span class="o">.</span><span class="nx">getElementById</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">useDf</span> <span class="o">=</span> <span class="nx">o</span><span class="o">.</span><span class="nx">useDisabled</span> <span class="o">||</span> <span class="kc">false</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">eUC</span> <span class="o">=</span> <span class="nb">encodeURIComponent</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">e</span><span class="o">,</span> <span class="nx">n</span><span class="o">,</span> <span class="nx">v</span><span class="o">,</span> <span class="nx">dF</span><span class="o">;</span>
<span class="c">// Iterate over the form elements collection to construct the name-value pairs.</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">f</span><span class="o">.</span><span class="nx">elements</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
<span class="nx">e</span> <span class="o">=</span> <span class="nx">f</span><span class="o">.</span><span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
<span class="nx">dF</span> <span class="o">=</span> <span class="nx">e</span><span class="o">.</span><span class="nx">disabled</span><span class="o">;</span>
<span class="nx">n</span> <span class="o">=</span> <span class="nx">e</span><span class="o">.</span><span class="nx">name</span><span class="o">;</span>
<span class="nx">v</span> <span class="o">=</span> <span class="nx">e</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
<span class="c"></span> <span class="c">//will be included in the serialized data.</span>
<span class="c"></span> <span class="k">if</span> <span class="o">((</span><span class="nx">useDf</span><span class="o">)</span> <span class="o">?</span> <span class="nx">n</span> <span class="o">:</span> <span class="o">(</span><span class="nx">n</span> <span class="o">&&</span> <span class="nx">dF</span><span class="o">));</span>
<span class="o">{</span>
<span class="nx">switch</span> <span class="o">(</span><span class="nx">e</span><span class="o">.</span><span class="nx">type</span><span class="o">)</span>
<span class="o">{</span>
<span class="nx">case</span> <span class="s1">'select-one'</span><span class="o">:</span>
<span class="nx">case</span> <span class="s1">'select-multiple'</span><span class="o">:</span>
<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">j</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">j</span> <span class="o"><</span> <span class="nx">e</span><span class="o">.</span><span class="nx">options</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">e</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">selected</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span><span class="o">.</span><span class="nx">ie</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">str</span> <span class="o">+=</span> <span class="nx">eUC</span><span class="o">(</span><span class="nx">n</span><span class="o">)</span> <span class="o">+</span> <span class="s1">'='</span> <span class="o">+</span> <span class="nx">eUC</span><span class="o">(</span><span class="nx">e</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">attributes</span><span class="o">[</span><span class="s1">'value'</span><span class="o">].</span><span class="nx">specified</span> <span class="o">?</span> <span class="nx">e</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">value</span> <span class="o">:</span> <span class="nx">e</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">text</span><span class="o">)</span> <span class="o">+</span> <span class="s1">'&'</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">else</span> <span class="o">{</span>
<span class="nx">str</span> <span class="o">+=</span> <span class="nx">eUC</span><span class="o">(</span><span class="nx">n</span><span class="o">)</span> <span class="o">+</span> <span class="s1">'='</span> <span class="o">+</span> <span class="nx">eUC</span><span class="o">(</span><span class="nx">e</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">hasAttribute</span><span class="o">(</span><span class="s1">'value'</span><span class="o">)</span> <span class="o">?</span> <span class="nx">e</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">value</span> <span class="o">:</span> <span class="nx">e</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">text</span><span class="o">)</span> <span class="o">+</span> <span class="s1">'&'</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">break</span><span class="o">;</span>
<span class="nx">case</span> <span class="s1">'radio'</span><span class="o">:</span>
<span class="nx">case</span> <span class="s1">'checkbox'</span><span class="o">:</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">e</span><span class="o">.</span><span class="nx">checked</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">str</span> <span class="o">+=</span> <span class="nx">eUC</span><span class="o">(</span><span class="nx">n</span><span class="o">)</span> <span class="o">+</span> <span class="s1">'='</span> <span class="o">+</span> <span class="nx">eUC</span><span class="o">(</span><span class="nx">v</span><span class="o">)</span> <span class="o">+</span> <span class="s1">'&'</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">break</span><span class="o">;</span>
<span class="nx">case</span> <span class="s1">'file'</span><span class="o">:</span>
<span class="nx">case</span> <span class="kc">undefined</span><span class="o">:</span>
<span class="nx">case</span> <span class="s1">'reset'</span><span class="o">:</span>
<span class="nx">case</span> <span class="s1">'button'</span><span class="o">:</span>
<span class="k">break</span><span class="o">;</span>
<span class="nx">case</span> <span class="s1">'submit'</span><span class="o">:</span>
<span class="nx">default</span><span class="o">:</span>
<span class="nx">str</span> <span class="o">+=</span> <span class="nx">eUC</span><span class="o">(</span><span class="nx">n</span><span class="o">)</span> <span class="o">+</span> <span class="s1">'='</span> <span class="o">+</span> <span class="nx">eUC</span><span class="o">(</span><span class="nx">v</span><span class="o">)</span> <span class="o">+</span> <span class="s1">'&'</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'HTML form serialized. The value is: '</span> <span class="o">+</span> <span class="nx">str</span><span class="o">.</span><span class="nx">substr</span><span class="o">(</span><span class="m">0</span><span class="o">,</span> <span class="nx">str</span><span class="o">.</span><span class="nx">length</span> <span class="o">-</span> <span class="m">1</span><span class="o">),</span> <span class="s1">'info'</span><span class="o">,</span> <span class="s1">'io'</span><span class="o">);</span>
<span class="k">return</span> <span class="nx">str</span><span class="o">.</span><span class="nx">substr</span><span class="o">(</span><span class="m">0</span><span class="o">,</span> <span class="nx">str</span><span class="o">.</span><span class="nx">length</span> <span class="o">-</span> <span class="m">1</span><span class="o">);</span>
<span class="o">};</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">xdrReady</span> <span class="o">=</span> <span class="nx">_ioXdrReady</span><span class="o">;</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">start</span> <span class="o">=</span> <span class="nx">_ioStart</span><span class="o">;</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">success</span> <span class="o">=</span> <span class="nx">_ioSuccess</span><span class="o">;</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">failure</span> <span class="o">=</span> <span class="nx">_ioFailure</span><span class="o">;</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">abort</span> <span class="o">=</span> <span class="nx">_ioAbort</span><span class="o">;</span>
<span class="c">//--------------------------------------</span>
<span class="c"></span> <span class="c">// Begin public interface definition</span>
<span class="c"></span> <span class="c">//--------------------------------------</span>
<span class="c"></span> <span class="c">/**</span>
<span class="c"> * @description Method that stores default client headers for all transactions.</span>
<span class="c"> * If a label is passed with no value argument, the header will be deleted.</span>
<span class="c"> * This is the interface for _setHeader().</span>
<span class="c"> *</span>
<span class="c"> * @method header</span>
<span class="c"> * @public</span>
<span class="c"> * @static</span>
<span class="c"> * @param {string} l - HTTP header</span>
<span class="c"> * @param {string} v - HTTP header value</span>
<span class="c"> * @return int</span>
<span class="c"> */</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">header</span> <span class="o">=</span> <span class="nx">_setHeader</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * @description Method for specifying and initializing a transport</span>
<span class="c"> * to facilitate cross-domain HTTP requests. This is the</span>
<span class="c"> * interface for _initTransport</span>
<span class="c"> *</span>
<span class="c"> * @method transport</span>
<span class="c"> * @public</span>
<span class="c"> * @static</span>
<span class="c"> * @param {object} t - configuration object for the transport.</span>
<span class="c"> * @return boolean</span>
<span class="c"> */</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">transport</span> <span class="o">=</span> <span class="nx">_initTransport</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * @description Method for requesting a transaction, and queueing the</span>
<span class="c"> * request before it is sent to the resource. This is the</span>
<span class="c"> * interface for _queue().</span>
<span class="c"> *</span>
<span class="c"> * @method queue</span>
<span class="c"> * @public</span>
<span class="c"> * @static</span>
<span class="c"> * @param {string} uri - qualified path to transaction resource.</span>
<span class="c"> * @param {object} c - configuration object for the transaction.</span>
<span class="c"> * @return int</span>
<span class="c"> */</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">queue</span> <span class="o">=</span> <span class="nx">_queue</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * @description Method to query the current size of the queue, or to</span>
<span class="c"> * set a maximum queue size. This is the interface for _size().</span>
<span class="c"> *</span>
<span class="c"> * @method size</span>
<span class="c"> * @public</span>
<span class="c"> * @static</span>
<span class="c"> * @param {number} i - Specified maximum size of queue.</span>
<span class="c"> * @return number</span>
<span class="c"> */</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">queue</span><span class="o">.</span><span class="nx">size</span> <span class="o">=</span> <span class="nx">_size</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * @description Method for setting the queue to "active". If there are</span>
<span class="c"> * transactions pending in the queue, they will be processed from the</span>
<span class="c"> * queue in FIFO order. This is the interface for _start().</span>
<span class="c"> *</span>
<span class="c"> * @method start</span>
<span class="c"> * @public</span>
<span class="c"> * @static</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">queue</span><span class="o">.</span><span class="nx">start</span> <span class="o">=</span> <span class="nx">_start</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * @description Method for setting queue processing to inactive.</span>
<span class="c"> * not processed until the queue is set to "active". This is the</span>
<span class="c"> * interface for _stop().</span>
<span class="c"> *</span>
<span class="c"> * @method stop</span>
<span class="c"> * @public</span>
<span class="c"> * @static</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">queue</span><span class="o">.</span><span class="nx">stop</span> <span class="o">=</span> <span class="nx">_stop</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * @description Method for promoting a transaction to the top of the queue.</span>
<span class="c"> * This is the interface for _unshift().</span>
<span class="c"> *</span>
<span class="c"> * @method promote</span>
<span class="c"> * @public</span>
<span class="c"> * @static</span>
<span class="c"> * @param {number} i - ID of queued transaction.</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">queue</span><span class="o">.</span><span class="nx">promote</span> <span class="o">=</span> <span class="nx">_unshift</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * @description Method for removing a specific, pending transaction from</span>
<span class="c"> * the queue. This is the interface for _purge().</span>
<span class="c"> *</span>
<span class="c"> * @method purge</span>
<span class="c"> * @public</span>
<span class="c"> * @static</span>
<span class="c"> * @param {number} i - ID of queued transaction.</span>
<span class="c"> * @return void</span>
<span class="c"> */</span>
<span class="nx">_io</span><span class="o">.</span><span class="nx">queue</span><span class="o">.</span><span class="nx">purge</span> <span class="o">=</span> <span class="nx">_purge</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * @description Method for requesting a transaction. This</span>
<span class="c"> * is the interface for _io().</span>
<span class="c"> *</span>
<span class="c"> * @method io</span>
<span class="c"> * @public</span>
<span class="c"> * @static</span>
<span class="c"> * @param {string} uri - qualified path to transaction resource.</span>
<span class="c"> * @param {object} c - configuration object for the transaction.</span>
<span class="c"> * @return object</span>
<span class="c"> */</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">io</span> <span class="o">=</span> <span class="nx">_io</span><span class="o">;</span>
<span class="o">},</span> <span class="s2">"3.0.0"</span><span class="o">);</span>
</pre></div>
</div>
</div>
</div>
<div class="yui-b">
<div class="nav">
<div class="module">
<h4>Modules</h4>
<ul class="content">
</ul>
</div>
<div class="module">
<h4>Classes</h4>
<ul class="content">
</ul>
</div>
<div class="module">
<h4>Files</h4>
<ul class="content">
</ul>
</div>
</div>
</div>
</div>
<div id="ft">
<hr />
Copyright © 2008 Yahoo! Inc. All rights reserved.
</div>
</div>
</body>
</html>