[geeklog-cvs] Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_link fck_link.js, 1.7, 1.8

Blaine Lang blaine at qs1489.pair.com
Sun Aug 10 12:46:32 EDT 2008


Update of /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_link
In directory qs1489.pair.com:/tmp/cvs-serv4567/editor/dialog/fck_link

Modified Files:
	fck_link.js 
Log Message:
Upgrade to FCKeditor ver 2.6.3

Index: fck_link.js
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/fckeditor/editor/dialog/fck_link/fck_link.js,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** fck_link.js	5 May 2008 00:35:24 -0000	1.7
--- fck_link.js	10 Aug 2008 16:46:29 -0000	1.8
***************
*** 78,111 ****
  var oParser = new Object() ;
  
! oParser.ParseEMailUrl = function( emailUrl )
  {
  	// Initializes the EMailInfo object.
  	var oEMailInfo = new Object() ;
! 	oEMailInfo.Address	= '' ;
! 	oEMailInfo.Subject	= '' ;
! 	oEMailInfo.Body		= '' ;
  
! 	var oParts = emailUrl.match( /^([^\?]+)\??(.+)?/ ) ;
! 	if ( oParts )
  	{
! 		// Set the e-mail address.
! 		oEMailInfo.Address = oParts[1] ;
! 
! 		// Look for the optional e-mail parameters.
! 		if ( oParts[2] )
  		{
! 			var oMatch = oParts[2].match( /(^|&)subject=([^&]+)/i ) ;
! 			if ( oMatch ) oEMailInfo.Subject = decodeURIComponent( oMatch[2] ) ;
  
! 			oMatch = oParts[2].match( /(^|&)body=([^&]+)/i ) ;
! 			if ( oMatch ) oEMailInfo.Body = decodeURIComponent( oMatch[2] ) ;
  		}
  	}
  
! 	return oEMailInfo ;
  }
  
  oParser.CreateEMailUri = function( address, subject, body )
  {
  	var sBaseUri = 'mailto:' + address ;
  
--- 78,262 ----
  var oParser = new Object() ;
  
! // This method simply returns the two inputs in numerical order. You can even
! // provide strings, as the method would parseInt() the values.
! oParser.SortNumerical = function(a, b)
! {
! 	return parseInt( a, 10 ) - parseInt( b, 10 ) ;
! }
! 
! oParser.ParseEMailParams = function(sParams)
! {
! 	// Initialize the oEMailParams object.
! 	var oEMailParams = new Object() ;
! 	oEMailParams.Subject = '' ;
! 	oEMailParams.Body = '' ;
! 
! 	var aMatch = sParams.match( /(^|^\?|&)subject=([^&]+)/i ) ;
! 	if ( aMatch ) oEMailParams.Subject = decodeURIComponent( aMatch[2] ) ;
! 
! 	aMatch = sParams.match( /(^|^\?|&)body=([^&]+)/i ) ;
! 	if ( aMatch ) oEMailParams.Body = decodeURIComponent( aMatch[2] ) ;
! 
! 	return oEMailParams ;
! }
! 
! // This method returns either an object containing the email info, or FALSE
! // if the parameter is not an email link.
! oParser.ParseEMailUri = function( sUrl )
  {
  	// Initializes the EMailInfo object.
  	var oEMailInfo = new Object() ;
! 	oEMailInfo.Address = '' ;
! 	oEMailInfo.Subject = '' ;
! 	oEMailInfo.Body = '' ;
  
! 	var aLinkInfo = sUrl.match( /^(\w+):(.*)$/ ) ;
! 	if ( aLinkInfo && aLinkInfo[1] == 'mailto' )
  	{
! 		// This seems to be an unprotected email link.
! 		var aParts = aLinkInfo[2].match( /^([^\?]+)\??(.+)?/ ) ;
! 		if ( aParts )
  		{
! 			// Set the e-mail address.
! 			oEMailInfo.Address = aParts[1] ;
  
! 			// Look for the optional e-mail parameters.
! 			if ( aParts[2] )
! 			{
! 				var oEMailParams = oParser.ParseEMailParams( aParts[2] ) ;
! 				oEMailInfo.Subject = oEMailParams.Subject ;
! 				oEMailInfo.Body = oEMailParams.Body ;
! 			}
  		}
+ 		return oEMailInfo ;
  	}
+ 	else if ( aLinkInfo && aLinkInfo[1] == 'javascript' )
+ 	{
+ 		// This may be a protected email.
  
! 		// Try to match the url against the EMailProtectionFunction.
! 		var func = FCKConfig.EMailProtectionFunction ;
! 		if ( func != null )
! 		{
! 			try
! 			{
! 				// Escape special chars.
! 				func = func.replace( /([\/^$*+.?()\[\]])/g, '\\$1' ) ;
! 
! 				// Define the possible keys.
! 				var keys = new Array('NAME', 'DOMAIN', 'SUBJECT', 'BODY') ;
! 
! 				// Get the order of the keys (hold them in the array <pos>) and
! 				// the function replaced by regular expression patterns.
! 				var sFunc = func ;
! 				var pos = new Array() ;
! 				for ( var i = 0 ; i < keys.length ; i ++ )
! 				{
! 					var rexp = new RegExp( keys[i] ) ;
! 					var p = func.search( rexp ) ;
! 					if ( p >= 0 )
! 					{
! 						sFunc = sFunc.replace( rexp, '\'([^\']*)\'' ) ;
! 						pos[pos.length] = p + ':' + keys[i] ;
! 					}
! 				}
! 
! 				// Sort the available keys.
! 				pos.sort( oParser.SortNumerical ) ;
! 
! 				// Replace the excaped single quotes in the url, such they do
! 				// not affect the regexp afterwards.
! 				aLinkInfo[2] = aLinkInfo[2].replace( /\\'/g, '###SINGLE_QUOTE###' ) ;
! 
! 				// Create the regexp and execute it.
! 				var rFunc = new RegExp( '^' + sFunc + '$' ) ;
! 				var aMatch = rFunc.exec( aLinkInfo[2] ) ;
! 				if ( aMatch )
! 				{
! 					var aInfo = new Array();
! 					for ( var i = 1 ; i < aMatch.length ; i ++ )
! 					{
! 						var k = pos[i-1].match(/^\d+:(.+)$/) ;
! 						aInfo[k[1]] = aMatch[i].replace(/###SINGLE_QUOTE###/g, '\'') ;
! 					}
! 
! 					// Fill the EMailInfo object that will be returned
! 					oEMailInfo.Address = aInfo['NAME'] + '@' + aInfo['DOMAIN'] ;
! 					oEMailInfo.Subject = decodeURIComponent( aInfo['SUBJECT'] ) ;
! 					oEMailInfo.Body = decodeURIComponent( aInfo['BODY'] ) ;
! 
! 					return oEMailInfo ;
! 				}
! 			}
! 			catch (e)
! 			{
! 			}
! 		}
! 
! 		// Try to match the email against the encode protection.
! 		var aMatch = aLinkInfo[2].match( /^location\.href='mailto:'\+(String\.fromCharCode\([\d,]+\))\+'(.*)'$/ ) ;
! 		if ( aMatch )
! 		{
! 			// The link is encoded
! 			oEMailInfo.Address = eval( aMatch[1] ) ;
! 			if ( aMatch[2] )
! 			{
! 				var oEMailParams = oParser.ParseEMailParams( aMatch[2] ) ;
! 				oEMailInfo.Subject = oEMailParams.Subject ;
! 				oEMailInfo.Body = oEMailParams.Body ;
! 			}
! 			return oEMailInfo ;
! 		}
! 	}
! 	return false;
  }
  
  oParser.CreateEMailUri = function( address, subject, body )
  {
+ 	// Switch for the EMailProtection setting.
+ 	switch ( FCKConfig.EMailProtection )
+ 	{
+ 		case 'function' :
+ 			var func = FCKConfig.EMailProtectionFunction ;
+ 			if ( func == null )
+ 			{
+ 				if ( FCKConfig.Debug )
+ 				{
+ 					alert('EMailProtection alert!\nNo function defined. Please set "FCKConfig.EMailProtectionFunction"') ;
+ 				}
+ 				return '';
+ 			}
+ 
+ 			// Split the email address into name and domain parts.
+ 			var aAddressParts = address.split( '@', 2 ) ;
+ 			if ( aAddressParts[1] == undefined )
+ 			{
+ 				aAddressParts[1] = '' ;
+ 			}
+ 
+ 			// Replace the keys by their values (embedded in single quotes).
+ 			func = func.replace(/NAME/g, "'" + aAddressParts[0].replace(/'/g, '\\\'') + "'") ;
+ 			func = func.replace(/DOMAIN/g, "'" + aAddressParts[1].replace(/'/g, '\\\'') + "'") ;
+ 			func = func.replace(/SUBJECT/g, "'" + encodeURIComponent( subject ).replace(/'/g, '\\\'') + "'") ;
+ 			func = func.replace(/BODY/g, "'" + encodeURIComponent( body ).replace(/'/g, '\\\'') + "'") ;
+ 
+ 			return 'javascript:' + func ;
+ 
+ 		case 'encode' :
+ 			var aParams = [] ;
+ 			var aAddressCode = [] ;
+ 
+ 			if ( subject.length > 0 )
+ 				aParams.push( 'subject='+ encodeURIComponent( subject ) ) ;
+ 			if ( body.length > 0 )
+ 				aParams.push( 'body=' + encodeURIComponent( body ) ) ;
+ 			for ( var i = 0 ; i < address.length ; i++ )
+ 				aAddressCode.push( address.charCodeAt( i ) ) ;
+ 
+ 			return 'javascript:location.href=\'mailto:\'+String.fromCharCode(' + aAddressCode.join( ',' ) + ')+\'?' + aParams.join( '&' ) + '\'' ;
+ 	}
+ 
+ 	// EMailProtection 'none'
+ 
  	var sBaseUri = 'mailto:' + address ;
  
***************
*** 264,268 ****
  	var sProtocol = oRegex.UriProtocol.exec( sHRef ) ;
  
! 	if ( sProtocol )
  	{
  		sProtocol = sProtocol[0].toLowerCase() ;
--- 415,430 ----
  	var sProtocol = oRegex.UriProtocol.exec( sHRef ) ;
  
! 	// Search for a protected email link.
! 	var oEMailInfo = oParser.ParseEMailUri( sHRef );
! 
! 	if ( oEMailInfo )
! 	{
! 		sType = 'email' ;
! 
! 		GetE('txtEMailAddress').value = oEMailInfo.Address ;
! 		GetE('txtEMailSubject').value = oEMailInfo.Subject ;
! 		GetE('txtEMailBody').value    = oEMailInfo.Body ;
! 	}
! 	else if ( sProtocol )
  	{
  		sProtocol = sProtocol[0].toLowerCase() ;
***************
*** 271,289 ****
  		// Remove the protocol and get the remaining URL.
  		var sUrl = sHRef.replace( oRegex.UriProtocol, '' ) ;
! 
! 		if ( sProtocol == 'mailto:' )	// It is an e-mail link.
! 		{
! 			sType = 'email' ;
! 
! 			var oEMailInfo = oParser.ParseEMailUrl( sUrl ) ;
! 			GetE('txtEMailAddress').value	= oEMailInfo.Address ;
! 			GetE('txtEMailSubject').value	= oEMailInfo.Subject ;
! 			GetE('txtEMailBody').value		= oEMailInfo.Body ;
! 		}
! 		else				// It is a normal link.
! 		{
! 			sType = 'url' ;
! 			GetE('txtUrl').value = sUrl ;
! 		}
  	}
  	else if ( sHRef.substr(0,1) == '#' && sHRef.length > 1 )	// It is an anchor link.
--- 433,438 ----
  		// Remove the protocol and get the remaining URL.
  		var sUrl = sHRef.replace( oRegex.UriProtocol, '' ) ;
! 		sType = 'url' ;
! 		GetE('txtUrl').value = sUrl ;
  	}
  	else if ( sHRef.substr(0,1) == '#' && sHRef.length > 1 )	// It is an anchor link.
***************
*** 651,655 ****
  function SetUrl( url )
  {
! 	document.getElementById('txtUrl').value = url ;
  	OnUrlChange() ;
  	dialog.SetSelectedTab( 'Info' ) ;
--- 800,804 ----
  function SetUrl( url )
  {
! 	GetE('txtUrl').value = url ;
  	OnUrlChange() ;
  	dialog.SetSelectedTab( 'Info' ) ;
***************
*** 658,661 ****
--- 807,814 ----
  function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
  {
+ 	// Remove animation
+ 	window.parent.Throbber.Hide() ;
+ 	GetE( 'divUpload' ).style.display  = '' ;
+ 
  	switch ( errorNumber )
  	{
***************
*** 710,713 ****
--- 863,870 ----
  	}
  
+ 	// Show animation
+ 	window.parent.Throbber.Show( 100 ) ;
+ 	GetE( 'divUpload' ).style.display  = 'none' ;
+ 
  	return true ;
  }




More information about the geeklog-cvs mailing list