FCKeditor 2.6.6
[freeside.git] / httemplate / elements / fckeditor / editor / filemanager / browser / default / js / fckxml.js
index 043ca84..b7eddc6 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2007 Frederico Caldeira Knabben\r
+ * Copyright (C) 2003-2010 Frederico Caldeira Knabben\r
  *\r
  * == BEGIN LICENSE ==\r
  *\r
@@ -31,8 +31,8 @@ var FCKXml = function()
 FCKXml.prototype.GetHttpRequest = function()\r
 {\r
        // Gecko / IE7\r
-       if ( typeof(XMLHttpRequest) != 'undefined' )\r
-               return new XMLHttpRequest() ;\r
+       try { return new XMLHttpRequest(); }\r
+       catch(e) {}\r
 \r
        // IE6\r
        try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; }\r
@@ -61,7 +61,25 @@ FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
                {\r
                        if ( oXmlHttp.readyState == 4 )\r
                        {\r
-                               if ( ( oXmlHttp.status != 200 && oXmlHttp.status != 304 ) || oXmlHttp.responseXML == null || oXmlHttp.responseXML.firstChild == null )\r
+                               var oXml ;\r
+                               try\r
+                               {\r
+                                       // this is the same test for an FF2 bug as in fckxml_gecko.js\r
+                                       // but we've moved the responseXML assignment into the try{}\r
+                                       // so we don't even have to check the return status codes.\r
+                                       var test = oXmlHttp.responseXML.firstChild ;\r
+                                       oXml = oXmlHttp.responseXML ;\r
+                               }\r
+                               catch ( e )\r
+                               {\r
+                                       try\r
+                                       {\r
+                                               oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ;\r
+                                       }\r
+                                       catch ( e ) {}\r
+                               }\r
+\r
+                               if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' )\r
                                {\r
                                        alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' +\r
                                                        'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' +\r
@@ -70,7 +88,7 @@ FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
                                        return ;\r
                                }\r
 \r
-                               oFCKXml.DOMDocument = oXmlHttp.responseXML ;\r
+                               oFCKXml.DOMDocument = oXml ;\r
                                asyncFunctionPointer( oFCKXml ) ;\r
                        }\r
                }\r