-/*!
- * Ext JS Library 3.1.1
- * Copyright(c) 2006-2010 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-// Create and append to the body, a Panel containing a block of code from the passed URL\r
-function createCodePanel(url, title) {\r
- var panel = new Ext.Panel({\r
- hideMode: 'visibility',\r
- title: title,\r
- width: 750,\r
- style: {\r
- 'margin-top': '10px'\r
- },\r
- hideCollapseTool: true,\r
- titleCollapse: true,\r
- collapsible: true,\r
- collapsed: true,\r
- autoScroll: true,\r
- renderTo: Ext.getBody(),\r
- listeners: {\r
- render: function(p) {\r
- p.getUpdater().setRenderer({\r
- render: Ext.isIE ? function(el, response, scripts, callback) {\r
- el.update('');\r
- var np = el.createChild({\r
- tag: 'pre',\r
- cls: 'code',\r
- cn: {\r
- tag: 'code'\r
- }\r
- });\r
- var t = response.responseText.split("\n");\r
- var c = np.child('code', true);\r
- for (var i = 0, l = t.length; i < l; i++) {\r
- var pre = document.createElement('pre');\r
- if (t[i].length) {\r
- pre.appendChild(document.createTextNode(t[i]));\r
- c.appendChild(pre);\r
- } else if (i < (l - 1)) {\r
- c.appendChild(document.createElement("br"));\r
- }\r
- \r
- }\r
- } : function(el, response, scripts, callback) {\r
- el.update('');\r
- el.createChild({\r
- tag: 'pre',\r
- cls: 'code',\r
- cn: {\r
- tag: 'code',\r
- html: response.responseText\r
- }\r
- });\r
- }\r
- });\r
- },\r
- beforeexpand: function(p) {\r
- p.load(url);\r
- },\r
- single: true\r
- }\r
- });\r
-}\r
-\r
-// Patch to allow XHR to local files. From hendricd: http://extjs.com/forum/member.php?u=8730\r
-Ext.apply( Ext.lib.Ajax ,\r
-{ forceActiveX:false,\r
- createXhrObject:function(transactionId)\r
- {\r
- var obj={ status:{isError:false}\r
- , tId:transactionId}, http;\r
- try\r
- {\r
- \r
- if(Ext.isIE7 && !!this.forceActiveX){throw("IE7forceActiveX");}\r
- \r
- obj.conn= new XMLHttpRequest();\r
- \r
- }\r
- catch(e)\r
- {\r
- for (var i = 0; i < this.activeX.length; ++i) {\r
- try\r
- {\r
- obj.conn= new ActiveXObject(this.activeX[i]);\r
- \r
- break;\r
- }\r
- catch(e) { \r
- }\r
- }\r
- }\r
- finally\r
- {\r
- obj.status.isError = typeof(obj.conn) === undefined;\r
- } \r
- return obj;\r
- \r
- },\r
- \r
- getHttpStatus: function(reqObj){\r
- \r
- var statObj = { status:0\r
- ,statusText:''\r
- ,isError:false\r
- ,isLocal:false\r
- ,isOK:false\r
- ,error:null};\r
- \r
- try {\r
- if(!reqObj)throw('noobj');\r
- statObj.status = reqObj.status;\r
- \r
- statObj.isLocal = !reqObj.status && location.protocol == "file:" || \r
- Ext.isSafari && reqObj.status === undefined;\r
- \r
- statObj.isOK = (statObj.isLocal || (statObj.status > 199 && statObj.status < 300));\r
- statObj.statusText = reqObj.statusText || '';\r
- } catch(e){ //status may not avail/valid yet (or called too early).\r
- } \r
- \r
- return statObj; \r
- \r
- },\r
- handleTransactionResponse:function(o, callback, isAbort)\r
- {\r
- \r
- \r
- callback = callback || {};\r
- var responseObject=null;\r
- \r
- if(!o.status.isError){\r
- o.status = this.getHttpStatus(o.conn); \r
- /* create and enhance the response with proper status and XMLDOM if necessary */\r
- responseObject = this.createResponseObject(o, callback.argument);\r
- }\r
- \r
- if(o.status.isError){ /* checked again in case exception was raised - ActiveX was disabled during XML-DOM creation? */\r
- // And mixin everything the XHR object had to offer as well\r
- responseObject = Ext.applyIf(responseObject||{},this.createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false)));\r
- \r
- }\r
- \r
- responseObject.options = o.options;\r
- responseObject.stat = o.status;\r
- \r
- if (o.status.isOK && !o.status.isError) {\r
- if (callback.success) {\r
- if (!callback.scope) {\r
- callback.success(responseObject);\r
- }\r
- else {\r
- callback.success.apply(callback.scope, [responseObject]);\r
- }\r
- }\r
- } else {\r
-\r
- if (callback.failure) {\r
- if (!callback.scope) {\r
- callback.failure(responseObject);\r
- }\r
- else {\r
- callback.failure.apply(callback.scope, [responseObject]);\r
- }\r
- }\r
-\r
- }\r
- \r
- if(o.options.async){\r
- this.releaseObject(o); \r
- responseObject = null;\r
- }else{ \r
- this.releaseObject(o);\r
- return responseObject; \r
- }\r
- \r
- },\r
- createResponseObject:function(o, callbackArg)\r
- {\r
- var obj = {};\r
- var headerObj = {},headerStr='';\r
-\r
- try{ //to catch bad encoding problems here\r
- obj.responseText = o.conn.responseText;\r
- }catch(e){obj.responseText ='';}\r
-\r
- obj.responseXML = o.conn.responseXML;\r
-\r
- try{\r
- headerStr = o.conn.getAllResponseHeaders()||'';\r
- } catch(e){}\r
-\r
- if(o.status.isLocal){\r
-\r
- o.status.isOK = ((o.status.status = (!!obj.responseText.length)?200:404) == 200);\r
-\r
- if(o.status.isOK && (!obj.responseXML || obj.responseXML.childNodes.length == 0)){\r
-\r
- var xdoc=null;\r
- try{ //ActiveX may be disabled\r
- if(typeof(DOMParser) == 'undefined'){ \r
- xdoc=new ActiveXObject("Microsoft.XMLDOM"); \r
- xdoc.async="false";\r
- xdoc.loadXML(obj.responseText); \r
-\r
- }else{ \r
- try{ //Opera 9 will fail parsing non-XML content, so trap here.\r
- var domParser = new DOMParser(); \r
- xdoc = domParser.parseFromString(obj.responseText, 'application\/xml'); \r
- }catch(ex){}\r
- finally{domParser = null;}\r
-\r
- }\r
- } catch(ex){ \r
- o.status.isError = true; \r
- o.status.error = ex;\r
-\r
- }\r
-\r
- obj.responseXML = xdoc;\r
- }\r
-\r
- if(obj.responseXML){\r
-\r
- var parseBad = (obj.responseXML.parseError || 0) != 0 || obj.responseXML.childNodes.length == 0;\r
- if(!parseBad){\r
- headerStr = 'Content-Type: ' + (obj.responseXML.contentType || 'text\/xml') + '\n' + headerStr ;\r
- } \r
- } \r
-\r
-\r
- } \r
-\r
- var header = headerStr.split('\n');\r
- for (var i = 0; i < header.length; i++) {\r
- var delimitPos = header[i].indexOf(':');\r
- if (delimitPos != -1) {\r
- headerObj[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2);\r
- }\r
- }\r
-\r
- obj.tId = o.tId;\r
- obj.status = o.status.status;\r
- obj.statusText = o.status.statusText;\r
- obj.getResponseHeader = headerObj;\r
- obj.getAllResponseHeaders = headerStr;\r
- obj.stat = o.status\r
-\r
- if (typeof callbackArg !== undefined) {\r
- obj.argument = callbackArg;\r
- }\r
-\r
- return obj;\r
- },\r
- \r
- request : function(method, uri, cb, data, options) {\r
- \r
- options = Ext.apply({async:true,\r
- headers:false,\r
- userId:null,\r
- password:null,\r
- xmlData:null }, options||{});\r
- \r
- var hs = options.headers;\r
- if(hs){\r
- for(var h in hs){\r
- if(hs.hasOwnProperty(h)){\r
- this.initHeader(h, hs[h], false);\r
- }\r
- }\r
- }\r
- if(options.xmlData){\r
- this.initHeader('Content-Type', 'text/xml', false);\r
- method = 'POST';\r
- data = options.xmlData;\r
- }\r
- \r
- return this.makeRequest(method, uri, cb, data, options);\r
- \r
- },\r
- asyncRequest:function(method, uri, callback, postData)\r
- {\r
- var o = this.getConnectionObject();\r
-\r
- if (!o || o.status.isError) {\r
- return null;\r
- }\r
- else {\r
- o.options = options;\r
- try{\r
- o.conn.open(method, uri, true);\r
- } catch(ex){\r
- o.status.isError = true;\r
- o.status.error = ex;\r
- return Ext.apply(o,this.handleTransactionResponse(o, callback));\r
- \r
- }\r
- \r
- \r
- if (this.useDefaultXhrHeader) {\r
- if (!this.defaultHeaders['X-Requested-With']) {\r
- this.initHeader('X-Requested-With', this.defaultXhrHeader, true);\r
- }\r
- }\r
-\r
- if(postData && this.useDefaultHeader){\r
- this.initHeader('Content-Type', this.defaultPostHeader);\r
- }\r
-\r
- if (this.hasDefaultHeaders || this.hasHeaders) {\r
- this.setHeader(o);\r
- }\r
-\r
- this.handleReadyState(o, callback);\r
- \r
- try{ o.conn.send(postData || null);\r
- } catch(ex){ \r
- o.status.isError=true;\r
- o.status.error = ex;\r
- return Ext.apply(o,this.handleTransactionResponse(o, callback));\r
- }\r
- \r
- \r
- return o;\r
- }\r
- },\r
- \r
- makeRequest:function(method, uri, callback, postData, options)\r
- {\r
- var o = this.getConnectionObject();\r
- \r
- if (!o || o.status.isError) {\r
- return null;\r
- }\r
- else {\r
- o.options = options; \r
- try{\r
- o.conn.open(method, uri, options.async, options.userId, options.password);\r
- } catch(ex){\r
- o.status.isError = true;\r
- o.status.error = ex;\r
- var r=this.handleTransactionResponse(o, callback);\r
- return Ext.apply(o,r);\r
- }\r
-\r
- if (this.useDefaultXhrHeader) {\r
- if (!this.defaultHeaders['X-Requested-With']) {\r
- this.initHeader('X-Requested-With', this.defaultXhrHeader, true);\r
- }\r
- }\r
-\r
- if(postData && this.useDefaultHeader){\r
- this.initHeader('Content-Type', this.defaultPostHeader);\r
- }\r
-\r
- if (this.hasDefaultHeaders || this.hasHeaders) {\r
- this.setHeader(o);\r
- }\r
-\r
- if(o.options.async){ //Timers won't work here as it's a blocking call\r
- this.handleReadyState(o, callback);\r
- }\r
- \r
- try{ o.conn.send(postData || null);\r
- } catch(ex){ \r
- //Ext.apply(o,this.handleTransactionResponse(o, callback));\r
- }\r
- \r
- return options.async?o:Ext.apply(o,this.handleTransactionResponse(o, callback));\r
- }\r
- }});\r
- \r
-Ext.lib.Ajax.forceActiveX = (document.location.protocol == 'file:');/* or other true/false mechanism */
\ No newline at end of file