[pLog-svn] r4728 - plog/branches/lifetype-1.2/js/tinymce/plugins/insertvideo
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Tue Feb 13 13:26:35 EST 2007
Author: oscar
Date: 2007-02-13 13:26:35 -0500 (Tue, 13 Feb 2007)
New Revision: 4728
Modified:
plog/branches/lifetype-1.2/js/tinymce/plugins/insertvideo/functions.js
Log:
Added some extra code in cases where 'www' is missing from youtube URLs.
Modified: plog/branches/lifetype-1.2/js/tinymce/plugins/insertvideo/functions.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertvideo/functions.js 2007-02-13 12:34:34 UTC (rev 4727)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertvideo/functions.js 2007-02-13 18:26:35 UTC (rev 4728)
@@ -10,9 +10,11 @@
function getYouTubeLink( url )
{
+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
+ // 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 ) {
@@ -22,9 +24,26 @@
// let's try to make a best guess...
videoId = url.substring( 31, url.length );
}
-
+
url = "http://www.youtube.com/v/" + videoId;
}
+
+ // Checks if the URL is missing WWW.
+ else if ( url.substring( 0, 27 ) == "http://youtube.com/watch?v=" ) {
+ // and if it's a link to a normal youtube page, build the right link to the video player
+ var regexp = /http:\/\/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( 27, url.length );
+ }
+
+ url = "http://www.youtube.com/v/" + videoId;
+ }
+
return( url );
}
More information about the pLog-svn
mailing list