aboutsummaryrefslogblamecommitdiffstats
path: root/docs/html/overview-summary-xmlrpc.js.html
blob: fa8f78614b9fa68494cc8b147cc551598f4efd87 (plain) (tree)

































































































































































































































































































































                                                                                                                                                                                          
<!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>