2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
3 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
\r
5 * == BEGIN LICENSE ==
\r
7 * Licensed under the terms of any of the following licenses at your
\r
10 * - GNU General Public License Version 2 or later (the "GPL")
\r
11 * http://www.gnu.org/licenses/gpl.html
\r
13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
14 * http://www.gnu.org/licenses/lgpl.html
\r
16 * - Mozilla Public License Version 1.1 or later (the "MPL")
\r
17 * http://www.mozilla.org/MPL/MPL-1.1.html
\r
21 * Defines the FCKXml object that is used for XML data calls
\r
22 * and XML processing.
\r
24 * This script is shared by almost all pages that compose the
\r
25 * File Browser frameset.
\r
28 var FCKXml = function()
\r
31 FCKXml.prototype.GetHttpRequest = function()
\r
34 try { return new XMLHttpRequest(); }
\r
38 try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; }
\r
42 try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; }
\r
48 FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
\r
50 var oFCKXml = this ;
\r
52 var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
\r
54 var oXmlHttp = this.GetHttpRequest() ;
\r
56 oXmlHttp.open( "GET", urlToCall, bAsync ) ;
\r
60 oXmlHttp.onreadystatechange = function()
\r
62 if ( oXmlHttp.readyState == 4 )
\r
67 // this is the same test for an FF2 bug as in fckxml_gecko.js
\r
68 // but we've moved the responseXML assignment into the try{}
\r
69 // so we don't even have to check the return status codes.
\r
70 var test = oXmlHttp.responseXML.firstChild ;
\r
71 oXml = oXmlHttp.responseXML ;
\r
77 oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ;
\r
82 if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' )
\r
84 alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' +
\r
85 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' +
\r
86 'Requested URL:\n' + urlToCall + '\n\n' +
\r
87 'Response text:\n' + oXmlHttp.responseText ) ;
\r
91 oFCKXml.DOMDocument = oXml ;
\r
92 asyncFunctionPointer( oFCKXml ) ;
\r
97 oXmlHttp.send( null ) ;
\r
101 if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
\r
102 this.DOMDocument = oXmlHttp.responseXML ;
\r
105 alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
\r
110 FCKXml.prototype.SelectNodes = function( xpath )
\r
112 if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE
\r
113 return this.DOMDocument.selectNodes( xpath ) ;
\r
116 var aNodeArray = new Array();
\r
118 var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
\r
119 this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
\r
122 var oNode = xPathResult.iterateNext() ;
\r
125 aNodeArray[aNodeArray.length] = oNode ;
\r
126 oNode = xPathResult.iterateNext();
\r
129 return aNodeArray ;
\r
133 FCKXml.prototype.SelectSingleNode = function( xpath )
\r
135 if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE
\r
136 return this.DOMDocument.selectSingleNode( xpath ) ;
\r
139 var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
\r
140 this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);
\r
142 if ( xPathResult && xPathResult.singleNodeValue )
\r
143 return xPathResult.singleNodeValue ;
\r