source: branches/1.2/workflow/js/fckeditor/editor/_source/classes/fckxml_gecko.js @ 1349

Revision 1349, 2.4 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 * FCKXml Class: class to load and manipulate XML files.
22 */
23
24var FCKXml = function()
25{}
26
27FCKXml.prototype.LoadUrl = function( urlToCall )
28{
29        this.Error = false ;
30        var oFCKXml = this ;
31
32        var oXmlHttp = FCKTools.CreateXmlObject( 'XmlHttp' ) ;
33        oXmlHttp.open( "GET", urlToCall, false ) ;
34        oXmlHttp.send( null ) ;
35
36        if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
37                this.DOMDocument = oXmlHttp.responseXML ;
38        else if ( oXmlHttp.status == 0 && oXmlHttp.readyState == 4 )
39                this.DOMDocument = oXmlHttp.responseXML ;
40        else
41                this.DOMDocument = null ;
42
43        if ( this.DOMDocument == null || this.DOMDocument.firstChild == null )
44        {
45                this.Error = true ;
46                if (window.confirm( 'Error loading "' + urlToCall + '"\r\nDo you want to see more info?' ) )
47                        alert( 'URL requested: "' + urlToCall + '"\r\n' +
48                                                'Server response:\r\nStatus: ' + oXmlHttp.status + '\r\n' +
49                                                'Response text:\r\n' + oXmlHttp.responseText ) ;
50
51        }
52}
53
54FCKXml.prototype.SelectNodes = function( xpath, contextNode )
55{
56        if ( this.Error )
57                return new Array() ;
58
59        var aNodeArray = new Array();
60
61        var xPathResult = this.DOMDocument.evaluate( xpath, contextNode ? contextNode : this.DOMDocument,
62                        this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
63        if ( xPathResult )
64        {
65                var oNode = xPathResult.iterateNext() ;
66                while( oNode )
67                {
68                        aNodeArray[aNodeArray.length] = oNode ;
69                        oNode = xPathResult.iterateNext();
70                }
71        }
72        return aNodeArray ;
73}
74
75FCKXml.prototype.SelectSingleNode = function( xpath, contextNode )
76{
77        if ( this.Error )
78                return null ;
79
80        var xPathResult = this.DOMDocument.evaluate( xpath, contextNode ? contextNode : this.DOMDocument,
81                        this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);
82
83        if ( xPathResult && xPathResult.singleNodeValue )
84                return xPathResult.singleNodeValue ;
85        else
86                return null ;
87}
Note: See TracBrowser for help on using the repository browser.