1 var dialog = window.parent ;
2 var oEditor = dialog.InnerDialogLoaded() ;
3 var FCK = oEditor.FCK ;
4 var FCKLang = oEditor.FCKLang ;
5 var FCKConfig = oEditor.FCKConfig ;
8 var REG_SCRIPT = new RegExp("< *script.*>|< *style.*>|< *link.*>|< *body .*>", "i");
9 var REG_PROTOCOL = new RegExp("javascript:|vbscript:|about:", "i");
10 var REG_CALL_SCRIPT = new RegExp("&\{.*\};", "i");
11 var REG_EVENT = new RegExp("onError|onUnload|onBlur|onFocus|onClick|onMouseOver|onMouseOut|onSubmit|onReset|onChange|onSelect|onAbort", "i");
13 var REG_AUTH = new RegExp("document\.cookie|Microsoft\.XMLHTTP", "i");
15 var REG_NEWLINE = new RegExp("\x0d|\x0a", "i");
19 // Set the dialog tabs.
20 dialog.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ;
22 // Get the selected flash embed (if available).
23 var oFakeImage = FCK.Selection.GetSelectedElement() ;
26 window.onload = function()
28 // Translate the dialog box texts.
29 oEditor.FCKLanguageManager.TranslatePage(document) ;
31 dialog.SetAutoSize( true ) ;
33 // Activate the "OK" button.
34 dialog.SetOkButton( true ) ;
36 SelectField( 'txtUrl' ) ;
39 //#### The OK button was hit.
42 if ( GetE('txtUrl').value.length == 0 )
44 dialog.SetSelectedTab( 'Info' ) ;
45 GetE('txtUrl').focus() ;
47 alert( oEditor.FCKLang.DlgYouTubeCode ) ;
53 if (checkCode(GetE('txtUrl').value) == false) {
54 alert( oEditor.FCKLang.DlgYouTubeSecurity ) ;
58 oEditor.FCKUndo.SaveUndoStep() ;
61 oEmbed = FCK.EditorDocument.createElement( 'EMBED' ) ;
64 UpdateEmbed( oEmbed ) ;
68 oFakeImage = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oEmbed ) ;
69 oFakeImage.setAttribute( '_fckflash', 'true', 0 ) ;
70 oFakeImage = FCK.InsertElement( oFakeImage ) ;
73 oEditor.FCKEmbedAndObjectProcessor.RefreshView( oFakeImage, oEmbed ) ;
78 function UpdateEmbed( e )
80 var youtubeUrl = GetE('txtUrl').value;
81 var youtubeId = youtubeUrl.slice(youtubeUrl.search(/\?v=/i)+3);
83 SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;
84 SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ;
86 if ( GetE('radioHigh').checked ) {
87 SetAttribute( e, 'src' , 'http://www.youtube.com/v/'+youtubeId+'%26hl=en%26fs=1%26rel=0%26ap=%2526fmt=18') ;
89 SetAttribute( e, 'src' , 'http://www.youtube.com/v/'+youtubeId+'%26hl=en%26fs=1%26rel=0') ;
92 SetAttribute( e, "width" , GetE('txtWidth').value == '' ? 425 : GetE('txtWidth').value ) ;
93 SetAttribute( e, "height" , GetE('txtHeight').value == '' ? 344 : GetE('txtHeight').value ) ;
96 function checkCode(code)
98 if (code.search(REG_SCRIPT) != -1) {
102 if (code.search(REG_PROTOCOL) != -1) {
106 if (code.search(REG_CALL_SCRIPT) != -1) {
110 if (code.search(REG_EVENT) != -1) {
114 if (code.search(REG_AUTH) != -1) {
118 if (code.search(REG_NEWLINE) != -1) {