From: Thyamad c. <th...@us...> - 2005-10-27 02:36:16
|
Update of /cvsroot/thyapi/thyapi/thyutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3305/thyutils Modified Files: thyconnector.js thyjsonprotocol.js thyxmlrpcprotocol.js Log Message: Commiting file additions and modification from SVN revision 2141 to 2142... Changes made by vinicius on 2005-10-27 05:07:59 +0200 (Thu, 27 Oct 2005) corresponding to SVN revision 2142 with message: JSON protocol support tested in thyapi Index: thyxmlrpcprotocol.js =================================================================== RCS file: /cvsroot/thyapi/thyapi/thyutils/thyxmlrpcprotocol.js,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** thyxmlrpcprotocol.js 12 Sep 2005 19:39:12 -0000 1.6 --- thyxmlrpcprotocol.js 27 Oct 2005 02:36:09 -0000 1.7 *************** *** 86,91 **** p.decode = function (response) { ! if (typeof(response) != 'object' || ! typeof(response.firstChild) != 'object') { throw({result: 'Invalid XMLRPC data', location: 'thyXMLRPCProtocol.decode'}); --- 86,93 ---- p.decode = function (response) { ! resp = response.xml; ! ! if (typeof(resp) != 'object' || ! typeof(resp.firstChild) != 'object') { throw({result: 'Invalid XMLRPC data', location: 'thyXMLRPCProtocol.decode'}); *************** *** 93,99 **** var i, data; ! for (i=0; i<response.childNodes.length; i++) { ! var node = response.childNodes[i]; if (node.nodeType != 1) continue; --- 95,101 ---- var i, data; ! for (i=0; i<resp.childNodes.length; i++) { ! var node = resp.childNodes[i]; if (node.nodeType != 1) continue; Index: thyconnector.js =================================================================== RCS file: /cvsroot/thyapi/thyapi/thyutils/thyconnector.js,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** thyconnector.js 12 Sep 2005 18:55:59 -0000 1.6 --- thyconnector.js 27 Oct 2005 02:36:09 -0000 1.7 *************** *** 154,160 **** if (typeof(handler) == 'function') { ! if (oxmlhttp.responseXML) handler(oxmlhttp.responseXML); ! else handler(oxmlhttp.responseText); ! //handler(oxmlhttp.responseText); } delete _this.requests[id]; --- 154,161 ---- if (typeof(handler) == 'function') { ! //Both XML and text responses are sent to the ! //handler; Depending of the protocol implemented, ! //one or the other will be used ! handler({xml: oxmlhttp.responseXML, text: oxmlhttp.responseText}); } delete _this.requests[id]; Index: thyjsonprotocol.js =================================================================== RCS file: /cvsroot/thyapi/thyapi/thyutils/thyjsonprotocol.js,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** thyjsonprotocol.js 26 Oct 2005 18:37:26 -0000 1.1 --- thyjsonprotocol.js 27 Oct 2005 02:36:09 -0000 1.2 *************** *** 36,40 **** * Method: encode * ! * Encode the data in XMLRPC protocol and returns the appropriate string * * Parameters: --- 36,40 ---- * Method: encode * ! * Encode the data in JSON protocol and returns the appropriate string * * Parameters: *************** *** 47,53 **** { params = params || {}; - params['run'] = method; - return params.toSource(); } --- 47,51 ---- *************** *** 56,70 **** * Method: decode * ! * Decodes received XML in XMLRPC response format to JS data structure * * Parameter: * ! * response - The response from server, that can be either a DOM XML document ! * or a XML string to be parsed * */ p.decode = function (response) { ! return eval(response); } --- 54,76 ---- * Method: decode * ! * Decodes received message in JSON format to JS data structure * * Parameter: * ! * response - The response from server, that is a string to be eval'd * */ p.decode = function (response) { ! /* //TODO make this work... ! try ! {*/ ! var ret = eval(response.text); ! /* } ! catch(err) ! { ! throw({result: 'Invalid JSON data', location: 'thyJSONProtocol.decode'}); ! }*/ ! return ret; } *************** *** 72,76 **** * Method: getContentType * ! * Returns the content type of XML document * */ --- 78,82 ---- * Method: getContentType * ! * Returns the content type of JSON document * */ |