-
Notifications
You must be signed in to change notification settings - Fork 3
/
docs.html
executable file
·38 lines (29 loc) · 9.45 KB
/
docs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>SACK Documentation</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="author" content="Gregory Wild-Smith"/><meta name="copyright" content="Gregory Wild-Smith"/><link rel="stylesheet" href="style.css" type="text/css"/></head><body>
<h1>SACK v1.5<span>(Public)</span></h1>
<p><small>©2005 Gregory Wild-Smith (http://www.twilightuniverse.com/)</small></p>
<p><small><code>This software is distributed under a <a href="http://www.twilightuniverse.com/projects/sack/sack-licence.html">Modified X11</a> licence. See distributed doumentation or authors website for more details. If you use this code a link or email would be nice but is not required.</code></small></p>
<p>The Simple AJAX Code-Kit (SACK) is a wrapper class designed to make using AJAX simpler, and easy to implement. More information can be found at the authors website.</p>
<p><small>Last Updated: 1st January 2006</small></p>
<h2>Class Methods</h2>
<dl><dt><h3>sack <span>(Public)</span></h3></dt><dd><p>usage: <span class="func_type">object</span> <span class="func_name">sack</span><span class="params">(<span class="param_type">string</span> <var>file</var>)</span></p><p>Initialising function for SACK Object.</p><dl><dt><span class="param_type">string</span> <var>file</var></dt><dd><p>(optional) The filename of the file to be accessed using XMLHttpRequest. Passes its contents to the requestFile variable.</p></dd></dl></dd><dt><h3>createAJAX <span>(Private)</span></h3></dt><dd><p>usage: <span class="func_type">void</span> <span class="func_name">createAJAX</span><span class="params">()</span></p><p>Constructor function for SACK data. Initialises the XMLHttpRequest object in compatible browsers and if this is not supported sets the failed variable to false.</p></dd><dt><h3>setVar <span>(Public)</span></h3></dt><dd><p>usage: <span class="func_type">void</span> <span class="func_name">setVar</span><span class="params">(<span class="param_type">string</span> <var>name</var>, <span class="param_type">string</span> <var>value</var>)</span></p><p>Allows you to add a variable to be parsed into the URLString data in the form of a name/value pair. Does not encode the data.</p><dl><dt><span class="param_type">string</span> <var>name</var></dt><dd><p>The name of the data that you want passed to the requestFile.</p></dd></dl><dl><dt><span class="param_type">string</span> <var>value</var></dt><dd><p>The corrisponding data that you want passed to the requestFile.</p></dd></dl></dd><dt><h3>encVar <span>(Private)</span></h3></dt><dd><p>usage: <span class="func_type">string</span> <span class="func_name">encVar</span><span class="params">(<span class="param_type">string</span> <var>name</var>, <span class="param_type">string</span> <var>value</var>)</span></p><p>Allows you to add a variable to be parsed into the URLString data, in the form of a name/value pair, and URLencodes the data into a unicode compatible escape sequence.</p><dl><dt><span class="param_type">string</span> <var>name</var></dt><dd><p>The name of the data that you want passed to the requestFile.</p></dd></dl><dl><dt><span class="param_type">string</span> <var>value</var></dt><dd><p>The corrisponding data that you want passed to the requestFile.</p></dd></dl></dd><dt><h3>processURLString <span>(Private)</span></h3></dt><dd><p>usage: <span class="func_type">string</span> <span class="func_name">processURLString</span><span class="params">(<span class="param_type">string</span> <var>string</var>, <span class="param_type">boolean</span> <var>encode</var>)</span></p><p>Splits up an URLString formatted string, and passes the name/value pairs to the variable setting functions.</p><dl><dt><span class="param_type">string</span> <var>string</var></dt><dd><p>The name of the data that you want passed to the requestFile.</p></dd></dl><dl><dt><span class="param_type">boolean</span> <var>encode</var></dt><dd><p>If the passed string should be encoded.</p></dd></dl></dd><dt><h3>createURLString <span>(Public)</span></h3></dt><dd><p>usage: <span class="func_type">void</span> <span class="func_name">createURLString</span><span class="params">(<span class="param_type">string</span> <var>urlstring</var>)</span></p><p>Creates a correctly formatted URLString from any existing and/or passed data.</p><dl><dt><span class="param_type">string</span> <var>urlstring</var></dt><dd><p>(optional) A correctly formatted URLstring which will be added to the existing variable data (if any).</p></dd></dl></dd><dt><h3>runResponse <span>(Public)</span></h3></dt><dd><p>usage: <span class="func_type">void</span> <span class="func_name">runResponse</span><span class="params">()</span></p><p>Evaluates the response text as javascript commands, and runs any present.</p></dd><dt><h3>resetData <span>(Public)</span></h3></dt><dd><p>usage: <span class="func_type">void</span> <span class="func_name">resetData</span><span class="params">()</span></p><p>Resets all the library variables back to their default values.</p></dd><dt><h3>resetFunctions <span>(Public)</span></h3></dt><dd><p>usage: <span class="func_type">void</span> <span class="func_name">resetFunctions</span><span class="params">()</span></p><p>Resets the onEvent functions back to their default state.</p></dd><dt><h3>reset <span>(Public)</span></h3></dt><dd><p>usage: <span class="func_type">void</span> <span class="func_name">reset</span><span class="params">()</span></p><p>Runs both resetData and resetFunctions. Effectively resets all data to the same as when the original object was initialised.</p></dd><dt><h3>runAJAX <span>(Public)</span></h3></dt><dd><p>usage: <span class="func_type">string</span> <span class="func_name">runAJAX</span><span class="params">(<span class="param_type">string</span> <var>urlstring</var>)</span></p><p>Runs the AJAX request. And fills class variables with appropriate responses (response, responseXML, responseStatus, etc). If the encodeURIString variable is set to true (default) then will escape the name/value pairs in the URLstring variable. If an element has been set then the elements contents (innerHTML or value) will be replaced. If the execute variable is set to true then will call the runResponse method.</p><dl><dt><span class="param_type">string</span> <var>urlstring</var></dt><dd><p>(optional) A string of name/value pairs formatted in the GET URL String style (eg: var1=data1&var2=data2).</p></dd></dl></dd></dl><h2>Class Variables</h2>
<p>(<span class="var_type">String</span>) <var>AjaxFailedAlert</var> - Holds a warning that will be used to alert users that their browser does not support XMLHttpRequest. To turn off warning set to null. Has a default message.</p>
<p>(<span class="var_type">String</span>) <var>requestFile</var> - Holds the file that the request will be sent to.</p>
<p>(<span class="var_type">String</span>) <var>method</var> - The http method used to communicate with the file, can be any valid method though GET and POST will probably be most common. Defaults to POST.</p>
<p>(<span class="var_type">String</span>) <var>element</var> - The element to replace the contents of with the response text. Is not set by default.</p>
<p>(<span class="var_type">String</span>) <var>URLString</var> - List of variables and values in GET style format name/value pairs seperated by &'s.</p>
<p>(<span class="var_type">Boolean</span>) <var>encodeURIString</var> - Whether to escape the data in the string. Set to false if you do this yourself, or use only ASCII characters. Defaults to true.</p>
<p>(<span class="var_type">Boolean</span>) <var>execute</var> - Set to true if you want to evaluate the response text as if it was javascript code, and run it. Defaults to false.</p>
<p>(<span class="var_type">function</span>) <var>onLoading</var> - Pass this variable a javascript function without arguments that you wish to run when Loading.</p>
<p>(<span class="var_type">function</span>) <var>onLoaded</var> - Pass this variable a javascript function without arguments that you wish to run when Loaded.</p>
<p>(<span class="var_type">function</span>) <var>onInteractive</var> - Pass this variable a javascript function without arguments that you wish to run when Interactive (data is being streamed).</p>
<p>(<span class="var_type">function</span>) <var>onCompletion</var> - Pass this variable a javascript function without arguments that you wish to run when Completed.</p>
<p>(<span class="var_type">function</span>) <var>onError</var> - Pass this variable a javascript function without arguments that you wish to run when the response code from the server is not 200 (i.e. there has been an error or problem).</p>
<p>(<span class="var_type">Array</span>) <var>responseStatus</var> - Array of the response status returned. 0 index is the response code (eg 404, 300, etc) and the 1 index is the text description.</p>
<p>(<span class="var_type">Boolean</span>) <var>failed</var> - Allows you to detect if the software supports XMLHttpRequest (true) or not (false).</p>
<p>(<span class="var_type">String</span>) <var>response</var> - The response text recieved from the server.</p>
<p>(<span class="var_type">String</span>) <var>responseXML</var> - The response xml revieved from the server.</p>
<p>(<span class="var_type">Array</span>) <var>vars</var> - Holds data to be passed (via the URL String) to the server. Uses the name from the name/value pair as the array key. Also holds the encoded state of the data.</p>
</body>
</html>