rem: if(response instanceof Object && (response.result || response.error)){ 
add: if(response instanceof Object && (response.result || response.error)){ 
context: rpc.ServiceProxy.prototype.__callMethod = function(methodName, params, successHandler, exceptionHandler, completeHandler){	rpc.requestCount++;		//Verify that successHandler, exceptionHandler, and completeHandler are functions	if(this.__isAsynchronous){		if(successHandler && typeof successHandler != 'function')			throw Error('The asynchronous onSuccess handler callback function you provided is invalid; the value you provided (' + successHandler.toString() + ') is of type "' + typeof(successHandler) + '".');		if(exceptionHandler && typeof exceptionHandler != 'function')			throw Error('The asynchronous onException handler callback function you provided is invalid; the value you provided (' + exceptionHandler.toString() + ') is of type "' + typeof(exceptionHandler) + '".');		if(completeHandler && typeof completeHandler != 'function')			throw Error('The asynchronous onComplete handler callback function you provided is invalid; the value you provided (' + completeHandler.toString() + ') is of type "' + typeof(completeHandler) + '".');	}		try {		//Assign the provided callback function to the response lookup table		if(this.__isAsynchronous || this.__isCrossSite){			rpc.pendingRequests[String(rpc.requestCount)] = {				//method:methodName,				onSuccess:successHandler,				onException:exceptionHandler,				onComplete:completeHandler			};		}					//Asynchronous cross-domain call (JSON-in-Script) -----------------------------------------------------		if(this.__isCrossSite){ //then this.__isAsynchronous is implied						//Create an ad hoc function specifically for this cross-site request; this is necessary because it is 			//  not possible pass an JSON-RPC request object with an id over HTTP Get requests.			rpc.callbacks['r' + String(rpc.requestCount)] = (function(instance, id){				var call = {instance: instance, id: id}; //Pass parameter into closure				return function(response){					if(response instanceof Object && (response.result || response.error)){							response.id = call.id;						instance.__doCallback(response);					}					else {//Allow data without response wrapper (i.e. GData)						instance.__doCallback({id: call.id, result: response});					}				}			})(this, rpc.requestCount);			//rpc.callbacks['r' + String(rpc.requestCount)] = new Function("response", 'response.id = ' + rpc.requestCount + '; this.__doCallback(response);');						//Make the request by adding a SCRIPT element to the page			var script = document.createElement('script');			script.setAttribute('type', 'text/javascript');			var src = this.__serviceURL +						'/' + methodName +						'?' + this.__callbackParamName + '=rpc.callbacks.r' + (rpc.requestCount);			if(params)				src += '&' + rpc.toQueryString(params);			script.setAttribute('src', src);			script.setAttribute('id', 'rpc' + rpc.requestCount);			var head = document.getElementsByTagName('head')[0];			rpc.pendingRequests[rpc.requestCount].scriptElement = script;			head.appendChild(script);						return undefined;		}		//Calls made with XMLHttpRequest ------------------------------------------------------------		else {			//Obtain and verify the parameters			if(params){				if(!(params instanceof Object) || params instanceof Date) //JSON-RPC 1.1 allows params to be a hash not just an array					throw Error('When making asynchronous calls, the parameters for the method must be passed as an array (or a hash); the value you supplied (' + String(params) + ') is of type "' + typeof(params) + '".');				//request.params = params;			}						//Prepare the XML-RPC request			var request,postData;			if(this.__protocol == 'XML-RPC'){				if(!(params instanceof Array))					throw Error("Unable to pass associative arrays to XML-RPC services.");								var xml = ['<?xml version="1.0"?><methodCall><methodName>' + methodName + '</methodName>'];				if(params){					xml.push('<params>');					for(var i = 0; i < params.length; i++)						xml.push('<param>' + this.__toXMLRPC(params[i]) + '</param>');					xml.push('</params>');				}				xml.push('</methodCall>');				postData = xml.join('');								//request = new Document();				//var methodCallEl = document.createElement('methodCall');				//var methodNameEl = document.createElement('methodName');				//methodNameEl.appendChild(document.createTextNode(methodName));				//methodCallEl.appendChild(methodNameEl);				//if(params){				//	var paramsEl = document.createElement('params');				//	for(var i = 0; i < params.length; i++){				//		var paramEl = document.createElement('param');				//		paramEl.appendChild(this.__toXMLRPC(params[i]));				//		paramsEl.appendChild(paramEl);				//	}				//	methodCallEl.appendChild(paramsEl);				//}				//request.appendChild(methodCallEl);				//postData = request.serializeXML();			}			//Prepare the JSON-RPC request			else {				request = {					version:"1.1",					method:methodName,					id:rpc.requestCount				};				if(params)					request.params = params;				postData = this.__toJSON(request);			}						//XMLHttpRequest chosen (over Ajax.Request) because it propogates uncaught exceptions			var xhr;			if(window.XMLHttpRequest)				xhr = new XMLHttpRequest();			else if(window.ActiveXObject){				try {					xhr = new ActiveXObject('Msxml2.XMLHTTP');				} catch(err){					xhr = new ActiveXObject('Microsoft.XMLHTTP');				}			}			xhr.open('POST', this.__serviceURL, this.__isAsynchronous, this.__authUsername, this.__authPassword);			if(this.__protocol == 'XML-RPC'){				xhr.setRequestHeader('Content-Type', 'text/xml');				xhr.setRequestHeader('Accept', 'text/xml');			}			else {				xhr.setRequestHeader('Content-Type', 'application/json');				xhr.setRequestHeader('Accept', 'application/json');			}						//Asynchronous same-domain call -----------------------------------------------------			if(this.__isAsynchronous){				//Send the request				xhr.send(postData);								//Handle the response				var instance = this;				var requestInfo = {id:rpc.requestCount}; //for XML-RPC since the 'request' object cannot contain request ID				xhr.onreadystatechange = function(){					//QUESTION: Why can't I use this.readyState?					if(xhr.readyState == 4){						//XML-RPC						if(instance.__protocol == 'XML-RPC'){							var response = instance.__getXMLRPCResponse(xhr, requestInfo.id);							instance.__doCallback(response);						}						//JSON-RPC						else							instance.__doCallback(instance.__evalJSON(xhr.responseText, instance.__isResponseSanitized));					}				};								return undefined;			}			//Synchronous same-domain call -----------------------------------------------------			else {				//Send the request				xhr.send(postData);				var response;				if(this.__protocol == 'XML-RPC')					response = this.__getXMLRPCResponse(xhr, rpc.requestCount);				else					response = this.__evalJSON(xhr.responseText, this.__isResponseSanitized);								//Note that this error must be caught with a try/catch block instead of by passing a onException callback				if(response.error)					throw Error('Unable to call "' + methodName + '". Server responsed with error (code ' + response.error.code + '): ' + response.error.message);								this.__upgradeValuesFromJSON(response);				return response.result;			}		}	}	catch(err){		//err.locationCode = PRE-REQUEST Cleint		var isCaught = false;		if(exceptionHandler)			isCaught = exceptionHandler(err); //add error location		if(completeHandler)			completeHandler();					if(!isCaught)			throw err;	}};
meta: 8021	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/8021/8073a6b85184d3aade5304de8e573aab353b3a9f/rpc.js/clean/rpc.js