1
|
/*
|
2
|
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
3
|
* Copyright (C) 2003-2008 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
|
* Scripts related to the Flash dialog window (see fck_flash.html).
|
22
|
*/
|
23
|
function Import(aSrc) {
|
24
|
document.write('<scr'+'ipt type="text/javascript" src="' + aSrc + '"></sc' + 'ript>');
|
25
|
}
|
26
|
|
27
|
var dialog = window.parent ;
|
28
|
var oEditor = dialog.InnerDialogLoaded() ;
|
29
|
var FCK = oEditor.FCK ;
|
30
|
var FCKLang = oEditor.FCKLang ;
|
31
|
var FCKConfig = oEditor.FCKConfig ;
|
32
|
var FCKTools = oEditor.FCKTools ;
|
33
|
|
34
|
Import(FCKConfig.FullBasePath + 'dialog/common/fck_dialog_common.js');
|
35
|
|
36
|
var oListText ;
|
37
|
var oListValue ;
|
38
|
|
39
|
//#### Dialog Tabs
|
40
|
|
41
|
// Set the dialog tabs.
|
42
|
dialog.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ;
|
43
|
|
44
|
if ( FCKConfig.FlashUpload )
|
45
|
dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;
|
46
|
|
47
|
if ( !FCKConfig.FlashDlgHideAdvanced )
|
48
|
{
|
49
|
dialog.AddTab( 'Advanced', oEditor.FCKLang.DlgAdvancedTag ) ;
|
50
|
dialog.AddTab( 'Flashvars', oEditor.FCKLang.DlgFlashvars ) ;
|
51
|
}
|
52
|
|
53
|
// Function called when a dialog tag is selected.
|
54
|
function OnDialogTabChange( tabCode )
|
55
|
{
|
56
|
ShowE('divInfo' , ( tabCode == 'Info' ) ) ;
|
57
|
ShowE('divUpload' , ( tabCode == 'Upload' ) ) ;
|
58
|
ShowE('divAdvanced' , ( tabCode == 'Advanced' ) ) ;
|
59
|
ShowE('divFlashvars' , ( tabCode == 'Flashvars' ) ) ;
|
60
|
}
|
61
|
|
62
|
// Get the selected flash embed (if available).
|
63
|
var oFakeImage = FCK.Selection.GetSelectedElement() ;
|
64
|
var oParsedFlash ;
|
65
|
var oEmbed;
|
66
|
|
67
|
if ( oFakeImage )
|
68
|
{
|
69
|
if ( oFakeImage.getAttribute( 'SwfObjectNumber' ) )
|
70
|
{
|
71
|
oParsedFlash = FCK.SwfobjectHandler.getItem( oFakeImage.getAttribute( 'SwfObjectNumber' ) );
|
72
|
oParsedFlash.updateDimensions( oFakeImage );
|
73
|
}
|
74
|
else
|
75
|
{
|
76
|
if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckflash') )
|
77
|
oEmbed = FCK.GetRealElement( oFakeImage ) ;
|
78
|
|
79
|
oFakeImage = null ;
|
80
|
}
|
81
|
}
|
82
|
if ( !oParsedFlash )
|
83
|
oParsedFlash = FCK.SwfobjectHandler.createNew() ;
|
84
|
|
85
|
window.onload = function()
|
86
|
{
|
87
|
// Translate the dialog box texts.
|
88
|
oEditor.FCKLanguageManager.TranslatePage(document) ;
|
89
|
|
90
|
oListText = document.getElementById( 'cmbText' ) ;
|
91
|
oListValue = document.getElementById( 'cmbValue' ) ;
|
92
|
|
93
|
// Fix the lists widths. (Bug #970)
|
94
|
oListText.style.width = "120px"; //oListText.offsetWidth ;
|
95
|
oListValue.style.width = "120px"; //oListValue.offsetWidth ;
|
96
|
|
97
|
// Load the selected element information (if any).
|
98
|
LoadSelection() ;
|
99
|
|
100
|
// Show/Hide the "Browse Server" button.
|
101
|
GetE('tdBrowse').style.display = FCKConfig.FlashBrowser ? '' : 'none' ;
|
102
|
|
103
|
// Set the actual uploader URL.
|
104
|
if ( FCKConfig.FlashUpload )
|
105
|
GetE('frmUpload').action = FCKConfig.FlashUploadURL ;
|
106
|
|
107
|
dialog.SetAutoSize( true ) ;
|
108
|
|
109
|
// Activate the "OK" button.
|
110
|
dialog.SetOkButton( true ) ;
|
111
|
|
112
|
if (typeof SelectField == 'function') SelectField( 'txtUrl' ) ;
|
113
|
}
|
114
|
|
115
|
function LoadSelection()
|
116
|
{
|
117
|
// parse old embeds
|
118
|
if (oEmbed)
|
119
|
{
|
120
|
oParsedFlash.file = GetAttribute( oEmbed, 'src', '' ) ;
|
121
|
oParsedFlash.width = GetAttribute( oEmbed, 'width', '' ) ;
|
122
|
oParsedFlash.height = GetAttribute( oEmbed, 'height', '' ) ;
|
123
|
|
124
|
// Get Advances Attributes
|
125
|
oParsedFlash.attributes.id = oEmbed.id ;
|
126
|
oParsedFlash.attributes.title = oEmbed.title ;
|
127
|
|
128
|
if ( oEditor.FCKBrowserInfo.IsIE )
|
129
|
{
|
130
|
oParsedFlash.attributes['class'] = oEmbed.getAttribute('className') || '' ;
|
131
|
oParsedFlash.attributes.style = oEmbed.style.cssText ;
|
132
|
}
|
133
|
else
|
134
|
{
|
135
|
oParsedFlash.attributes['class'] = oEmbed.getAttribute('class',2) || '' ;
|
136
|
oParsedFlash.attributes.style = oEmbed.getAttribute('style',2) || '' ;
|
137
|
}
|
138
|
|
139
|
oParsedFlash.params.play = GetAttribute( oEmbed, 'play', 'true' ) == 'true' ;
|
140
|
oParsedFlash.params.loop = GetAttribute( oEmbed, 'loop', 'true' ) == 'true' ;
|
141
|
oParsedFlash.params.menu = GetAttribute( oEmbed, 'menu', 'true' ) == 'true' ;
|
142
|
oParsedFlash.params.scale = GetAttribute( oEmbed, 'scale', '' ).toLowerCase() ;
|
143
|
}
|
144
|
|
145
|
GetE('txtUrl').value = oParsedFlash.file ;
|
146
|
GetE('txtWidth').value = oParsedFlash.width ;
|
147
|
GetE('txtHeight').value = oParsedFlash.height ;
|
148
|
|
149
|
// Get Advances Attributes
|
150
|
GetE('txtAttId').value = oParsedFlash.attributes.id || '' ;
|
151
|
GetE('txtAttTitle').value = oParsedFlash.attributes.title || '' ;
|
152
|
GetE('txtAttClasses').value = oParsedFlash.attributes['class'] || '' ;
|
153
|
GetE('txtAttStyle').value = oParsedFlash.attributes.style ;
|
154
|
|
155
|
GetE('chkAutoPlay').checked = oParsedFlash.params.play ;
|
156
|
GetE('chkLoop').checked = oParsedFlash.params.loop ;
|
157
|
GetE('chkMenu').checked = oParsedFlash.params.menu ;
|
158
|
GetE('cmbScale').value = oParsedFlash.params.scale || '' ;
|
159
|
|
160
|
GetE('allowscriptaccess').value = oParsedFlash.params.allowscriptaccess || '' ;
|
161
|
GetE('wmode').value = oParsedFlash.params.wmode || '' ;
|
162
|
GetE('allowfullscreen').checked = oParsedFlash.params.allowfullscreen ;
|
163
|
|
164
|
// flashvars
|
165
|
var opts = oParsedFlash.flashvars ;
|
166
|
for ( var v in opts )
|
167
|
{
|
168
|
var sText = v ;
|
169
|
var sValue = opts[v] ;
|
170
|
|
171
|
AddComboOption( oListText, sText, sText ) ;
|
172
|
AddComboOption( oListValue, sValue, sValue ) ;
|
173
|
}
|
174
|
|
175
|
UpdatePreview() ;
|
176
|
}
|
177
|
|
178
|
//#### The OK button was hit.
|
179
|
function Ok()
|
180
|
{
|
181
|
if ( GetE('txtUrl').value.length == 0 )
|
182
|
{
|
183
|
dialog.SetSelectedTab( 'Info' ) ;
|
184
|
GetE('txtUrl').focus() ;
|
185
|
|
186
|
alert( oEditor.FCKLang.DlgAlertUrl ) ;
|
187
|
|
188
|
return false ;
|
189
|
}
|
190
|
|
191
|
oEditor.FCKUndo.SaveUndoStep() ;
|
192
|
|
193
|
updateObject(oParsedFlash) ;
|
194
|
|
195
|
if ( !oFakeImage )
|
196
|
oFakeImage = oParsedFlash.createHtmlElement() ;
|
197
|
|
198
|
oParsedFlash.updateHTMLElement(oFakeImage);
|
199
|
|
200
|
return true ;
|
201
|
}
|
202
|
|
203
|
function updateObject( e )
|
204
|
{
|
205
|
e.file = GetE('txtUrl').value;
|
206
|
e.width = GetE('txtWidth').value;
|
207
|
e.height = GetE('txtHeight').value;
|
208
|
if (e.width=='') e.width = '100';
|
209
|
if (e.height=='') e.height = '100';
|
210
|
|
211
|
// Advances Attributes
|
212
|
e.attributes.id = GetE('txtAttId').value;
|
213
|
e.attributes['class'] = GetE('txtAttClasses').value;
|
214
|
e.attributes.style = GetE('txtAttStyle').value;
|
215
|
e.attributes.title = GetE('txtAttTitle').value;
|
216
|
|
217
|
e.params.scale = GetE('cmbScale').value;
|
218
|
e.params.play = GetE('chkAutoPlay').checked;
|
219
|
e.params.loop = GetE('chkLoop').checked;
|
220
|
e.params.menu = GetE('chkMenu').checked;
|
221
|
|
222
|
e.params.allowscriptaccess = GetE('allowscriptaccess').value;
|
223
|
e.params.wmode = GetE('wmode').value;
|
224
|
e.params.allowfullscreen = GetE('allowfullscreen').checked;
|
225
|
|
226
|
// Add all available options.
|
227
|
var vars = {};
|
228
|
for ( var i = 0 ; i < oListText.options.length ; i++ )
|
229
|
{
|
230
|
var sText = oListText.options[i].value ;
|
231
|
var sValue = oListValue.options[i].value ;
|
232
|
if ( sValue.length == 0 ) sValue = sText ;
|
233
|
vars[sText] = sValue ;
|
234
|
}
|
235
|
e.flashvars = vars;
|
236
|
}
|
237
|
|
238
|
var ePreview ;
|
239
|
|
240
|
function SetPreviewElement( previewEl )
|
241
|
{
|
242
|
ePreview = previewEl ;
|
243
|
|
244
|
if ( GetE('txtUrl').value.length > 0 )
|
245
|
UpdatePreview() ;
|
246
|
}
|
247
|
|
248
|
function UpdatePreview()
|
249
|
{
|
250
|
if ( !ePreview )
|
251
|
return ;
|
252
|
|
253
|
while ( ePreview.firstChild )
|
254
|
ePreview.removeChild( ePreview.firstChild ) ;
|
255
|
|
256
|
if ( GetE('txtUrl').value.length == 0 )
|
257
|
ePreview.innerHTML = ' ' ;
|
258
|
else
|
259
|
{
|
260
|
// Skip reloading the swf if it's the current preview
|
261
|
var url = GetE('txtUrl').value ;
|
262
|
if (ePreview.dataUrl == url)
|
263
|
return ;
|
264
|
|
265
|
// check if it isn't a swf file or some mix of html or an embedding page:
|
266
|
var oData = oWebVideo.ParseHtml(url, GetE('txtWidth').value, GetE('txtHeight').value );
|
267
|
GetE('txtUrl').value = oData.url ;
|
268
|
GetE('txtWidth').value = oData.width ;
|
269
|
GetE('txtHeight').value = oData.height ;
|
270
|
ePreview.dataUrl = oData.url ;
|
271
|
|
272
|
var oDoc = ePreview.ownerDocument || ePreview.document ;
|
273
|
var e = oDoc.createElement( 'EMBED' ) ;
|
274
|
|
275
|
SetAttribute( e, 'src', GetE('txtUrl').value ) ;
|
276
|
SetAttribute( e, 'type', 'application/x-shockwave-flash' ) ;
|
277
|
SetAttribute( e, 'width', '100%' ) ;
|
278
|
SetAttribute( e, 'height', '100%' ) ;
|
279
|
|
280
|
ePreview.appendChild( e ) ;
|
281
|
}
|
282
|
}
|
283
|
|
284
|
// <embed id="ePreview" src="fck_flash/claims.swf" width="100%" height="100%" style="visibility:hidden" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
|
285
|
|
286
|
function BrowseServer()
|
287
|
{
|
288
|
OpenFileBrowser( FCKConfig.FlashBrowserURL, FCKConfig.FlashBrowserWindowWidth, FCKConfig.FlashBrowserWindowHeight ) ;
|
289
|
}
|
290
|
|
291
|
function SetUrl( url, width, height )
|
292
|
{
|
293
|
GetE('txtUrl').value = url ;
|
294
|
|
295
|
if ( width )
|
296
|
GetE('txtWidth').value = width ;
|
297
|
|
298
|
if ( height )
|
299
|
GetE('txtHeight').value = height ;
|
300
|
|
301
|
UpdatePreview() ;
|
302
|
|
303
|
dialog.SetSelectedTab( 'Info' ) ;
|
304
|
}
|
305
|
|
306
|
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
|
307
|
{
|
308
|
// Remove animation
|
309
|
window.parent.Throbber.Hide() ;
|
310
|
GetE( 'divUpload' ).style.display = '' ;
|
311
|
|
312
|
switch ( errorNumber )
|
313
|
{
|
314
|
case 0 : // No errors
|
315
|
alert( 'Your file has been successfully uploaded' ) ;
|
316
|
break ;
|
317
|
case 1 : // Custom error
|
318
|
alert( customMsg ) ;
|
319
|
return ;
|
320
|
case 101 : // Custom warning
|
321
|
alert( customMsg ) ;
|
322
|
break ;
|
323
|
case 201 :
|
324
|
alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
|
325
|
break ;
|
326
|
case 202 :
|
327
|
alert( 'Invalid file type' ) ;
|
328
|
return ;
|
329
|
case 203 :
|
330
|
alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
|
331
|
return ;
|
332
|
case 500 :
|
333
|
alert( 'The connector is disabled' ) ;
|
334
|
break ;
|
335
|
default :
|
336
|
alert( 'Error on file upload. Error number: ' + errorNumber ) ;
|
337
|
return ;
|
338
|
}
|
339
|
|
340
|
SetUrl( fileUrl ) ;
|
341
|
GetE('frmUpload').reset() ;
|
342
|
}
|
343
|
|
344
|
var oUploadAllowedExtRegex = new RegExp( FCKConfig.FlashUploadAllowedExtensions, 'i' ) ;
|
345
|
var oUploadDeniedExtRegex = new RegExp( FCKConfig.FlashUploadDeniedExtensions, 'i' ) ;
|
346
|
|
347
|
function CheckUpload()
|
348
|
{
|
349
|
var sFile = GetE('txtUploadFile').value ;
|
350
|
|
351
|
if ( sFile.length == 0 )
|
352
|
{
|
353
|
alert( 'Please select a file to upload' ) ;
|
354
|
return false ;
|
355
|
}
|
356
|
|
357
|
if ( ( FCKConfig.FlashUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) ||
|
358
|
( FCKConfig.FlashUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) )
|
359
|
{
|
360
|
OnUploadCompleted( 202 ) ;
|
361
|
return false ;
|
362
|
}
|
363
|
|
364
|
// Show animation
|
365
|
window.parent.Throbber.Show( 100 ) ;
|
366
|
GetE( 'divUpload' ).style.display = 'none' ;
|
367
|
|
368
|
return true ;
|
369
|
}
|
370
|
|
371
|
|
372
|
/* flashvars selects*/
|
373
|
|
374
|
function Select( combo )
|
375
|
{
|
376
|
var iIndex = combo.selectedIndex ;
|
377
|
|
378
|
oListText.selectedIndex = iIndex ;
|
379
|
oListValue.selectedIndex = iIndex ;
|
380
|
|
381
|
var oTxtText = document.getElementById( "txtText" ) ;
|
382
|
var oTxtValue = document.getElementById( "txtValue" ) ;
|
383
|
|
384
|
oTxtText.value = oListText.value ;
|
385
|
oTxtValue.value = oListValue.value ;
|
386
|
}
|
387
|
|
388
|
function Add()
|
389
|
{
|
390
|
var oTxtText = document.getElementById( "txtText" ) ;
|
391
|
var oTxtValue = document.getElementById( "txtValue" ) ;
|
392
|
|
393
|
AddComboOption( oListText, oTxtText.value, oTxtText.value ) ;
|
394
|
AddComboOption( oListValue, oTxtValue.value, oTxtValue.value ) ;
|
395
|
|
396
|
oListText.selectedIndex = oListText.options.length - 1 ;
|
397
|
oListValue.selectedIndex = oListValue.options.length - 1 ;
|
398
|
|
399
|
oTxtText.value = '' ;
|
400
|
oTxtValue.value = '' ;
|
401
|
|
402
|
oTxtText.focus() ;
|
403
|
}
|
404
|
|
405
|
function Modify()
|
406
|
{
|
407
|
var iIndex = oListText.selectedIndex ;
|
408
|
|
409
|
if ( iIndex < 0 ) return ;
|
410
|
|
411
|
var oTxtText = document.getElementById( "txtText" ) ;
|
412
|
var oTxtValue = document.getElementById( "txtValue" ) ;
|
413
|
|
414
|
oListText.options[ iIndex ].innerHTML = HTMLEncode( oTxtText.value ) ;
|
415
|
oListText.options[ iIndex ].value = oTxtText.value ;
|
416
|
|
417
|
oListValue.options[ iIndex ].innerHTML = HTMLEncode( oTxtValue.value ) ;
|
418
|
oListValue.options[ iIndex ].value = oTxtValue.value ;
|
419
|
|
420
|
oTxtText.value = '' ;
|
421
|
oTxtValue.value = '' ;
|
422
|
|
423
|
oTxtText.focus() ;
|
424
|
}
|
425
|
|
426
|
function Delete()
|
427
|
{
|
428
|
RemoveSelectedOptions( oListText ) ;
|
429
|
RemoveSelectedOptions( oListValue ) ;
|
430
|
}
|
431
|
|
432
|
// Remove all selected options from a SELECT object
|
433
|
function RemoveSelectedOptions(combo)
|
434
|
{
|
435
|
// Save the selected index
|
436
|
var iSelectedIndex = combo.selectedIndex ;
|
437
|
|
438
|
var oOptions = combo.options ;
|
439
|
|
440
|
// Remove all selected options
|
441
|
for ( var i = oOptions.length - 1 ; i >= 0 ; i-- )
|
442
|
{
|
443
|
if (oOptions[i].selected) combo.remove(i) ;
|
444
|
}
|
445
|
|
446
|
// Reset the selection based on the original selected index
|
447
|
if ( combo.options.length > 0 )
|
448
|
{
|
449
|
if ( iSelectedIndex >= combo.options.length ) iSelectedIndex = combo.options.length - 1 ;
|
450
|
combo.selectedIndex = iSelectedIndex ;
|
451
|
}
|
452
|
}
|
453
|
|
454
|
// Add a new option to a SELECT object (combo or list)
|
455
|
function AddComboOption( combo, optionText, optionValue, documentObject, index )
|
456
|
{
|
457
|
var oOption ;
|
458
|
|
459
|
if ( documentObject )
|
460
|
oOption = documentObject.createElement("OPTION") ;
|
461
|
else
|
462
|
oOption = document.createElement("OPTION") ;
|
463
|
|
464
|
if ( index != null )
|
465
|
combo.options.add( oOption, index ) ;
|
466
|
else
|
467
|
combo.options.add( oOption ) ;
|
468
|
|
469
|
oOption.innerHTML = optionText.length > 0 ? HTMLEncode( optionText ) : ' ' ;
|
470
|
oOption.value = optionValue ;
|
471
|
|
472
|
return oOption ;
|
473
|
}
|
474
|
|
475
|
function HTMLEncode( text )
|
476
|
{
|
477
|
if ( !text )
|
478
|
return '' ;
|
479
|
|
480
|
text = text.replace( /&/g, '&' ) ;
|
481
|
text = text.replace( /</g, '<' ) ;
|
482
|
text = text.replace( />/g, '>' ) ;
|
483
|
|
484
|
return text ;
|
485
|
}
|
486
|
|
487
|
|
488
|
function HTMLDecode( text )
|
489
|
{
|
490
|
if ( !text )
|
491
|
return '' ;
|
492
|
|
493
|
text = text.replace( />/g, '>' ) ;
|
494
|
text = text.replace( /</g, '<' ) ;
|
495
|
text = text.replace( /&/g, '&' ) ;
|
496
|
|
497
|
return text ;
|
498
|
}
|
499
|
|
500
|
|
501
|
|
502
|
|
503
|
// The object used for all Web Video operations.
|
504
|
var oWebVideo = {
|
505
|
Objects : [ "<object width=\"(?<width>\\d+)\" height=\"(?<height>\\d+)\".* name=\"movie\"\\s+value=\"(?<url>[^\"]*)\".*<\\/object>" ,
|
506
|
// youtube style only embed
|
507
|
"<embed src=\"(?<url>[^\"]*)\".* width=\"(?<width>\\d+)\" height=\"(?<height>\\d+)\".*<\\/embed>" ,
|
508
|
// google video
|
509
|
"<embed .*width:(?<width>\\d+)px.*height:(?<height>\\d+)px.* src=\"(?<url>[^\"]*)\".*<\\/embed>" ,
|
510
|
// invalid syntax but anyway...
|
511
|
"<embed src=\"(?<url>[^\"]*)\".* width=\"(?<width>\\d+)px\" height=\"(?<height>\\d+)px\".*<\\/embed>"
|
512
|
] ,
|
513
|
|
514
|
webPages : [{re:/http:\/\/www\.youtube\.com\/watch\?v=([^&]*)(&.*|$)/, url:'http://www.youtube.com/v/$1', width:425, height:344} ,
|
515
|
{re:/http:\/\/video\.google\.(.*)\/videoplay\?docid=([^&]*)(&.*|$)/, url:'http://video.google.$1/googleplayer.swf?docid=$2', width:400, height:326},
|
516
|
{re:/http:\/\/www\.mtvmusic\.com\/video\/\?id=([^&]*)(&.*|$)/, url:'http://media.mtvnservices.com/mgid:uma:video:mtvmusic.com:$1', width:320, height:271} ,
|
517
|
{re:/http:\/\/www\.metacafe\.com\/watch\/(.*?)\/(.*?)(\/.*|$)/, url:'http://www.metacafe.com/fplayer/$1/$2.swf', width:400, height:345}
|
518
|
],
|
519
|
|
520
|
// Parses the suplied HTML and returns an object with the url of the video, its width and height
|
521
|
ParseHtml : function( html, width, height )
|
522
|
{
|
523
|
// Check if it's a valid swf and skip the tests
|
524
|
var swfFile = new RegExp(".*\.swf$", i) ;
|
525
|
if ( swfFile.test(html) )
|
526
|
return {url: html, width: width, height: height } ;
|
527
|
|
528
|
// Generic system to work with any proposed embed by the site (as long as it matches the previous regexps
|
529
|
for(var i=0; i< this.Objects.length; i++)
|
530
|
{
|
531
|
// Using XRegExp to work with named captures: http://stevenlevithan.com/regex/xregexp/
|
532
|
var re = new XRegExp( this.Objects[i] ) ;
|
533
|
var parts = re.exec( html ) ;
|
534
|
if (parts)
|
535
|
return {url: parts.url, width: parts.width, height: parts.height };
|
536
|
}
|
537
|
|
538
|
// Ability to paste the url of the web site and extract the correct info. It needs to be adjusted for every site.
|
539
|
for(var i=0; i< this.webPages.length; i++)
|
540
|
{
|
541
|
var page = this.webPages[i] ;
|
542
|
var oMatch = html.match( page.re ) ;
|
543
|
if (oMatch)
|
544
|
{
|
545
|
return {url: html.replace(page.re, page.url), width: page.width, height: page.height};
|
546
|
}
|
547
|
}
|
548
|
|
549
|
return {url: html, width: width, height: height } ;
|
550
|
}
|
551
|
};
|
552
|
|
553
|
|
554
|
|
555
|
|
556
|
|
557
|
// XRegExp 0.5.1, <stevenlevithan.com>, MIT License
|
558
|
if(!window.XRegExp){(function(){var D={exec:RegExp.prototype.exec,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split},C={part:/(?:[^\\([#\s.]+|\\(?!k<[\w$]+>)[\S\s]?|\((?=\?(?!#|<[\w$]+>)))+|(\()(?:\?(?:(#)[^)]*\)|<([$\w]+)>))?|\\k<([\w$]+)>|(\[\^?)|([\S\s])/g,replaceVar:/(?:[^$]+|\$(?![1-9$&`']|{[$\w]+}))+|\$(?:([1-9]\d*|[$&`'])|{([$\w]+)})/g,extended:/^(?:\s+|#.*)+/,quantifier:/^(?:[?*+]|{\d+(?:,\d*)?})/,classLeft:/&&\[\^?/g,classRight:/]/g},A=function(H,F,G){for(var E=G||0;E<H.length;E++){if(H[E]===F){return E}}return -1},B=/()??/.exec("")[1]!==undefined;XRegExp=function(N,H){if(N instanceof RegExp){if(H!==undefined){throw TypeError("can't supply flags when constructing one RegExp from another")}return N.addFlags()}var H=H||"",E=H.indexOf("s")>-1,J=H.indexOf("x")>-1,O=false,Q=[],G=[],F=C.part,K,I,M,L,P;F.lastIndex=0;while(K=D.exec.call(F,N)){if(K[2]){if(!C.quantifier.test(N.slice(F.lastIndex))){G.push("(?:)")}}else{if(K[1]){Q.push(K[3]||null);if(K[3]){O=true}G.push("(")}else{if(K[4]){L=A(Q,K[4]);G.push(L>-1?"\\"+(L+1)+(isNaN(N.charAt(F.lastIndex))?"":"(?:)"):K[0])}else{if(K[5]){if(N.charAt(F.lastIndex)==="]"){G.push(K[5]==="["?"(?!)":"[\\S\\s]");F.lastIndex++}else{I=XRegExp.matchRecursive("&&"+N.slice(K.index),C.classLeft,C.classRight,"",{escapeChar:"\\"})[0];G.push(K[5]+I+"]");F.lastIndex+=I.length+1}}else{if(K[6]){if(E&&K[6]==="."){G.push("[\\S\\s]")}else{if(J&&C.extended.test(K[6])){M=D.exec.call(C.extended,N.slice(F.lastIndex-1))[0].length;if(!C.quantifier.test(N.slice(F.lastIndex-1+M))){G.push("(?:)")}F.lastIndex+=M-1}else{G.push(K[6])}}}else{G.push(K[0])}}}}}}P=RegExp(G.join(""),D.replace.call(H,/[sx]+/g,""));P._x={source:N,captureNames:O?Q:null};return P};RegExp.prototype.exec=function(I){var G=D.exec.call(this,I),F,H,E;if(G){if(B&&G.length>1){E=new RegExp("^"+this.source+"$(?!\\s)",this.getNativeFlags());D.replace.call(G[0],E,function(){for(H=1;H<arguments.length-2;H++){if(arguments[H]===undefined){G[H]=undefined}}})}if(this._x&&this._x.captureNames){for(H=1;H<G.length;H++){F=this._x.captureNames[H-1];if(F){G[F]=G[H]}}}if(this.global&&this.lastIndex>(G.index+G[0].length)){this.lastIndex--}}return G};String.prototype.match=function(E){if(!(E instanceof RegExp)){E=new XRegExp(E)}if(E.global){return D.match.call(this,E)}return E.exec(this)};String.prototype.replace=function(F,G){var E=(F._x||{}).captureNames;if(!(F instanceof RegExp&&E)){return D.replace.apply(this,arguments)}if(typeof G==="function"){return D.replace.call(this,F,function(){arguments[0]=new String(arguments[0]);for(var H=0;H<E.length;H++){if(E[H]){arguments[0][E[H]]=arguments[H+1]}}return G.apply(window,arguments)})}else{return D.replace.call(this,F,function(){var H=arguments;return D.replace.call(G,C.replaceVar,function(J,I,M){if(I){switch(I){case"$":return"$";case"&":return H[0];case"`":return H[H.length-1].slice(0,H[H.length-2]);case"'":return H[H.length-1].slice(H[H.length-2]+H[0].length);default:var K="";I=+I;while(I>E.length){K=D.split.call(I,"").pop()+K;I=Math.floor(I/10)}return(I?H[I]:"$")+K}}else{if(M){var L=A(E,M);return L>-1?H[L+1]:J}else{return J}}})})}};String.prototype.split=function(J,F){if(!(J instanceof RegExp)){return D.split.apply(this,arguments)}var G=[],E=J.lastIndex,K=0,I=0,H;if(F===undefined||+F<0){F=false}else{F=Math.floor(+F);if(!F){return[]}}if(!J.global){J=J.addFlags("g")}else{J.lastIndex=0}while((!F||I++<=F)&&(H=J.exec(this))){if(J.lastIndex>K){G=G.concat(this.slice(K,H.index),(H.index===this.length?[]:H.slice(1)));K=J.lastIndex}if(!H[0].length){J.lastIndex++}}G=K===this.length?(J.test("")?G:G.concat("")):(F?G:G.concat(this.slice(K)));J.lastIndex=E;return G}})()}RegExp.prototype.getNativeFlags=function(){return(this.global?"g":"")+(this.ignoreCase?"i":"")+(this.multiline?"m":"")+(this.extended?"x":"")+(this.sticky?"y":"")};RegExp.prototype.addFlags=function(A){var B=new XRegExp(this.source,(A||"")+this.getNativeFlags());if(this._x){B._x={source:this._x.source,captureNames:this._x.captureNames?this._x.captureNames.slice(0):null}}return B};RegExp.prototype.call=function(A,B){return this.exec(B)};RegExp.prototype.apply=function(B,A){return this.exec(A[0])};XRegExp.cache=function(C,A){var B="/"+C+"/"+(A||"");return XRegExp.cache[B]||(XRegExp.cache[B]=new XRegExp(C,A))};XRegExp.escape=function(A){return A.replace(/[-[\]{}()*+?.\\^$|,#\s]/g,"\\$&")};XRegExp.matchRecursive=function(P,D,S,F,B){var B=B||{},V=B.escapeChar,K=B.valueNames,F=F||"",Q=F.indexOf("g")>-1,C=F.indexOf("i")>-1,H=F.indexOf("m")>-1,U=F.indexOf("y")>-1,F=F.replace(/y/g,""),D=D instanceof RegExp?(D.global?D:D.addFlags("g")):new XRegExp(D,"g"+F),S=S instanceof RegExp?(S.global?S:S.addFlags("g")):new XRegExp(S,"g"+F),I=[],A=0,J=0,N=0,L=0,M,E,O,R,G,T;if(V){if(V.length>1){throw SyntaxError("can't supply more than one escape character")}if(H){throw TypeError("can't supply escape character when using the multiline flag")}G=XRegExp.escape(V);T=new RegExp("^(?:"+G+"[\\S\\s]|(?:(?!"+D.source+"|"+S.source+")[^"+G+"])+)+",C?"i":"")}while(true){D.lastIndex=S.lastIndex=N+(V?(T.exec(P.slice(N))||[""])[0].length:0);O=D.exec(P);R=S.exec(P);if(O&&R){if(O.index<=R.index){R=null}else{O=null}}if(O||R){J=(O||R).index;N=(O?D:S).lastIndex}else{if(!A){break}}if(U&&!A&&J>L){break}if(O){if(!A++){M=J;E=N}}else{if(R&&A){if(!--A){if(K){if(K[0]&&M>L){I.push([K[0],P.slice(L,M),L,M])}if(K[1]){I.push([K[1],P.slice(M,E),M,E])}if(K[2]){I.push([K[2],P.slice(E,J),E,J])}if(K[3]){I.push([K[3],P.slice(J,N),J,N])}L=N}else{I.push(P.slice(E,J))}if(!Q){break}}}else{D.lastIndex=S.lastIndex=0;throw Error("subject data contains unbalanced delimiters")}}if(J===N){N++}}if(Q&&!U&&K&&K[0]&&P.length>L){I.push([K[0],P.slice(L),L,P.length])}D.lastIndex=S.lastIndex=0;return I};
|