[pLog-svn] r4082 - plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo

oscar at devel.lifetype.net oscar at devel.lifetype.net
Wed Oct 4 13:56:39 GMT 2006


Author: oscar
Date: 2006-10-04 13:56:38 +0000 (Wed, 04 Oct 2006)
New Revision: 4082

Modified:
   plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/editor_plugin.js
   plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/functions.js
   plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/videoinput.html
Log:
finally the plugin is working with IE, but I didn't know that IE had some Javascript reserved words ('class'?, 'content'?) It took me a while to figure it out!


Modified: plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/editor_plugin.js
===================================================================
--- plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/editor_plugin.js	2006-10-03 23:09:08 UTC (rev 4081)
+++ plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/editor_plugin.js	2006-10-04 13:56:38 UTC (rev 4082)
@@ -67,7 +67,8 @@
 				if (tinyMCE.getParam('convert_urls')) {
 					var imgs = content.getElementsByTagName("img");
 					for (var i=0; i<imgs.length; i++) {
-						if (tinyMCE.getAttrib(imgs[i], "class") == "ltVideoYouTube") {
+						//if (tinyMCE.getAttrib(imgs[i], "class")== "ltVideoYouTube") {
+						if (tinyMCE.getAttrib(imgs[i], "class").substr(0,6) == "ltVideo") {							
 							var src = tinyMCE.getAttrib(imgs[i], "alt");
 
 							if (tinyMCE.getParam('convert_urls'))
@@ -83,7 +84,7 @@
 			case "get_from_editor_dom":
 				var imgs = content.getElementsByTagName("img");
 				for (var i=0; i<imgs.length; i++) {
-					if (tinyMCE.getAttrib(imgs[i], "class") == "ltVideoYouTube") {
+					if (tinyMCE.getAttrib(imgs[i], "class").substr(0,6) == "ltVideo") {
 						var src = tinyMCE.getAttrib(imgs[i], "alt");
 
 						if (tinyMCE.getParam('convert_urls'))
@@ -106,7 +107,7 @@
 				// Parse all embed tags
 				while ((startPos = content.indexOf('<embed', startPos+1)) != -1) {
 					var endPos = content.indexOf('>', startPos);
-					var attribs = TinyMCE_FlashPlugin._parseAttributes(content.substring(startPos + 6, endPos));
+					var attribs = TinyMCE_insertvideoPlugin._parseAttributes(content.substring(startPos + 6, endPos));
 					embedList[embedList.length] = attribs;
 				}
 
@@ -127,7 +128,7 @@
 					content = content.substring(0, startPos);
 					content += '<img width="' + attribs["width"] + '" height="' + attribs["height"] + '"';
 					content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["src"] + '"';
-					content += ' alt="' + attribs["src"] + '" class="ltVideoYouTube" />' + content.substring(endPos);
+					content += ' alt="' + attribs["src"] + '" class="'+attribs["class"]+'" />' + content.substring(endPos);
 					content += contentAfter;
 					index++;
 
@@ -151,7 +152,7 @@
 					content = content.substring(0, startPos);
 					content += '<img width="' + attribs["width"] + '" height="' + attribs["height"] + '"';
 					content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["src"] + '"';
-					content += ' alt="' + attribs["src"] + '" class="ltVideoYouTube" />' + content.substring(endPos);
+					content += ' alt="' + attribs["src"] + '" class="'+attribs["class"]+'" />' + content.substring(endPos);
 					content += contentAfter;
 					index++;
 
@@ -166,7 +167,7 @@
 
 				while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
 					var endPos = content.indexOf('/>', startPos);
-					var attribs = TinyMCE_FlashPlugin._parseAttributes(content.substring(startPos + 4, endPos));
+					var attribs = TinyMCE_insertvideoPlugin._parseAttributes(content.substring(startPos + 4, endPos));
 
 					// Is not flash, skip it
 					if (attribs['class'] != "ltVideoYouTube" && attribs['class'] != "ltVideoGoogleVideo")
@@ -200,7 +201,7 @@
 			return;
 
 		do {
-			if (node.nodeName == "IMG" && tinyMCE.getAttrib(node, 'class').indexOf('ltVideoYouTube') == 0) {
+			if (node.nodeName == "IMG" && tinyMCE.getAttrib(node, 'class').indexOf('ltVideo') == 0) {
 				tinyMCE.switchClass(editor_id + '_flash', 'mceButtonSelected');
 				return true;
 			}
@@ -261,18 +262,18 @@
 
 function getVideoFlashHTML( url, width, height )
 {
-content = "<object type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\" data=\""+url+"\">"+
-	"<param name=\"movie\" value=\""+url+"\" />"+
-	"<param name=\"wmode\" value=\"transparent\" />"+
-	"<param name=\"allowScriptAcess\" value=\"sameDomain\" />"+
-	"<param name=\"quality\" value=\"best\" />"+
-	"<param name=\"bgcolor\" value=\"#FFFFFF\" />"+
-	"<param name=\"scale\" value=\"noScale\" />"+
-	"<param name=\"salign\" value=\"TL\" />"+
-	"<param name=\"FlashVars\" value=\"playerMode=embedded\" />"+
-"</object>";
-
-return( content );
+	html = "<object type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\" data=\""+url+"\">"+
+		"<param name=\"movie\" value=\""+url+"\" />"+
+		"<param name=\"wmode\" value=\"transparent\" />"+
+		"<param name=\"allowScriptAcess\" value=\"sameDomain\" />"+
+		"<param name=\"quality\" value=\"best\" />"+
+		"<param name=\"bgcolor\" value=\"#FFFFFF\" />"+
+		"<param name=\"scale\" value=\"noScale\" />"+
+		"<param name=\"salign\" value=\"TL\" />"+
+		"<param name=\"FlashVars\" value=\"playerMode=embedded\" />"+
+	"</object>";
+	
+	return( html );
 }
 
 tinyMCE.addPlugin("insertvideo", TinyMCE_insertvideoPlugin );
\ No newline at end of file

Modified: plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/functions.js
===================================================================
--- plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/functions.js	2006-10-03 23:09:08 UTC (rev 4081)
+++ plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/functions.js	2006-10-04 13:56:38 UTC (rev 4082)
@@ -9,11 +9,20 @@
 }
 
 function getYouTubeLink( url ) 
-{
+{	
 	// check if this is a URL pointing to a youtube link or to a youtube video
 	if( url.substring( 0, 31 ) == "http://www.youtube.com/watch?v=" ) {
-		// and if it's a link to a normal youtube page, build the right link to the video player
-		videoId = url.substring( 31, url.length );
+		// and if it's a link to a normal youtube page, build the right link to the video player	
+		var regexp = /http:\/\/www.youtube.com\/.*?v=([\-0-9a-zA-z]*).*/i;
+		result = regexp.exec( url );
+		if( result ) {
+			videoId = result[1];
+		}
+		else {
+			// let's try to make a best guess...
+			videoId = url.substring( 31, url.length );
+		}
+		
 		url = "http://www.youtube.com/v/" + videoId;
 	}
 	return( url );
@@ -24,15 +33,26 @@
 	// check if it's a link to a video page or a link to the video player
 	if( url.substring( 0, 40 ) == "http://video.google.com/videoplay?docid=" ) {
 		// if it's a link to a video page, generate the right one
-		videoId = url.substring( 40, url.length );
+		var regexp = /http:\/\/video.google.com\/.*?docid=([\-0-9a-zA-z]*).*/i;
+		result = regexp.exec( url );
+		if( result ) {
+			videoId = result[1];
+		}
+		else {		
+			videoId = url.substring( 40, url.length );
+		}
+		window.alert(videoId);
+		
 		url = "http://video.google.com/googleplayer.swf?docId=" + videoId;
 	}
+	
+	return( url );
 }
 
 function insertVideoCode()
 {
 	// get and check the URL
-	urlField = document.getElementById( "url" );
+	urlField = document.forms[0].url;
 	url = urlField.value;
 	if( url == "" || !isValidUrl( url )) {
 		window.alert( "The URL is not valid" );
@@ -49,30 +69,28 @@
 	
 	if( youtube.checked == true ) {
 		link = getYouTubeLink( url );
-		class="ltVideoYouTube";
+		css="ltVideoYouTube";
 		width=425;
 		height=350;
 	}
 	else {
 		link = getGoogleVideoLink( url );	
-		class="ltVideoGoogleVideo";
+		css="ltVideoGoogleVideo";
 		width=400;
 		height=326;		
 	}
 
-	insertFlash( link, class, width, height );
+	insertFlash( link, css, width, height );
 }
 
-function insertFlash( url, class, width, height ) {
+function insertFlash( file, css, width, height ) {
 
 	var html      = '';
-	var file      = url;
 
-
 	html += ''
 		+ '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" mce_src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
 		+ 'width="' + width + '" height="' + height + '" '
-		+ 'border="0" alt="' + file + '" title="' + file + '" class="'+class+'" />';
+		+ 'border="0" alt="' + file + '" title="' + file + '" class="'+css+'" />';
 		
 	window.alert(html);
 

Modified: plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/videoinput.html
===================================================================
--- plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/videoinput.html	2006-10-03 23:09:08 UTC (rev 4081)
+++ plog/branches/lifetype-1.1.1/js/tinymce/plugins/insertvideo/videoinput.html	2006-10-04 13:56:38 UTC (rev 4082)
@@ -7,6 +7,7 @@
 </head>
 <body style="display: none">
 	<div align="left">
+	<form name="video" id="video" method="post">
 		<div class="title">Insert Video<br /><br />
 		</div>
 		Video URL:<br/>
@@ -19,6 +20,7 @@
 		<div class="mceActionPanel">		
 			<input type="button" name="insert" value="Insert Code" onClick="insertVideoCode()" />
 		</div>
+	 </form>
 	</div>
 </body>
 </html>



More information about the pLog-svn mailing list