[pLog-svn] r4186 - plog/branches/lifetype-1.1.2/js/tinymce/plugins/insertvideo

oscar at devel.lifetype.net oscar at devel.lifetype.net
Wed Oct 25 11:15:48 GMT 2006


Author: oscar
Date: 2006-10-25 11:15:47 +0000 (Wed, 25 Oct 2006)
New Revision: 4186

Modified:
   plog/branches/lifetype-1.1.2/js/tinymce/plugins/insertvideo/editor_plugin.js
Log:
potential fix for issue http://bugs.lifetype.net/view.php?id=1098, but it probably needs more testing.


Modified: plog/branches/lifetype-1.1.2/js/tinymce/plugins/insertvideo/editor_plugin.js
===================================================================
--- plog/branches/lifetype-1.1.2/js/tinymce/plugins/insertvideo/editor_plugin.js	2006-10-25 07:34:35 UTC (rev 4185)
+++ plog/branches/lifetype-1.1.2/js/tinymce/plugins/insertvideo/editor_plugin.js	2006-10-25 11:15:47 UTC (rev 4186)
@@ -63,6 +63,7 @@
 	cleanup : function(type, content) {
 		switch (type) {
 			case "insert_to_editor_dom":
+			
 				// Force relative/absolute
 				if (tinyMCE.getParam('convert_urls')) {
 					var imgs = content.getElementsByTagName("img");
@@ -79,6 +80,7 @@
 						}
 					}
 				}
+				
 				break;
 
 			case "get_from_editor_dom":
@@ -98,37 +100,36 @@
 
 			case "insert_to_editor":
 				var startPos = 0;
-				var embedList = new Array();
+				var embedList = new Array();			
 
 				// Fix the embed and object elements
 				content = content.replace(new RegExp('<[ ]*object','gi'),'<object');
-				content = content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');
-
-				// Parse all embed tags
-				while ((startPos = content.indexOf('<embed', startPos+1)) != -1) {
-					var endPos = content.indexOf('>', startPos);
-					var attribs = TinyMCE_insertvideoPlugin._parseAttributes(content.substring(startPos + 6, endPos));
-					embedList[embedList.length] = attribs;
-				}
-
+				content = content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');			
+				
 				// Parse all object tags and replace them with images from the embed data
 				var index = 0;
 				while ((startPos = content.indexOf('<object', startPos)) != -1) {
-					if (index >= embedList.length)
-						break;
 
-					var attribs = embedList[index];
-
 					// Find end of object
 					endPos = content.indexOf('</object>', startPos);
 					endPos += 9;
+					
+					objectTag = content.substring(startPos,endPos);
+					attribs = TinyMCE_insertvideoPlugin._parseAttributes( objectTag );
+					
+					var class = "";
+					if( getVideoType( attribs["data"] ) == 1 )
+						class = "ltVideoGoogleVideo";
+					else
+						class = "ltVideoYouTube";
+					
 
 					// Insert image
 					var contentAfter = content.substring(endPos);
 					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="'+attribs["class"]+'" />' + content.substring(endPos);
+					content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["data"] + '"';
+					content += ' alt="' + attribs["data"] + '" class="'+class+'" />' + content.substring(endPos);
 					content += contentAfter;
 					index++;
 
@@ -136,7 +137,7 @@
 				}
 
 				// Parse all embed tags and replace them with images from the embed data
-				var index = 0;
+				/*var index = 0;
 				while ((startPos = content.indexOf('<object', startPos)) != -1) {
 					if (index >= embedList.length)
 						break;
@@ -157,7 +158,9 @@
 					index++;
 
 					startPos++;
-				}
+				}*/
+				
+				//window.alert("content after processing: " + content );
 
 				break;
 
@@ -276,4 +279,13 @@
 	return( html );
 }
 
+
+function getVideoType( url )
+{
+	if( url.substring( 0, 24 ) == "http://video.google.com/" )
+		return 1;
+	else
+		return 2;
+}
+
 tinyMCE.addPlugin("insertvideo", TinyMCE_insertvideoPlugin );
\ No newline at end of file



More information about the pLog-svn mailing list