Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1688 Rev 1921
Line 1... Line 1...
1
/*
1
/*
2
 * FCKeditor - The text editor for internet
2
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
3
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
-
 
4
 *
-
 
5
 * == BEGIN LICENSE ==
4
 * 
6
 *
5
 * Licensed under the terms of the GNU Lesser General Public License:
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")
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
11
 *    http://www.gnu.org/licenses/gpl.html
7
 * 
12
 *
8
 * For further information visit:
13
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
9
 * 		http://www.fckeditor.net/
14
 *    http://www.gnu.org/licenses/lgpl.html
10
 * 
15
 *
11
 * "Support Open Source software. What about a donation today?"
16
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
-
 
17
 *    http://www.mozilla.org/MPL/MPL-1.1.html
12
 * 
18
 *
13
 * File Name: fckxml.js
19
 * == END LICENSE ==
-
 
20
 *
14
 * 	Defines the FCKXml object that is used for XML data calls
21
 * Defines the FCKXml object that is used for XML data calls
15
 * 	and XML processing.
22
 * and XML processing.
-
 
23
 *
16
 * 	This script is shared by almost all pages that compose the 
24
 * This script is shared by almost all pages that compose the
17
 * 	File Browser frameset.
25
 * File Browser frameset.
18
 * 
-
 
19
 * File Authors:
-
 
20
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
-
 
21
 */
26
 */
Line 22... Line 27...
22
 
27
 
23
var FCKXml = function()
28
var FCKXml = function()
Line 24... Line 29...
24
{}
29
{}
25
 
30
 
26
FCKXml.prototype.GetHttpRequest = function()
31
FCKXml.prototype.GetHttpRequest = function()
27
{
-
 
28
	// Gecko / IE7
32
{
-
 
33
	// Gecko / IE7
Line 29... Line 34...
29
	if ( typeof(XMLHttpRequest) != 'undefined' )
34
	try { return new XMLHttpRequest(); }
30
		return new XMLHttpRequest() ;
35
	catch(e) {}
31
 
36
 
Line 32... Line 37...
32
	// IE6
37
	// IE6
33
	try { return new ActiveXObject("Msxml2.XMLHTTP") ; } 
38
	try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; }
34
	catch(e) {}
39
	catch(e) {}
-
 
40
 
-
 
41
	// IE5
35
 
42
	try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; }
Line 36... Line 43...
36
	// IE5
43
	catch(e) {}
37
	try { return new ActiveXObject("Microsoft.XMLHTTP") ; }
44
 
38
	catch(e) {}
45
	return null ;
Line 39... Line 46...
39
}
46
}
Line 40... Line 47...
40
 
47
 
41
FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
48
FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
42
{
49
{
43
	var oFCKXml = this ;
50
	var oFCKXml = this ;
44
 
51
 
45
	var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
52
	var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
46
 
53
 
47
	var oXmlHttp = this.GetHttpRequest() ;
54
	var oXmlHttp = this.GetHttpRequest() ;
48
		
55
 
49
	oXmlHttp.open( "GET", urlToCall, bAsync ) ;
56
	oXmlHttp.open( "GET", urlToCall, bAsync ) ;
-
 
57
 
-
 
58
	if ( bAsync )
-
 
59
	{
-
 
60
		oXmlHttp.onreadystatechange = function()
-
 
61
		{
-
 
62
			if ( oXmlHttp.readyState == 4 )
-
 
63
			{
50
	
64
				var oXml ;
-
 
65
				try
-
 
66
				{
-
 
67
					// this is the same test for an FF2 bug as in fckxml_gecko.js
-
 
68
					// but we've moved the responseXML assignment into the try{}
-
 
69
					// so we don't even have to check the return status codes.
51
	if ( bAsync )
70
					var test = oXmlHttp.responseXML.firstChild ;
-
 
71
					oXml = oXmlHttp.responseXML ;
52
	{	
72
				}
-
 
73
				catch ( e )
-
 
74
				{
-
 
75
					try
53
		oXmlHttp.onreadystatechange = function() 
76
					{
-
 
77
						oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ;
54
		{
78
					}
-
 
79
					catch ( e ) {}
-
 
80
				}
-
 
81
 
-
 
82
				if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' )
-
 
83
				{
-
 
84
					alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' +
-
 
85
							'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' +
55
			if ( oXmlHttp.readyState == 4 )
86
							'Requested URL:\n' + urlToCall + '\n\n' +
56
			{
87
							'Response text:\n' + oXmlHttp.responseText ) ;
57
				oFCKXml.DOMDocument = oXmlHttp.responseXML ;
88
					return ;
58
				if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
89
				}
59
					asyncFunctionPointer( oFCKXml ) ;
90
 
60
				else
91
				oFCKXml.DOMDocument = oXml ;
61
					alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
92
				asyncFunctionPointer( oFCKXml ) ;
62
			}
93
			}
63
		}
94
		}
64
	}
95
	}
65
	
96
 
Line 82... Line 113...
82
		return this.DOMDocument.selectNodes( xpath ) ;
113
		return this.DOMDocument.selectNodes( xpath ) ;
83
	else					// Gecko
114
	else					// Gecko
84
	{
115
	{
85
		var aNodeArray = new Array();
116
		var aNodeArray = new Array();
Line 86... Line 117...
86
 
117
 
87
		var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, 
118
		var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
88
				this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
119
				this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
89
		if ( xPathResult ) 
120
		if ( xPathResult )
90
		{
121
		{
91
			var oNode = xPathResult.iterateNext() ;
122
			var oNode = xPathResult.iterateNext() ;
92
 			while( oNode )
123
 			while( oNode )
93
 			{
124
 			{
94
 				aNodeArray[aNodeArray.length] = oNode ;
125
 				aNodeArray[aNodeArray.length] = oNode ;
95
 				oNode = xPathResult.iterateNext();
126
 				oNode = xPathResult.iterateNext();
96
 			}
127
 			}
97
		} 
128
		}
98
		return aNodeArray ;
129
		return aNodeArray ;
99
	}
130
	}
Line 100... Line 131...
100
}
131
}
101
 
132
 
102
FCKXml.prototype.SelectSingleNode = function( xpath ) 
133
FCKXml.prototype.SelectSingleNode = function( xpath )
103
{
134
{
104
	if ( navigator.userAgent.indexOf('MSIE') >= 0 )		// IE
135
	if ( navigator.userAgent.indexOf('MSIE') >= 0 )		// IE
105
		return this.DOMDocument.selectSingleNode( xpath ) ;
136
		return this.DOMDocument.selectSingleNode( xpath ) ;
106
	else					// Gecko
137
	else					// Gecko
107
	{
138
	{
Line 108... Line 139...
108
		var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
139
		var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
109
				this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);
140
				this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);
110
 
141
 
111
		if ( xPathResult && xPathResult.singleNodeValue )
142
		if ( xPathResult && xPathResult.singleNodeValue )
112
			return xPathResult.singleNodeValue ;
143
			return xPathResult.singleNodeValue ;
113
		else	
144
		else