FCKeditor - Resources Browser
function GetUrlParam( paramName )
{
var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ;
var oMatch = oRegex.exec( window.top.location.search ) ;
if ( oMatch && oMatch.length > 1 )
return oMatch[1] ;
else
return '' ;
}
var oConnector = new Object() ;
oConnector.CurrentFolder = '/' ;
var sConnUrl = GetUrlParam( 'Connector' ) ;
// Gecko has some problems when using relative URLs (not starting with slash).
if ( sConnUrl.substr(0,1) != '/' && sConnUrl.indexOf( '://' ) < 0 )
sConnUrl = window.location.href.replace( /browser.html.*$/, '' ) + sConnUrl ;
oConnector.ConnectorUrl = sConnUrl + ( sConnUrl.indexOf('?') != -1 ? '&' : '?' ) ;
var sServerPath = GetUrlParam( 'ServerPath' ) ;
if ( sServerPath.length > 0 )
oConnector.ConnectorUrl += 'ServerPath=' + escape( sServerPath ) + '&' ;
oConnector.ResourceType = GetUrlParam( 'Type' ) ;
oConnector.ShowAllTypes = ( oConnector.ResourceType.length == 0 ) ;
if ( oConnector.ShowAllTypes )
oConnector.ResourceType = 'File' ;
oConnector.SendCommand = function( command, params, callBackFunction )
{
var sUrl = this.ConnectorUrl + 'Command=' + command ;
sUrl += '&Type=' + this.ResourceType ;
sUrl += '&CurrentFolder=' + escape( this.CurrentFolder ) ;
if ( params ) sUrl += '&' + params ;
var oXML = new FCKXml() ;
if ( callBackFunction )
oXML.LoadUrl( sUrl, callBackFunction ) ; // Asynchronous load.
else
return oXML.LoadUrl( sUrl ) ;
}
oConnector.CheckError = function( responseXml )
{
var iErrorNumber = 0
var oErrorNode = responseXml.SelectSingleNode( 'Connector/Error' ) ;
if ( oErrorNode )
{
iErrorNumber = parseInt( oErrorNode.attributes.getNamedItem('number').value ) ;
switch ( iErrorNumber )
{
case 0 :
break ;
case 1 : // Custom error. Message placed in the "text" attribute.
alert( oErrorNode.attributes.getNamedItem('text').value ) ;
break ;
case 101 :
alert( 'Folder already exists' ) ;
break ;
case 102 :
alert( 'Invalid folder name' ) ;
break ;
case 103 :
alert( 'You have no permissions to create the folder' ) ;
break ;
case 110 :
alert( 'Unknown error creating folder' ) ;
break ;
default :
alert( 'Error on your request. Error number: ' + iErrorNumber ) ;
break ;
}
}
return iErrorNumber ;
}
var oIcons = new Object() ;
oIcons.AvailableIconsArray = [
'ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js',
'mdb','mp3','pdf','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip' ] ;
oIcons.AvailableIcons = new Object() ;
for ( var i = 0 ; i < oIcons.AvailableIconsArray.length ; i++ )
oIcons.AvailableIcons[ oIcons.AvailableIconsArray[i] ] = true ;
oIcons.GetIcon = function( fileName )
{
var sExtension = fileName.substr( fileName.lastIndexOf('.') + 1 ).toLowerCase() ;
if ( this.AvailableIcons[ sExtension ] == true )
return sExtension ;
else
return 'default.icon' ;
}
Wyszukiwarka
Podobne podstrony:
browser detailsbrowse article view (2)browse mapbrowser infobrowse archivebrowsebrowse articles?it y (2)browse article pview (2)public web browser 5 z6ithnb7xpg7i5uotahfpwhmyj63ymcr63txwai z6ithnb7xpg7i5uotahfpwhmyj63ymcr63txwaibrowse?aturebrowse printablebrowse article view?tailspublic web browser 4 slrrn6uoi5rv64rikauo7y7prxyrlryvy2m4n7y slrrn6uoi5rv64rikauo7y7prxyrlryvy2m4n7ybrowse archivebrowse reviews?tails (2)browse mapwięcej podobnych podstron