~bestpractical/rt/master

« back to all changes in this revision

Viewing changes to share/html/NoAuth/RichText/FCKeditor/editor/filemanager/browser/default/js/fckxml.js

  • Committer: sunnavy
  • Date: 2008-05-14 13:22:46 UTC
  • Revision ID: git-v1:0f0c8baef62a06a13d6fb54683d6c7d75d5f1283
source layout change! html now lives in share/html

git-svn-id: svn+ssh://svn.bestpractical.com/svn/bps-public/rt/branches/3.8-TESTING@12308 e417ac7c-1bcc-0310-8ffa-8f5827389a85

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
28
var FCKXml = function()
 
29
{}
 
30
 
 
31
FCKXml.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
 
 
48
FCKXml.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.status != 200 && oXmlHttp.status != 304 ) || oXmlHttp.responseXML == null || oXmlHttp.responseXML.firstChild == null )
 
65
                                {
 
66
                                        alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' +
 
67
                                                        'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' +
 
68
                                                        'Requested URL:\n' + urlToCall + '\n\n' +
 
69
                                                        'Response text:\n' + oXmlHttp.responseText ) ;
 
70
                                        return ;
 
71
                                }
 
72
 
 
73
                                oFCKXml.DOMDocument = oXmlHttp.responseXML ;
 
74
                                asyncFunctionPointer( oFCKXml ) ;
 
75
                        }
 
76
                }
 
77
        }
 
78
 
 
79
        oXmlHttp.send( null ) ;
 
80
 
 
81
        if ( ! bAsync )
 
82
        {
 
83
                if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
 
84
                        this.DOMDocument = oXmlHttp.responseXML ;
 
85
                else
 
86
                {
 
87
                        alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
 
88
                }
 
89
        }
 
90
}
 
91
 
 
92
FCKXml.prototype.SelectNodes = function( xpath )
 
93
{
 
94
        if ( navigator.userAgent.indexOf('MSIE') >= 0 )         // IE
 
95
                return this.DOMDocument.selectNodes( xpath ) ;
 
96
        else                                    // Gecko
 
97
        {
 
98
                var aNodeArray = new Array();
 
99
 
 
100
                var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
 
101
                                this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
 
102
                if ( xPathResult )
 
103
                {
 
104
                        var oNode = xPathResult.iterateNext() ;
 
105
                        while( oNode )
 
106
                        {
 
107
                                aNodeArray[aNodeArray.length] = oNode ;
 
108
                                oNode = xPathResult.iterateNext();
 
109
                        }
 
110
                }
 
111
                return aNodeArray ;
 
112
        }
 
113
}
 
114
 
 
115
FCKXml.prototype.SelectSingleNode = function( xpath )
 
116
{
 
117
        if ( navigator.userAgent.indexOf('MSIE') >= 0 )         // IE
 
118
                return this.DOMDocument.selectSingleNode( xpath ) ;
 
119
        else                                    // Gecko
 
120
        {
 
121
                var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
 
122
                                this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);
 
123
 
 
124
                if ( xPathResult && xPathResult.singleNodeValue )
 
125
                        return xPathResult.singleNodeValue ;
 
126
                else
 
127
                        return null ;
 
128
        }
 
129
}