[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/cms/shared/js/ -> media.js (source)

   1  function GetXMLHttpRequest()
   2  {
   3    if ( window.XMLHttpRequest )        // Gecko
   4      return new XMLHttpRequest() ;
   5    else if ( window.ActiveXObject )    // IE
   6      return new ActiveXObject("MsXml2.XmlHttp") ;
   7  }
   8  
   9  function AddSelectOption( selectElement, optionText, optionValue )
  10  {
  11    var oOption = document.createElement("OPTION") ;
  12  
  13    oOption.text    = optionText ;
  14    oOption.value    = optionValue ;
  15  
  16    selectElement.options.add(oOption) ;
  17  
  18    return oOption ;
  19  }
  20  
  21  var oConnector    = window.parent.oConnector ;
  22  var oIcons        = window.parent.oIcons ;
  23  
  24  var FCKXml = function(){}
  25  
  26  FCKXml.prototype.GetHttpRequest = function()
  27  {
  28    if ( window.XMLHttpRequest )        // Gecko
  29      return new XMLHttpRequest() ;
  30    else if ( window.ActiveXObject )    // IE
  31      return new ActiveXObject("MsXml2.XmlHttp") ;
  32  }
  33  
  34  FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
  35  {
  36    var oFCKXml = this ;
  37  
  38    var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
  39  
  40    var oXmlHttp = this.GetHttpRequest() ;
  41  
  42    oXmlHttp.open( "GET", urlToCall, bAsync ) ;
  43  
  44    if ( bAsync )
  45    {
  46      oXmlHttp.onreadystatechange = function()
  47      {
  48        if ( oXmlHttp.readyState == 4 )
  49        {
  50          oFCKXml.DOMDocument = oXmlHttp.responseXML ;
  51          if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
  52            asyncFunctionPointer( oFCKXml ) ;
  53          else
  54            alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
  55        }
  56      }
  57    }
  58  
  59    oXmlHttp.send( null ) ;
  60  
  61    if ( ! bAsync )
  62    {
  63      if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
  64      {
  65        this.DOMDocument = oXmlHttp.responseXML ;
  66        return oFCKXml ;
  67      }
  68      else
  69      {
  70        alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
  71      }
  72    }
  73  }
  74  
  75  FCKXml.prototype.SelectNodes = function( xpath )
  76  {
  77    if ( document.all )        // IE
  78      return this.DOMDocument.selectNodes( xpath ) ;
  79    else                    // Gecko
  80    {
  81      var aNodeArray = new Array();
  82  
  83      var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
  84          this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
  85      if ( xPathResult )
  86      {
  87        var oNode = xPathResult.iterateNext() ;
  88        while( oNode )
  89        {
  90          aNodeArray[aNodeArray.length] = oNode ;
  91          oNode = xPathResult.iterateNext();
  92        }
  93      }
  94      return aNodeArray ;
  95    }
  96  }
  97  
  98  FCKXml.prototype.SelectSingleNode = function( xpath )
  99  {
 100    if ( document.all )        // IE
 101      return this.DOMDocument.selectSingleNode( xpath ) ;
 102    else                    // Gecko
 103    {
 104      var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
 105          this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);
 106  
 107      if ( xPathResult && xPathResult.singleNodeValue )
 108        return xPathResult.singleNodeValue ;
 109      else
 110        return null ;
 111    }
 112  }
 113  
 114  function GetMediaName(mediaUrl) //ugly!
 115  {
 116    items = mediaUrl.split('/') ;
 117    media_id = items[items.length - 1] ;
 118  
 119    var oXML = new FCKXml() ;
 120    var node = oXML.LoadUrl( "/media/info_xml/" + media_id).SelectSingleNode( 'Media' ) ;
 121    if(node)
 122      return node.attributes.getNamedItem('name').value ;
 123  }
 124  


Generated: Sat Nov 22 03:48:54 2008 Cross-referenced by PHPXref 0.7