[svn r21752] FS#2867 - The FCKEditor, the youtube plugin: Minor changes, code cosmetics.

skala
Ivan Tcholakov 17 years ago
parent 52522153e1
commit 542a6d8d6c
  1. 104
      main/inc/lib/fckeditor/editor/plugins/youtube/youtube.js

@ -7,15 +7,15 @@ var FCKLang = oEditor.FCKLang ;
var FCKConfig = oEditor.FCKConfig ;
var FCKTools = oEditor.FCKTools ;
//security RegExp
var REG_SCRIPT = new RegExp("< *script.*>|< *style.*>|< *link.*>|< *body .*>", "i");
var REG_PROTOCOL = new RegExp("javascript:|vbscript:|about:", "i");
var REG_CALL_SCRIPT = new RegExp("&\{.*\};", "i");
var REG_EVENT = new RegExp("onError|onUnload|onBlur|onFocus|onClick|onMouseOver|onMouseOut|onSubmit|onReset|onChange|onSelect|onAbort", "i");
// Security RegExp
var REG_SCRIPT = new RegExp( "< *script.*>|< *style.*>|< *link.*>|< *body .*>", "i" ) ;
var REG_PROTOCOL = new RegExp( "javascript:|vbscript:|about:", "i" ) ;
var REG_CALL_SCRIPT = new RegExp( "&\{.*\};", "i" ) ;
var REG_EVENT = new RegExp( "onError|onUnload|onBlur|onFocus|onClick|onMouseOver|onMouseOut|onSubmit|onReset|onChange|onSelect|onAbort", "i" ) ;
// Cookie Basic
var REG_AUTH = new RegExp("document\.cookie|Microsoft\.XMLHTTP", "i");
var REG_AUTH = new RegExp( "document\.cookie|Microsoft\.XMLHTTP", "i" ) ;
// TEXTAREA
var REG_NEWLINE = new RegExp("\x0d|\x0a", "i");
var REG_NEWLINE = new RegExp( "\x0d|\x0a", "i" ) ;
var YoutubeSite = 'http://www.youtube.com/v/' ;
var HighQualityString = '%26hl=en%26fs=1%26rel=0%26ap=%2526fmt=18' ;
@ -56,7 +56,7 @@ var oEmbed ;
if ( oFakeImage )
{
if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckvideo') )
if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute( '_fckvideo' ) )
oEmbed = FCK.GetRealElement( oFakeImage ) ;
else
oFakeImage = null ;
@ -84,57 +84,58 @@ function LoadSelection()
var src = GetAttribute( oEmbed, 'src', '' ) ;
GetE('txtUrl').value = GetOriginalYoutubeUrl ( src ) ;
GetE( 'txtUrl' ).value = GetOriginalYoutubeUrl ( src ) ;
if ( GetQuality ( src ) == 'high' )
{
GetE('radioHigh').checked = true ;
GetE('radioLow').checked = false ;
GetE( 'radioHigh' ).checked = true ;
GetE( 'radioLow' ).checked = false ;
}
else
{
GetE('radioHigh').checked = false ;
GetE('radioLow').checked = true ;
GetE( 'radioHigh' ).checked = false ;
GetE( 'radioLow' ).checked = true ;
}
GetE('txtWidth').value = GetAttribute( oEmbed, 'width', 425 ) ;
GetE('txtHeight').value = GetAttribute( oEmbed, 'height', 344 ) ;
GetE( 'txtWidth' ).value = GetAttribute( oEmbed, 'width', 425 ) ;
GetE( 'txtHeight' ).value = GetAttribute( oEmbed, 'height', 344 ) ;
}
//#### The OK button was hit.
function Ok()
{
GetE('txtUrl').value = GetE('txtUrl').value.Trim() ;
GetE( 'txtUrl' ).value = GetE( 'txtUrl' ).value.Trim() ;
if ( GetE('txtUrl').value.length == 0 )
{
dialog.SetSelectedTab( 'Info' ) ;
GetE('txtUrl').focus() ;
GetE( 'txtUrl' ).focus() ;
alert( oEditor.FCKLang.DlgYouTubeCode ) ;
return false ;
}
// check security
if (checkCode(GetE('txtUrl').value) == false) {
// Check security
if ( checkCode( GetE( 'txtUrl' ).value ) == false )
{
alert( oEditor.FCKLang.DlgYouTubeSecurity ) ;
return false;
return false ;
}
oEditor.FCKUndo.SaveUndoStep() ;
if ( !oEmbed )
{
oEmbed = FCK.EditorDocument.createElement( 'EMBED' ) ;
oFakeImage = null ;
oEmbed = FCK.EditorDocument.createElement( 'EMBED' ) ;
oFakeImage = null ;
}
UpdateEmbed( oEmbed ) ;
if ( !oFakeImage )
{
oFakeImage = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Video', oEmbed ) ;
oFakeImage = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Video', oEmbed ) ;
oFakeImage.setAttribute( '_fckvideo', 'true', 0 ) ;
oFakeImage = FCK.InsertElement( oFakeImage ) ;
oFakeImage = FCK.InsertElement( oFakeImage ) ;
}
oEditor.FCKEmbedAndObjectProcessor.RefreshView( oFakeImage, oEmbed ) ;
@ -144,46 +145,55 @@ function Ok()
function UpdateEmbed( e )
{
var YoutubeUrl = GetE('txtUrl').value;
var YoutubeUrl = GetE( 'txtUrl' ).value ;
var YoutubeId = GetYoutubeId( YoutubeUrl ) ;
SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;
SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ;
SetAttribute( e, 'allowfullscreen' , 'true' ) ;
if ( GetE('radioHigh').checked ) {
SetAttribute( e, 'src' , YoutubeSite + YoutubeId + HighQualityString ) ;
} else {
SetAttribute( e, 'src' , YoutubeSite + YoutubeId + LowQualityString ) ;
SetAttribute( e, 'type', 'application/x-shockwave-flash' ) ;
SetAttribute( e, 'pluginspage', 'http://www.macromedia.com/go/getflashplayer' ) ;
SetAttribute( e, 'allowfullscreen', 'true' ) ;
if ( GetE( 'radioHigh' ).checked )
{
SetAttribute( e, 'src', YoutubeSite + YoutubeId + HighQualityString ) ;
}
else
{
SetAttribute( e, 'src', YoutubeSite + YoutubeId + LowQualityString ) ;
}
SetAttribute( e, "width" , GetE('txtWidth').value == '' ? 425 : GetE('txtWidth').value ) ;
SetAttribute( e, "height" , GetE('txtHeight').value == '' ? 344 : GetE('txtHeight').value ) ;
SetAttribute( e, 'width' , GetE( 'txtWidth' ).value == '' ? 425 : GetE( 'txtWidth' ).value ) ;
SetAttribute( e, 'height', GetE( 'txtHeight' ).value == '' ? 344 : GetE( 'txtHeight' ).value ) ;
}
function checkCode(code)
function checkCode( code )
{
if (code.search(REG_SCRIPT) != -1) {
return false;
if ( code.search( REG_SCRIPT ) != -1 )
{
return false ;
}
if (code.search(REG_PROTOCOL) != -1) {
return false;
if ( code.search( REG_PROTOCOL ) != -1 )
{
return false ;
}
if (code.search(REG_CALL_SCRIPT) != -1) {
return false;
if ( code.search( REG_CALL_SCRIPT ) != -1 )
{
return false ;
}
if (code.search(REG_EVENT) != -1) {
return false;
if ( code.search( REG_EVENT ) != -1 )
{
return false ;
}
if (code.search(REG_AUTH) != -1) {
return false;
if ( code.search( REG_AUTH ) != -1 )
{
return false ;
}
if (code.search(REG_NEWLINE) != -1) {
return false;
if ( code.search( REG_NEWLINE ) != -1 )
{
return false ;
}
}

Loading…
Cancel
Save