Subversion Repositories Applications.papyrus

Rev

Rev 431 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 ddelon 1
/*
2
 * FCKeditor - The text editor for internet
3
 * Copyright (C) 2003-2005 Frederico Caldeira Knabben
4
 *
5
 * Licensed under the terms of the GNU Lesser General Public License:
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
7
 *
8
 * For further information visit:
9
 * 		http://www.fckeditor.net/
10
 *
521 ddelon 11
 * "Support Open Source software. What about a donation today?"
12
 *
431 ddelon 13
 * File Name: fck_link.js
14
 * 	Scripts related to the Link dialog window (see fck_link.html).
15
 *
16
 * File Authors:
17
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
18
 */
19
 
20
var oEditor		= window.parent.InnerDialogLoaded() ;
21
var FCK			= oEditor.FCK ;
22
var FCKLang		= oEditor.FCKLang ;
23
var FCKConfig	= oEditor.FCKConfig ;
24
 
25
//#### Dialog Tabs
26
 
27
// Set the dialog tabs.
28
window.parent.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ;
29
 
30
if ( !FCKConfig.LinkDlgHideTarget )
31
	window.parent.AddTab( 'Target', FCKLang.DlgLnkTargetTab, true ) ;
32
 
33
if ( FCKConfig.LinkUpload )
34
	window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload, true ) ;
35
 
36
if ( !FCKConfig.LinkDlgHideAdvanced )
37
	window.parent.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;
38
 
39
// Function called when a dialog tag is selected.
40
function OnDialogTabChange( tabCode )
41
{
42
	ShowE('divInfo'		, ( tabCode == 'Info' ) ) ;
43
	ShowE('divTarget'	, ( tabCode == 'Target' ) ) ;
44
	ShowE('divUpload'	, ( tabCode == 'Upload' ) ) ;
45
	ShowE('divAttribs'	, ( tabCode == 'Advanced' ) ) ;
46
}
47
 
48
//#### Regular Expressions library.
49
var oRegex = new Object() ;
50
 
51
oRegex.UriProtocol = new RegExp('') ;
52
oRegex.UriProtocol.compile( '^(((http|https|ftp|news):\/\/)|mailto:)', 'gi' ) ;
53
 
54
oRegex.UrlOnChangeProtocol = new RegExp('') ;
55
oRegex.UrlOnChangeProtocol.compile( '^(http|https|ftp|news)://(?=.)', 'gi' ) ;
56
 
57
oRegex.UrlOnChangeTestOther = new RegExp('') ;
521 ddelon 58
//oRegex.UrlOnChangeTestOther.compile( '^(javascript:|#|/)', 'gi' ) ;
59
oRegex.UrlOnChangeTestOther.compile( '^((javascript:)|[#/\.])', 'gi' ) ;
431 ddelon 60
 
61
oRegex.ReserveTarget = new RegExp('') ;
62
oRegex.ReserveTarget.compile( '^_(blank|self|top|parent)$', 'i' ) ;
63
 
64
oRegex.PopupUri = new RegExp('') ;
65
oRegex.PopupUri.compile( "^javascript:void\\(\\s*window.open\\(\\s*'([^']+)'\\s*,\\s*(?:'([^']*)'|null)\\s*,\\s*'([^']*)'\\s*\\)\\s*\\)\\s*$" ) ;
66
 
67
oRegex.PopupFeatures = new RegExp('') ;
68
oRegex.PopupFeatures.compile( '(?:^|,)([^=]+)=(\\d+|yes|no)', 'gi' ) ;
69
 
70
//#### Parser Functions
71
 
72
var oParser = new Object() ;
73
 
74
oParser.ParseEMailUrl = function( emailUrl )
75
{
76
	// Initializes the EMailInfo object.
77
	var oEMailInfo = new Object() ;
78
	oEMailInfo.Address	= '' ;
79
	oEMailInfo.Subject	= '' ;
80
	oEMailInfo.Body		= '' ;
81
 
82
	var oParts = emailUrl.match( /^([^\?]+)\??(.+)?/ ) ;
83
	if ( oParts )
84
	{
85
		// Set the e-mail address.
86
		oEMailInfo.Address = oParts[1] ;
87
 
88
		// Look for the optional e-mail parameters.
89
		if ( oParts[2] )
90
		{
91
			var oMatch = oParts[2].match( /(^|&)subject=([^&]+)/i ) ;
92
			if ( oMatch ) oEMailInfo.Subject = unescape( oMatch[2] ) ;
93
 
94
			oMatch = oParts[2].match( /(^|&)body=([^&]+)/i ) ;
95
			if ( oMatch ) oEMailInfo.Body = unescape( oMatch[2] ) ;
96
		}
97
	}
98
 
99
	return oEMailInfo ;
100
}
101
 
102
oParser.CreateEMailUri = function( address, subject, body )
103
{
104
	var sBaseUri = 'mailto:' + address ;
105
 
106
	var sParams = '' ;
107
 
108
	if ( subject.length > 0 )
109
		sParams = '?subject=' + escape( subject ) ;
110
 
111
	if ( body.length > 0 )
112
	{
113
		sParams += ( sParams.length == 0 ? '?' : '&' ) ;
114
		sParams += 'body=' + escape( body ) ;
115
	}
116
 
117
	return sBaseUri + sParams ;
118
}
119
 
120
//#### Initialization Code
121
 
122
// oLink: The actual selected link in the editor.
123
var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ;
124
if ( oLink )
125
	FCK.Selection.SelectNode( oLink ) ;
126
 
127
window.onload = function()
128
{
129
	// Translate the dialog box texts.
130
	oEditor.FCKLanguageManager.TranslatePage(document) ;
131
 
132
	// Fill the Anchor Names and Ids combos.
133
	LoadAnchorNamesAndIds() ;
134
 
135
	// Load the selected link information (if any).
136
	LoadSelection() ;
137
 
138
	// Update the dialog box.
139
	SetLinkType( GetE('cmbLinkType').value ) ;
140
 
141
	// Show/Hide the "Browse Server" button.
142
	GetE('divBrowseServer').style.display = FCKConfig.LinkBrowser ? '' : 'none' ;
143
 
144
	// Show the initial dialog content.
145
	GetE('divInfo').style.display = '' ;
146
 
147
	// Set the actual uploader URL.
148
	if ( FCKConfig.LinkUpload )
149
		GetE('frmUpload').action = FCKConfig.LinkUploadURL ;
150
 
151
	// Activate the "OK" button.
152
	window.parent.SetOkButton( true ) ;
153
}
154
 
155
var bHasAnchors ;
156
 
157
function LoadAnchorNamesAndIds()
158
{
521 ddelon 159
	// Since version 2.0, the anchors are replaced in the DOM by IMGs so the user see the icon
160
	// to edit them. So, we must look for that images now.
161
	var aAnchors = new Array() ;
162
 
163
	var oImages = oEditor.FCK.EditorDocument.getElementsByTagName( 'IMG' ) ;
164
	for( var i = 0 ; i < oImages.length ; i++ )
165
	{
166
		if ( oImages[i].getAttribute('_fckanchor') )
167
			aAnchors[ aAnchors.length ] = oEditor.FCK.GetRealElement( oImages[i] ) ;
168
	}
169
 
170
	var aIds = oEditor.FCKTools.GetAllChildrenIds( oEditor.FCK.EditorDocument.body ) ;
431 ddelon 171
 
172
	bHasAnchors = ( aAnchors.length > 0 || aIds.length > 0 ) ;
173
 
174
	for ( var i = 0 ; i < aAnchors.length ; i++ )
175
	{
176
		var sName = aAnchors[i].name ;
177
		if ( sName && sName.length > 0 )
178
			oEditor.FCKTools.AddSelectOption( document, GetE('cmbAnchorName'), sName, sName ) ;
179
	}
180
 
181
	for ( var i = 0 ; i < aIds.length ; i++ )
182
	{
183
		oEditor.FCKTools.AddSelectOption( document, GetE('cmbAnchorId'), aIds[i], aIds[i] ) ;
184
	}
185
 
186
	ShowE( 'divSelAnchor'	, bHasAnchors ) ;
187
	ShowE( 'divNoAnchor'	, !bHasAnchors ) ;
188
}
189
 
190
function LoadSelection()
191
{
192
	if ( !oLink ) return ;
193
 
194
	var sType = 'url' ;
195
 
196
	// Get the actual Link href.
197
	var sHRef = oLink.getAttribute('href',2) + '' ;
198
 
199
	// TODO: Wait stable version and remove the following commented lines.
200
//	if ( sHRef.startsWith( FCK.BaseUrl ) )
201
//		sHRef = sHRef.remove( 0, FCK.BaseUrl.length ) ;
202
 
203
	// Look for a popup javascript link.
204
	var oPopupMatch = oRegex.PopupUri.exec( sHRef ) ;
205
	if( oPopupMatch )
206
	{
207
		GetE('cmbTarget').value = 'popup' ;
208
		sHRef = oPopupMatch[1] ;
209
		FillPopupFields( oPopupMatch[2], oPopupMatch[3] ) ;
210
		SetTarget( 'popup' ) ;
211
	}
212
 
213
	// Search for the protocol.
214
	var sProtocol = oRegex.UriProtocol.exec( sHRef ) ;
215
 
216
	if ( sProtocol )
217
	{
218
		sProtocol = sProtocol[0].toLowerCase() ;
219
		GetE('cmbLinkProtocol').value = sProtocol ;
220
 
221
		// Remove the protocol and get the remainig URL.
222
		var sUrl = sHRef.replace( oRegex.UriProtocol, '' ) ;
223
 
224
		if ( sProtocol == 'mailto:' )	// It is an e-mail link.
225
		{
226
			sType = 'email' ;
227
 
228
			var oEMailInfo = oParser.ParseEMailUrl( sUrl ) ;
229
			GetE('txtEMailAddress').value	= oEMailInfo.Address ;
230
			GetE('txtEMailSubject').value	= oEMailInfo.Subject ;
231
			GetE('txtEMailBody').value		= oEMailInfo.Body ;
232
		}
233
		else				// It is a normal link.
234
		{
235
			sType = 'url' ;
236
			GetE('txtUrl').value = sUrl ;
237
		}
238
	}
239
	else if ( sHRef.substr(0,1) == '#' && sHRef.length > 2 )	// It is an anchor link.
240
	{
241
		sType = 'anchor' ;
242
		GetE('cmbAnchorName').value = GetE('cmbAnchorId').value = sHRef.substr(1) ;
243
	}
244
	else					// It is another type of link.
245
	{
246
		sType = 'url' ;
247
 
248
		GetE('cmbLinkProtocol').value = '' ;
249
		GetE('txtUrl').value = sHRef ;
250
	}
251
 
252
	if ( !oPopupMatch )
253
	{
254
		// Get the target.
255
		var sTarget = oLink.target ;
256
 
257
		if ( sTarget && sTarget.length > 0 )
258
		{
259
			if ( oRegex.ReserveTarget.test( sTarget ) )
260
			{
261
				sTarget = sTarget.toLowerCase() ;
262
				GetE('cmbTarget').value = sTarget ;
263
			}
264
			else
265
				GetE('cmbTarget').value = 'frame' ;
266
			GetE('txtTargetFrame').value = sTarget ;
267
		}
268
	}
269
 
270
	// Get Advances Attributes
271
	GetE('txtAttId').value			= oLink.id ;
272
	GetE('txtAttName').value		= oLink.name ;
273
	GetE('cmbAttLangDir').value		= oLink.dir ;
274
	GetE('txtAttLangCode').value	= oLink.lang ;
275
	GetE('txtAttAccessKey').value	= oLink.accessKey ;
276
	GetE('txtAttTabIndex').value	= oLink.tabIndex <= 0 ? '' : oLink.tabIndex ;
277
	GetE('txtAttTitle').value		= oLink.title ;
278
	GetE('txtAttContentType').value	= oLink.type ;
279
	GetE('txtAttCharSet').value		= oLink.charset ;
280
 
281
	if ( oEditor.FCKBrowserInfo.IsIE )
282
	{
283
		GetE('txtAttClasses').value	= oLink.getAttribute('className',2) || '' ;
284
		GetE('txtAttStyle').value	= oLink.style.cssText ;
285
	}
286
	else
287
	{
288
		GetE('txtAttClasses').value	= oLink.getAttribute('class',2) || '' ;
289
		GetE('txtAttStyle').value	= oLink.getAttribute('style',2) ;
290
	}
291
 
292
	// Update the Link type combo.
293
	GetE('cmbLinkType').value = sType ;
294
}
295
 
296
//#### Link type selection.
297
function SetLinkType( linkType )
298
{
299
	ShowE('divLinkTypeUrl'		, (linkType == 'url') ) ;
300
	ShowE('divLinkTypeAnchor'	, (linkType == 'anchor') ) ;
301
	ShowE('divLinkTypeEMail'	, (linkType == 'email') ) ;
302
 
303
	if ( !FCKConfig.LinkDlgHideTarget )
304
		window.parent.SetTabVisibility( 'Target'	, (linkType == 'url') ) ;
305
 
306
	if ( FCKConfig.LinkUpload )
307
		window.parent.SetTabVisibility( 'Upload'	, (linkType == 'url') ) ;
308
 
309
	if ( !FCKConfig.LinkDlgHideAdvanced )
310
		window.parent.SetTabVisibility( 'Advanced'	, (linkType != 'anchor' || bHasAnchors) ) ;
311
 
312
	if ( linkType == 'email' )
313
		window.parent.SetAutoSize( true ) ;
314
}
315
 
316
//#### Target type selection.
317
function SetTarget( targetType )
318
{
319
	GetE('tdTargetFrame').style.display	= ( targetType == 'popup' ? 'none' : '' ) ;
320
	GetE('tdPopupName').style.display	=
321
		GetE('tablePopupFeatures').style.display = ( targetType == 'popup' ? '' : 'none' ) ;
322
 
323
	switch ( targetType )
324
	{
325
		case "_blank" :
326
		case "_self" :
327
		case "_parent" :
328
		case "_top" :
329
			GetE('txtTargetFrame').value = targetType ;
330
			break ;
331
		case "" :
332
			GetE('txtTargetFrame').value = '' ;
333
			break ;
334
	}
335
 
336
	if ( targetType == 'popup' )
337
		window.parent.SetAutoSize( true ) ;
338
}
339
 
340
//#### Called while the user types the URL.
341
function OnUrlChange()
342
{
343
	var sUrl = GetE('txtUrl').value ;
344
	var sProtocol = oRegex.UrlOnChangeProtocol.exec( sUrl ) ;
345
 
346
	if ( sProtocol )
347
	{
348
		sUrl = sUrl.substr( sProtocol[0].length ) ;
349
		GetE('txtUrl').value = sUrl ;
350
		GetE('cmbLinkProtocol').value = sProtocol[0].toLowerCase() ;
351
	}
352
	else if ( oRegex.UrlOnChangeTestOther.test( sUrl ) )
353
	{
354
		GetE('cmbLinkProtocol').value = '' ;
355
	}
356
}
357
 
358
//#### Called while the user types the target name.
359
function OnTargetNameChange()
360
{
361
	var sFrame = GetE('txtTargetFrame').value ;
362
 
363
	if ( sFrame.length == 0 )
364
		GetE('cmbTarget').value = '' ;
365
	else if ( oRegex.ReserveTarget.test( sFrame ) )
366
		GetE('cmbTarget').value = sFrame.toLowerCase() ;
367
	else
368
		GetE('cmbTarget').value = 'frame' ;
369
}
370
 
371
//#### Builds the javascript URI to open a popup to the specified URI.
372
function BuildPopupUri( uri )
373
{
374
	var oReg = new RegExp( "'", "g" ) ;
375
	var sWindowName = "'" + GetE('txtPopupName').value.replace(oReg, "\\'") + "'" ;
376
 
377
	var sFeatures = '' ;
378
	var aChkFeatures = document.getElementsByName('chkFeature') ;
379
	for ( var i = 0 ; i < aChkFeatures.length ; i++ )
380
	{
381
		if ( i > 0 ) sFeatures += ',' ;
382
		sFeatures += aChkFeatures[i].value + '=' + ( aChkFeatures[i].checked ? 'yes' : 'no' ) ;
383
	}
384
 
385
	if ( GetE('txtPopupWidth').value.length > 0 )	sFeatures += ',width=' + GetE('txtPopupWidth').value ;
386
	if ( GetE('txtPopupHeight').value.length > 0 )	sFeatures += ',height=' + GetE('txtPopupHeight').value ;
387
	if ( GetE('txtPopupLeft').value.length > 0 )	sFeatures += ',left=' + GetE('txtPopupLeft').value ;
388
	if ( GetE('txtPopupTop').value.length > 0 )		sFeatures += ',top=' + GetE('txtPopupTop').value ;
389
 
390
	return ( "javascript:void(window.open('" + uri + "'," + sWindowName + ",'" + sFeatures + "'))" ) ;
391
}
392
 
393
//#### Fills all Popup related fields.
394
function FillPopupFields( windowName, features )
395
{
396
	if ( windowName )
397
		GetE('txtPopupName').value = windowName ;
398
 
399
	var oFeatures = new Object() ;
400
	var oFeaturesMatch ;
401
	while( ( oFeaturesMatch = oRegex.PopupFeatures.exec( features ) ) != null )
402
	{
403
		var sValue = oFeaturesMatch[2] ;
404
		if ( sValue == ( 'yes' || '1' ) )
405
			oFeatures[ oFeaturesMatch[1] ] = true ;
406
		else if ( ! isNaN( sValue ) && sValue != 0 )
407
			oFeatures[ oFeaturesMatch[1] ] = sValue ;
408
	}
409
 
410
	// Update all features check boxes.
411
	var aChkFeatures = document.getElementsByName('chkFeature') ;
412
	for ( var i = 0 ; i < aChkFeatures.length ; i++ )
413
	{
414
		if ( oFeatures[ aChkFeatures[i].value ] )
415
			aChkFeatures[i].checked = true ;
416
	}
417
 
418
	// Update position and size text boxes.
419
	if ( oFeatures['width'] )	GetE('txtPopupWidth').value		= oFeatures['width'] ;
420
	if ( oFeatures['height'] )	GetE('txtPopupHeight').value	= oFeatures['height'] ;
421
	if ( oFeatures['left'] )	GetE('txtPopupLeft').value		= oFeatures['left'] ;
422
	if ( oFeatures['top'] )		GetE('txtPopupTop').value		= oFeatures['top'] ;
423
}
424
 
425
//#### The OK button was hit.
426
function Ok()
427
{
428
	var sUri ;
429
 
430
	switch ( GetE('cmbLinkType').value )
431
	{
432
		case 'url' :
433
			sUri = GetE('txtUrl').value ;
434
 
435
			if ( sUri.length == 0 )
436
			{
437
				alert( FCKLang.DlnLnkMsgNoUrl ) ;
438
				return false ;
439
			}
440
 
441
			sUri = GetE('cmbLinkProtocol').value + sUri ;
442
 
443
			if( GetE('cmbTarget').value == 'popup' )
444
				sUri = BuildPopupUri( sUri ) ;
445
 
446
			break ;
447
 
448
		case 'email' :
449
			sUri = GetE('txtEMailAddress').value ;
450
 
451
			if ( sUri.length == 0 )
452
			{
453
				alert( FCKLang.DlnLnkMsgNoEMail ) ;
454
				return false ;
455
			}
456
 
457
			sUri = oParser.CreateEMailUri(
458
				sUri,
459
				GetE('txtEMailSubject').value,
460
				GetE('txtEMailBody').value ) ;
461
			break ;
462
 
463
		case 'anchor' :
464
			var sAnchor = GetE('cmbAnchorName').value ;
465
			if ( sAnchor.length == 0 ) sAnchor = GetE('cmbAnchorId').value ;
466
 
467
			if ( sAnchor.length == 0 )
468
			{
469
				alert( FCKLang.DlnLnkMsgNoAnchor ) ;
470
				return false ;
471
			}
472
 
473
			sUri = '#' + sAnchor ;
474
			break ;
475
	}
476
 
477
	if ( oLink )	// Modifying an existent link.
478
	{
479
		oEditor.FCKUndo.SaveUndoStep() ;
480
		oLink.href = sUri ;
481
	}
482
	else			// Creating a new link.
483
	{
484
		oLink = oEditor.FCK.CreateLink( sUri ) ;
485
		if ( ! oLink )
486
			return true ;
487
	}
488
 
489
	// Target
490
	if( GetE('cmbTarget').value != 'popup' )
491
		SetAttribute( oLink, 'target', GetE('txtTargetFrame').value ) ;
492
	else
493
		SetAttribute( oLink, 'target', null ) ;
494
 
495
	// Advances Attributes
496
	SetAttribute( oLink, 'id'		, GetE('txtAttId').value ) ;
497
	SetAttribute( oLink, 'name'		, GetE('txtAttName').value ) ;		// No IE. Set but doesnt't update the outerHTML.
498
	SetAttribute( oLink, 'dir'		, GetE('cmbAttLangDir').value ) ;
499
	SetAttribute( oLink, 'lang'		, GetE('txtAttLangCode').value ) ;
500
	SetAttribute( oLink, 'accesskey', GetE('txtAttAccessKey').value ) ;
501
	SetAttribute( oLink, 'tabindex'	, ( GetE('txtAttTabIndex').value > 0 ? GetE('txtAttTabIndex').value : null ) ) ;
502
	SetAttribute( oLink, 'title'	, GetE('txtAttTitle').value ) ;
503
	SetAttribute( oLink, 'class'	, GetE('txtAttClasses').value ) ;
504
	SetAttribute( oLink, 'type'		, GetE('txtAttContentType').value ) ;
505
	SetAttribute( oLink, 'charset'	, GetE('txtAttCharSet').value ) ;
506
 
507
	if ( oEditor.FCKBrowserInfo.IsIE )
508
		oLink.style.cssText = GetE('txtAttStyle').value ;
509
	else
510
		SetAttribute( oLink, 'style', GetE('txtAttStyle').value ) ;
511
 
512
	return true ;
513
}
514
 
515
function BrowseServer()
516
{
517
	// Set the browser window feature.
518
	var iWidth	= FCKConfig.LinkBrowserWindowWidth ;
519
	var iHeight	= FCKConfig.LinkBrowserWindowHeight ;
520
 
521 ddelon 521
	var iLeft = (FCKConfig.ScreenWidth  - iWidth) / 2 ;
522
	var iTop  = (FCKConfig.ScreenHeight - iHeight) / 2 ;
431 ddelon 523
 
524
	var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ;
525
	sOptions += ",width=" + iWidth ;
526
	sOptions += ",height=" + iHeight ;
527
	sOptions += ",left=" + iLeft ;
528
	sOptions += ",top=" + iTop ;
529
 
521 ddelon 530
	if ( oEditor.FCKBrowserInfo.IsIE )
531
	{
532
		// The following change has been made otherwise IE will open the file
533
		// browser on a different server session (on some cases):
534
		// http://support.microsoft.com/default.aspx?scid=kb;en-us;831678
535
		// by Simone Chiaretta.
536
		var oWindow = oEditor.window.open( FCKConfig.LinkBrowserURL, "FCKBrowseWindow", sOptions ) ;
537
		oWindow.opener = window ;
538
    }
539
    else
540
		window.open( FCKConfig.LinkBrowserURL, "FCKBrowseWindow", sOptions ) ;
431 ddelon 541
}
542
 
543
function SetUrl( url )
544
{
545
	document.getElementById('txtUrl').value = url ;
546
	OnUrlChange() ;
547
	window.parent.SetSelectedTab( 'Info' ) ;
548
}
549
 
550
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
551
{
552
	switch ( errorNumber )
553
	{
554
		case 0 :	// No errors
555
			alert( 'Your file has been successfully uploaded' ) ;
556
			break ;
557
		case 1 :	// Custom error
558
			alert( customMsg ) ;
559
			return ;
560
		case 101 :	// Custom warning
561
			alert( customMsg ) ;
562
			break ;
563
		case 201 :
564
			alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
565
			break ;
566
		case 202 :
567
			alert( 'Invalid file type' ) ;
568
			return ;
569
		case 203 :
570
			alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
571
			return ;
572
		default :
573
			alert( 'Error on file upload. Error number: ' + errorNumber ) ;
574
			return ;
575
	}
576
 
577
	SetUrl( fileUrl ) ;
578
	GetE('frmUpload').reset() ;
579
}
580
 
581
var oUploadAllowedExtRegex	= new RegExp( FCKConfig.LinkUploadAllowedExtensions, 'i' ) ;
582
var oUploadDeniedExtRegex	= new RegExp( FCKConfig.LinkUploadDeniedExtensions, 'i' ) ;
583
 
584
function CheckUpload()
585
{
586
	var sFile = GetE('txtUploadFile').value ;
587
 
588
	if ( sFile.length == 0 )
589
	{
590
		alert( 'Please select a file to upload' ) ;
591
		return false ;
592
	}
593
 
594
	if ( ( FCKConfig.LinkUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) ||
595
		( FCKConfig.LinkUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) )
596
	{
597
		OnUploadCompleted( 202 ) ;
598
		return false ;
599
	}
600
 
601
	return true ;
602
}