aboutsummaryrefslogtreecommitdiffstats
path: root/docs/html/overview-summary-xmlrpc.js.html
blob: fa8f78614b9fa68494cc8b147cc551598f4efd87 (plain) (blame)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="xmlrpc.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>xmlrpc.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'xmlrpc.js'<BR/><BR/>
	
</p>

<hr>



<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">// Released under the MIT/X11 license</span>
<span class="comment">// http://www.opensource.org/licenses/mit-license.php</span>
<span class="literal">"use strict"</span>;
<span class="comment">/*
 *
 * xmlrpc.js beta version 1 Tool for creating XML-RPC formatted requests in
 * JavaScript
 *
 * Copyright 2001 Scott Andrew LePera scott<span class="attrib">@scottandrew</span>.com
 * http://www.scottandrew.com/xml-rpc
 *
 * License: You are granted the right to use and/or redistribute this code only
 * if this license and the copyright notice are included and you accept that no
 * warranty of any kind is made or implied by the author.
 *
 */</span>

var XMLRPCMessage = exports.XMLRPCMessage = <span class="reserved">function</span> XMLRPCMessage(methodname) {
    <span class="reserved">this</span>.method = methodname || <span class="literal">"system.listMethods"</span>;
    <span class="reserved">this</span>.params = [];
    <span class="reserved">return</span> <span class="reserved">this</span>;
};

XMLRPCMessage.<span class="reserved">prototype</span>.setMethod = <span class="reserved">function</span>(methodName) {
    <span class="reserved">if</span> (!methodName) <span class="reserved">return</span>;
    <span class="reserved">this</span>.method = methodName;
};

XMLRPCMessage.<span class="reserved">prototype</span>.addParameter = <span class="reserved">function</span>(data) {
    <span class="reserved">if</span> (arguments.length == 0) <span class="reserved">return</span>;
    <span class="reserved">this</span>.params[<span class="reserved">this</span>.params.length] = data;
};

XMLRPCMessage.<span class="reserved">prototype</span>.xml = <span class="reserved">function</span>() {

    var method = <span class="reserved">this</span>.method;

    <span class="comment">// assemble the XML message header</span>
    var xml = <span class="literal">""</span>;

    xml += <span class="literal">"&lt;?xml version=\"</span>1.0\<span class="literal">"?&gt;\n"</span>;
    xml += <span class="literal">"&lt;methodCall&gt;\n"</span>;
    xml += <span class="literal">"&lt;methodName&gt;"</span> + method + <span class="literal">"&lt;/methodName&gt;\n"</span>;
    xml += <span class="literal">"&lt;params&gt;\n"</span>;

    <span class="comment">// do individual parameters</span>
    <span class="reserved">for</span> ( var i = 0; i &lt; <span class="reserved">this</span>.params.length; i++) {
        var data = <span class="reserved">this</span>.params[i];
        xml += <span class="literal">"&lt;param&gt;\n"</span>;
        xml += <span class="literal">"&lt;value&gt;"</span>
                + <span class="reserved">this</span>.getParamXML(<span class="reserved">this</span>.dataTypeOf(data),
                        data) + <span class="literal">"&lt;/value&gt;\n"</span>;
        xml += <span class="literal">"&lt;/param&gt;\n"</span>;
    }

    xml += <span class="literal">"&lt;/params&gt;\n"</span>;
    xml += <span class="literal">"&lt;/methodCall&gt;"</span>;

    <span class="reserved">return</span> xml; <span class="comment">// for now</span>
};

XMLRPCMessage.<span class="reserved">prototype</span>.dataTypeOf = <span class="reserved">function</span>(o) {
    <span class="comment">// identifies the data type</span>
    var type = typeof (o);
    type = type.toLowerCase();
    switch (type) {
    case <span class="literal">"number"</span>:
        <span class="reserved">if</span> (Math.round(o) == o)
            type = <span class="literal">"i4"</span>;
        <span class="reserved">else</span>
            type = <span class="literal">"double"</span>;
        break;
    case <span class="literal">"object"</span>:
        var con = o.constructor;
        <span class="reserved">if</span> (con == Date)
            type = <span class="literal">"date"</span>;
        <span class="reserved">else</span> <span class="reserved">if</span> (con == Array)
            type = <span class="literal">"array"</span>;
        <span class="reserved">else</span>
            type = <span class="literal">"struct"</span>;
        break;
    }
    <span class="reserved">return</span> type;
};

XMLRPCMessage.<span class="reserved">prototype</span>.doValueXML = <span class="reserved">function</span>(type, data) {
    var xml = <span class="literal">"&lt;"</span> + type + <span class="literal">"&gt;"</span> + data + <span class="literal">"&lt;/"</span> + type + <span class="literal">"&gt;"</span>;
    <span class="reserved">return</span> xml;
};

XMLRPCMessage.<span class="reserved">prototype</span>.doBooleanXML = <span class="reserved">function</span>(data) {
    var value = (data == true) ? 1 : 0;
    var xml = <span class="literal">"&lt;boolean&gt;"</span> + value + <span class="literal">"&lt;/boolean&gt;"</span>;
    <span class="reserved">return</span> xml;
};

XMLRPCMessage.<span class="reserved">prototype</span>.doDateXML = <span class="reserved">function</span>(data) {
    var leadingZero = <span class="reserved">function</span> (n) {
        <span class="comment">// pads a single number with a leading zero. Heh.</span>
        <span class="reserved">if</span> (n.length == 1)
            n = <span class="literal">"0"</span> + n;
        <span class="reserved">return</span> n;
    };
    var dateToISO8601 = <span class="reserved">function</span>(date) {
        <span class="comment">// wow I hate working with the Date object</span>
        var year = new String(date.getYear());
        var month = <span class="reserved">this</span>.leadingZero(new String(date.getMonth()));
        var day = <span class="reserved">this</span>.leadingZero(new String(date.getDate()));
        var time = <span class="reserved">this</span>.leadingZero(new String(date.getHours())) + <span class="literal">":"</span>
        + <span class="reserved">this</span>.leadingZero(new String(date.getMinutes())) + <span class="literal">":"</span>
        + <span class="reserved">this</span>.leadingZero(new String(date.getSeconds()));

        var converted = year + month + day + <span class="literal">"T"</span> + time;
        <span class="reserved">return</span> converted;
    };

    var xml = <span class="literal">"&lt;dateTime.iso8601&gt;"</span>;
    xml += dateToISO8601(data);
    xml += <span class="literal">"&lt;/dateTime.iso8601&gt;"</span>;
    <span class="reserved">return</span> xml;
};

XMLRPCMessage.<span class="reserved">prototype</span>.doArrayXML = <span class="reserved">function</span>(data) {
    var xml = <span class="literal">"&lt;array&gt;&lt;data&gt;\n"</span>;
    <span class="reserved">for</span> ( var i = 0; i &lt; data.length; i++) {
        xml += <span class="literal">"&lt;value&gt;"</span>
                + <span class="reserved">this</span>.getParamXML(<span class="reserved">this</span>.dataTypeOf(data[i]),
                        data[i]) + <span class="literal">"&lt;/value&gt;\n"</span>;
    }
    xml += <span class="literal">"&lt;/data&gt;&lt;/array&gt;\n"</span>;
    <span class="reserved">return</span> xml;
};

XMLRPCMessage.<span class="reserved">prototype</span>.doStructXML = <span class="reserved">function</span>(data) {
    var xml = <span class="literal">"&lt;struct&gt;\n"</span>;
    <span class="reserved">for</span> ( var i in data) {
        xml += <span class="literal">"&lt;member&gt;\n"</span>;
        xml += <span class="literal">"&lt;name&gt;"</span> + i + <span class="literal">"&lt;/name&gt;\n"</span>;
        xml += <span class="literal">"&lt;value&gt;"</span>
                + <span class="reserved">this</span>.getParamXML(<span class="reserved">this</span>.dataTypeOf(data[i]),
                        data[i]) + <span class="literal">"&lt;/value&gt;\n"</span>;
        xml += <span class="literal">"&lt;/member&gt;\n"</span>;
    }
    xml += <span class="literal">"&lt;/struct&gt;\n"</span>;
    <span class="reserved">return</span> xml;
};

XMLRPCMessage.<span class="reserved">prototype</span>.getParamXML = <span class="reserved">function</span>(type, data) {
    var xml;
    switch (type) {
    case <span class="literal">"date"</span>:
        xml = <span class="reserved">this</span>.doDateXML(data);
        break;
    case <span class="literal">"array"</span>:
        xml = <span class="reserved">this</span>.doArrayXML(data);
        break;
    case <span class="literal">"struct"</span>:
        xml = <span class="reserved">this</span>.doStructXML(data);
        break;
    case <span class="literal">"boolean"</span>:
        xml = <span class="reserved">this</span>.doBooleanXML(data);
        break;
    default:
        xml = <span class="reserved">this</span>.doValueXML(type, data);
        break;
    }
    <span class="reserved">return</span> xml;
};
</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Wed Jun 23 09:33:14 2010</div>
</body>
</html>