--- /dev/null
+/*\r
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben\r
+ *\r
+ * == BEGIN LICENSE ==\r
+ *\r
+ * Licensed under the terms of any of the following licenses at your\r
+ * choice:\r
+ *\r
+ * - GNU General Public License Version 2 or later (the "GPL")\r
+ * http://www.gnu.org/licenses/gpl.html\r
+ *\r
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
+ * http://www.gnu.org/licenses/lgpl.html\r
+ *\r
+ * - Mozilla Public License Version 1.1 or later (the "MPL")\r
+ * http://www.mozilla.org/MPL/MPL-1.1.html\r
+ *\r
+ * == END LICENSE ==\r
+ *\r
+ * Defines the FCKXml object that is used for XML data calls\r
+ * and XML processing.\r
+ *\r
+ * This script is shared by almost all pages that compose the\r
+ * File Browser frameset.\r
+ */\r
+\r
+var FCKXml = function()\r
+{}\r
+\r
+FCKXml.prototype.GetHttpRequest = function()\r
+{\r
+ // Gecko / IE7\r
+ try { return new XMLHttpRequest(); }\r
+ catch(e) {}\r
+\r
+ // IE6\r
+ try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; }\r
+ catch(e) {}\r
+\r
+ // IE5\r
+ try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; }\r
+ catch(e) {}\r
+\r
+ return null ;\r
+}\r
+\r
+FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )\r
+{\r
+ var oFCKXml = this ;\r
+\r
+ var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;\r
+\r
+ var oXmlHttp = this.GetHttpRequest() ;\r
+\r
+ oXmlHttp.open( "GET", urlToCall, bAsync ) ;\r
+\r
+ if ( bAsync )\r
+ {\r
+ oXmlHttp.onreadystatechange = function()\r
+ {\r
+ if ( oXmlHttp.readyState == 4 )\r
+ {\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
+ 'Requested URL:\n' + urlToCall + '\n\n' +\r
+ 'Response text:\n' + oXmlHttp.responseText ) ;\r
+ return ;\r
+ }\r
+\r
+ oFCKXml.DOMDocument = oXml ;\r
+ asyncFunctionPointer( oFCKXml ) ;\r
+ }\r
+ }\r
+ }\r
+\r
+ oXmlHttp.send( null ) ;\r
+\r
+ if ( ! bAsync )\r
+ {\r
+ if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )\r
+ this.DOMDocument = oXmlHttp.responseXML ;\r
+ else\r
+ {\r
+ alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;\r
+ }\r
+ }\r
+}\r
+\r
+FCKXml.prototype.SelectNodes = function( xpath )\r
+{\r
+ if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE\r
+ return this.DOMDocument.selectNodes( xpath ) ;\r
+ else // Gecko\r
+ {\r
+ var aNodeArray = new Array();\r
+\r
+ var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,\r
+ this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;\r
+ if ( xPathResult )\r
+ {\r
+ var oNode = xPathResult.iterateNext() ;\r
+ while( oNode )\r
+ {\r
+ aNodeArray[aNodeArray.length] = oNode ;\r
+ oNode = xPathResult.iterateNext();\r
+ }\r
+ }\r
+ return aNodeArray ;\r
+ }\r
+}\r
+\r
+FCKXml.prototype.SelectSingleNode = function( xpath )\r
+{\r
+ if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE\r
+ return this.DOMDocument.selectSingleNode( xpath ) ;\r
+ else // Gecko\r
+ {\r
+ var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,\r
+ this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);\r
+\r
+ if ( xPathResult && xPathResult.singleNodeValue )\r
+ return xPathResult.singleNodeValue ;\r
+ else\r
+ return null ;\r
+ }\r
+}\r