source: branches/1.2/workflow/js/fckeditor/editor/filemanager/browser/default/js/fckxml.js @ 1349

Revision 1349, 3.3 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

  • Property svn:executable set to *
Line 
1/*
2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
4 *
5 * == BEGIN LICENSE ==
6 *
7 * Licensed under the terms of any of the following licenses at your
8 * choice:
9 *
10 *  - GNU General Public License Version 2 or later (the "GPL")
11 *    http://www.gnu.org/licenses/gpl.html
12 *
13 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14 *    http://www.gnu.org/licenses/lgpl.html
15 *
16 *  - Mozilla Public License Version 1.1 or later (the "MPL")
17 *    http://www.mozilla.org/MPL/MPL-1.1.html
18 *
19 * == END LICENSE ==
20 *
21 * Defines the FCKXml object that is used for XML data calls
22 * and XML processing.
23 *
24 * This script is shared by almost all pages that compose the
25 * File Browser frameset.
26 */
27
28var FCKXml = function()
29{}
30
31FCKXml.prototype.GetHttpRequest = function()
32{
33        // Gecko / IE7
34        if ( typeof(XMLHttpRequest) != 'undefined' )
35                return new XMLHttpRequest() ;
36
37        // IE6
38        try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; }
39        catch(e) {}
40
41        // IE5
42        try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; }
43        catch(e) {}
44
45        return null ;
46}
47
48FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
49{
50        var oFCKXml = this ;
51
52        var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
53
54        var oXmlHttp = this.GetHttpRequest() ;
55
56        oXmlHttp.open( "GET", urlToCall, bAsync ) ;
57
58        if ( bAsync )
59        {
60                oXmlHttp.onreadystatechange = function()
61                {
62                        if ( oXmlHttp.readyState == 4 )
63                        {
64                                if ( oXmlHttp.responseXML == null || oXmlHttp.responseXML.firstChild == null)
65                                {
66                                        alert( 'The server didn\'t send back a proper XML response.\r\n\r\n' +
67                                                        'Requested URL: ' + urlToCall + '\r\n' +
68                                                        'Response text:\r\n' + oXmlHttp.responseText ) ;
69                                        return ;
70                                }
71                                oFCKXml.DOMDocument = oXmlHttp.responseXML ;
72                                if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
73                                        asyncFunctionPointer( oFCKXml ) ;
74                                else
75                                        alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
76                        }
77                }
78        }
79
80        oXmlHttp.send( null ) ;
81
82        if ( ! bAsync )
83        {
84                if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
85                        this.DOMDocument = oXmlHttp.responseXML ;
86                else
87                {
88                        alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
89                }
90        }
91}
92
93FCKXml.prototype.SelectNodes = function( xpath )
94{
95        if ( navigator.userAgent.indexOf('MSIE') >= 0 )         // IE
96                return this.DOMDocument.selectNodes( xpath ) ;
97        else                                    // Gecko
98        {
99                var aNodeArray = new Array();
100
101                var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
102                                this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
103                if ( xPathResult )
104                {
105                        var oNode = xPathResult.iterateNext() ;
106                        while( oNode )
107                        {
108                                aNodeArray[aNodeArray.length] = oNode ;
109                                oNode = xPathResult.iterateNext();
110                        }
111                }
112                return aNodeArray ;
113        }
114}
115
116FCKXml.prototype.SelectSingleNode = function( xpath )
117{
118        if ( navigator.userAgent.indexOf('MSIE') >= 0 )         // IE
119                return this.DOMDocument.selectSingleNode( xpath ) ;
120        else                                    // Gecko
121        {
122                var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
123                                this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);
124
125                if ( xPathResult && xPathResult.singleNodeValue )
126                        return xPathResult.singleNodeValue ;
127                else
128                        return null ;
129        }
130}
Note: See TracBrowser for help on using the repository browser.