Alien-Web-ExtJS-V3

 view release on metacpan or  search on metacpan

share/examples/shared/code-display.js  view on Meta::CPAN

		 	responseObject = this.createResponseObject(o, callback.argument);
		 }
		
 		 if(o.status.isError){ /* checked again in case exception was raised - ActiveX was disabled during XML-DOM creation? */
 		     // And mixin everything the XHR object had to offer as well
		   responseObject = Ext.applyIf(responseObject||{},this.createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false)));
		   
		 }
		
		 responseObject.options = o.options;
		 responseObject.stat = o.status;
		 
		 if (o.status.isOK && !o.status.isError) {
			if (callback.success) {
				if (!callback.scope) {
					callback.success(responseObject);
				}
				else {
					callback.success.apply(callback.scope, [responseObject]);
				}
			}
		  } else {

			if (callback.failure) {
				if (!callback.scope) {
					callback.failure(responseObject);
				}
				else {
					callback.failure.apply(callback.scope, [responseObject]);
				}
			}

		 }
		
		if(o.options.async){
			this.releaseObject(o);	
			responseObject = null;
		}else{ 
			this.releaseObject(o);
			return responseObject; 
		}
			
	},
	createResponseObject:function(o, callbackArg)
	{
	    var obj = {};
	    var headerObj = {},headerStr='';

	    try{  //to catch bad encoding problems here
		obj.responseText = o.conn.responseText;
	    }catch(e){obj.responseText ='';}

	    obj.responseXML = o.conn.responseXML;

	    try{
		headerStr = o.conn.getAllResponseHeaders()||'';
	    } catch(e){}

	    if(o.status.isLocal){

		   o.status.isOK = ((o.status.status = (!!obj.responseText.length)?200:404) == 200);

		   if(o.status.isOK && (!obj.responseXML || obj.responseXML.childNodes.length == 0)){

			var xdoc=null;
			try{   //ActiveX may be disabled
				if(typeof(DOMParser) == 'undefined'){ 
					xdoc=new ActiveXObject("Microsoft.XMLDOM"); 
					xdoc.async="false";
					xdoc.loadXML(obj.responseText); 

				}else{ 
					try{  //Opera 9 will fail parsing non-XML content, so trap here.
						var domParser = new DOMParser(); 
						xdoc = domParser.parseFromString(obj.responseText, 'application\/xml'); 
					}catch(ex){}
					finally{domParser = null;}

				}
			} catch(ex){ 
				o.status.isError = true; 
				o.status.error = ex;

				}

			obj.responseXML = xdoc;
		    }

		    if(obj.responseXML){

			var parseBad = (obj.responseXML.parseError || 0) != 0 || obj.responseXML.childNodes.length == 0;
			if(!parseBad){
				headerStr = 'Content-Type: ' + (obj.responseXML.contentType || 'text\/xml') + '\n' + headerStr ;
				}			    
		    }		


	    }	

	   var header = headerStr.split('\n');
	   for (var i = 0; i < header.length; i++) {
	        var delimitPos = header[i].indexOf(':');
	    	if (delimitPos != -1) {
			headerObj[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2);
	    	}
	    }

	    obj.tId = o.tId;
	    obj.status = o.status.status;
	    obj.statusText = o.status.statusText;
	    obj.getResponseHeader = headerObj;
	    obj.getAllResponseHeaders = headerStr;
	    obj.stat = o.status

	    if (typeof callbackArg !== undefined) {
		obj.argument = callbackArg;
	    }

	    return obj;
        },
        



( run in 1.630 second using v1.01-cache-2.11-cpan-39bf76dae61 )