[ Index ] |
|
Code source de FCKeditor 2.4 |
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 * File Name: fckxml.js 22 * Defines the FCKXml object that is used for XML data calls 23 * and XML processing. 24 * This script is shared by almost all pages that compose the 25 * File Browser frameset. 26 * 27 * File Authors: 28 * Frederico Caldeira Knabben (www.fckeditor.net) 29 */ 30 31 var FCKXml = function() 32 {} 33 34 FCKXml.prototype.GetHttpRequest = function() 35 { 36 // Gecko / IE7 37 if ( typeof(XMLHttpRequest) != 'undefined' ) 38 return new XMLHttpRequest() ; 39 40 // IE6 41 try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; } 42 catch(e) {} 43 44 // IE5 45 try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; } 46 catch(e) {} 47 48 return null ; 49 } 50 51 FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer ) 52 { 53 var oFCKXml = this ; 54 55 var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ; 56 57 var oXmlHttp = this.GetHttpRequest() ; 58 59 oXmlHttp.open( "GET", urlToCall, bAsync ) ; 60 61 if ( bAsync ) 62 { 63 oXmlHttp.onreadystatechange = function() 64 { 65 if ( oXmlHttp.readyState == 4 ) 66 { 67 if ( oXmlHttp.responseXML == null || oXmlHttp.responseXML.firstChild == null) 68 { 69 alert( 'The server didn\'t send back a proper XML response.\r\n\r\n' + 70 'Requested URL: ' + urlToCall + '\r\n' + 71 'Response text:\r\n' + oXmlHttp.responseText ) ; 72 return ; 73 } 74 oFCKXml.DOMDocument = oXmlHttp.responseXML ; 75 if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 ) 76 asyncFunctionPointer( oFCKXml ) ; 77 else 78 alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ; 79 } 80 } 81 } 82 83 oXmlHttp.send( null ) ; 84 85 if ( ! bAsync ) 86 { 87 if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 ) 88 this.DOMDocument = oXmlHttp.responseXML ; 89 else 90 { 91 alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ; 92 } 93 } 94 } 95 96 FCKXml.prototype.SelectNodes = function( xpath ) 97 { 98 if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE 99 return this.DOMDocument.selectNodes( xpath ) ; 100 else // Gecko 101 { 102 var aNodeArray = new Array(); 103 104 var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, 105 this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ; 106 if ( xPathResult ) 107 { 108 var oNode = xPathResult.iterateNext() ; 109 while( oNode ) 110 { 111 aNodeArray[aNodeArray.length] = oNode ; 112 oNode = xPathResult.iterateNext(); 113 } 114 } 115 return aNodeArray ; 116 } 117 } 118 119 FCKXml.prototype.SelectSingleNode = function( xpath ) 120 { 121 if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE 122 return this.DOMDocument.selectSingleNode( xpath ) ; 123 else // Gecko 124 { 125 var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, 126 this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null); 127 128 if ( xPathResult && xPathResult.singleNodeValue ) 129 return xPathResult.singleNodeValue ; 130 else 131 return null ; 132 } 133 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 15:28:05 2007 | par Balluche grâce à PHPXref 0.7 |