[ Index ] |
|
Code source de LifeType 1.2.4 |
1 function init() { 2 tinyMCEPopup.resizeToInnerSize(); 3 } 4 5 function isValidUrl( url ) 6 { 7 var regexp = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/ 8 return regexp.test(url); 9 } 10 11 function getYouTubeLink( url ) 12 { 13 // check if this is a URL pointing to a youtube link or to a youtube video 14 //if( url.substring( 0, 31 ) == "http://www.youtube.com/watch?v=" ) { 15 if( url.match( /http:\/\/.{2,3}\.youtube.com\//i )) { 16 // and if it's a link to a normal youtube page, build the right link to the video player 17 var regexp = /http:\/\/.{2,3}\.youtube.com\/.*?v=([\-0-9a-zA-z_]*).*/i; 18 result = regexp.exec( url ); 19 if( result ) { 20 videoId = result[1]; 21 } 22 else { 23 // let's try to make a best guess... 24 videoId = url.substring( 31, url.length ); 25 } 26 27 url = "http://www.youtube.com/v/" + videoId; 28 } 29 else if ( url.substring( 0, 27 ) == "http://youtube.com/watch?v=" ) { 30 // Checks if the URL is missing WWW. 31 // and if it's a link to a normal youtube page, build the right link to the video player 32 var regexp = /http:\/\/youtube.com\/.*?v=([\-0-9a-zA-z_]*).*/i; 33 result = regexp.exec( url ); 34 if( result ) { 35 videoId = result[1]; 36 } 37 else { 38 // let's try to make a best guess... 39 videoId = url.substring( 27, url.length ); 40 } 41 42 url = "http://www.youtube.com/v/" + videoId; 43 } 44 else { 45 var regexp = /.*?v=([\-0-9a-zA-z_]*).*/i; 46 result = regexp.exec( url ); 47 if( result ) { 48 videoId = result[1]; 49 url = "http://www.youtube.com/v/" + videoId; 50 } 51 } 52 53 return( url ); 54 } 55 56 function getGoogleVideoLink( url ) 57 { 58 // check if it's a link to a video page or a link to the video player 59 if( url.substring( 0, 40 ) == "http://video.google.com/videoplay?docid=" ) { 60 // if it's a link to a video page, generate the right one 61 var regexp = /http:\/\/video.google.com\/.*?docid=([\-0-9a-zA-z_]*).*/i; 62 result = regexp.exec( url ); 63 if( result ) { 64 videoId = result[1]; 65 } 66 else { 67 videoId = url.substring( 40, url.length ); 68 } 69 70 url = "http://video.google.com/googleplayer.swf?docId=" + videoId; 71 } 72 73 return( url ); 74 } 75 76 function getMetacafeVideoLink( url ) 77 { 78 // check if it's a link to a video page or a link to the video player 79 if( url.substring( 0, 30 ) == "http://www.metacafe.com/watch/" ) { 80 // if it's a link to a video page, generate the right one 81 var regexp = /http:\/\/www.metacafe.com\/watch\/.*?docid=([\-0-9a-zA-z_]*).*/i; 82 result = regexp.exec( url ); 83 if( result ) { 84 videoId = result[1]; 85 } 86 else { 87 videoId = url.substring( 30, url.length - 1 ); 88 } 89 90 url = "http://www.metacafe.com/fplayer/" + videoId + ".swf"; 91 } 92 93 return( url ); 94 } 95 96 function getiFilmVideoLink( url ) 97 { 98 // check if it's a link to a video page or a link to the video player 99 if( url.substring( 0, 27 ) == "http://www.ifilm.com/video/" ) { 100 // if it's a link to a video page, generate the right one 101 var regexp = /http:\/\/www.ifilm.com\/video\/.*?docid=([\-0-9a-zA-z_]*).*/i; 102 result = regexp.exec( url ); 103 if( result ) { 104 videoId = result[1]; 105 } 106 else { 107 videoId = url.substring( 27, url.length ); 108 } 109 110 url = "http://www.ifilm.com/efp?flvbaseclip=" + videoId ; 111 } 112 113 return( url ); 114 } 115 116 function getGoearVideoLink( url ) 117 { 118 // check if it's a link to a video page or a link to the video player 119 if( url.substring( 0, 34 ) == "http://www.goear.com/listen.php?v=" ) { 120 // if it's a link to a video page, generate the right one 121 var regexp = /http:\/\/www.goear.com\/.*?v=([\-0-9a-zA-z_]*).*/i; 122 result = regexp.exec( url ); 123 if( result ) { 124 videoId = result[1]; 125 } 126 else { 127 videoId = url.substring( 34, url.length ); 128 } 129 url = "http://www.goear.com/files/localplayer.swf?file=" + videoId ; 130 } 131 132 return( url ); 133 } 134 135 function getGrouperVideoLink( url ) 136 { 137 // check if it's a link to a video page or a link to the video player 138 if( url.substring( 0, 46 ) == "http://grouper.com/video/MediaDetails.aspx?id=" ) { 139 // if it's a link to a video page, generate the right one 140 var regexp = /http:\/\/www.grouper.com\/video\/MediaDetails.aspx.*?id=([\-0-9a-zA-z_]*).*/i; 141 result = regexp.exec( url ); 142 if( result ) { 143 videoId = result[1]; 144 } 145 else { 146 videoId = url.substring( 46, url.length ); 147 } 148 149 url = "http://grouper.com/mtg/mtgPlayer.swf?gvars=vurl~http%3a%2f%2fgrouper.com%2frss%2fflv.ashx%3fid%3d" + videoId + "_rf%7e-9_vfver~8_ap~1_extid~-1"; 150 } 151 152 return( url ); 153 } 154 155 function getDailymotionLink( url ) 156 { 157 // check if this is a URL pointing to a dailymotion embedded video link 158 var regexp = /object\swidth="([0-9]+)"\sheight="([0-9]+)".+value="(http:\/\/www\.dailymotion\.com\/swf\/\w*)"/; 159 result = regexp.exec( url ); 160 return( result ); 161 } 162 163 function insertVideoCode() 164 { 165 // get and check the URL 166 urlField = document.forms[0].url; 167 url = urlField.value; 168 if( url == "" || !isValidUrl( url )) { 169 window.alert( tinyMCE.getLang('lang_insertvideo_badurl', 0) ); 170 return( false ); 171 } 172 173 // check if a destination system was selected 174 youtube = document.getElementById("youtube"); 175 gvideo = document.getElementById("gvideo"); 176 // dalealplay = document.getElementById("dalealplay"); 177 metacafe = document.getElementById("metacafe"); 178 ifilm = document.getElementById("ifilm"); 179 goear = document.getElementById("goear"); 180 grouper = document.getElementById("grouper"); 181 dailymot = document.getElementById("dailymot"); 182 // bolt = document.getElementById("bolt"); 183 184 if( youtube.checked==false && gvideo.checked==false && metacafe.checked==false && ifilm.checked==false && goear.checked==false && grouper.checked==false && dailymot.checked==false ) { 185 window.alert( tinyMCE.getLang('lang_insertvideo_selectiontype', 0) ); 186 return( false ); 187 } 188 189 if( youtube.checked == true ) { 190 link = getYouTubeLink( url ); 191 css="ltVideoYouTube"; 192 width=450; 193 height=350; 194 } 195 if( gvideo.checked == true ) { 196 link = getGoogleVideoLink( url ); 197 css="ltVideoGoogleVideo"; 198 width=400; 199 height=326; 200 } 201 if( metacafe.checked == true ) { 202 link = getMetacafeVideoLink( url ); 203 css="ltVideoMetacafe"; 204 width=400; 205 height=345; 206 } 207 if( ifilm.checked == true ) { 208 link = getiFilmVideoLink( url ); 209 css="ltVideoIfilm"; 210 width=448; 211 height=365; 212 } 213 if( goear.checked == true ) { 214 link = getGoearVideoLink( url ); 215 css="ltVideoGoear"; 216 width=366; 217 height=75; 218 } 219 if( grouper.checked == true ) { 220 link = getGrouperVideoLink( url ); 221 css="ltVideoGrouper"; 222 width=496; 223 height=398; 224 } 225 if( dailymot.checked == true ) { 226 result = getDailymotionLink( url ); 227 width = result[1]; 228 height = result[2]; 229 link = result[3]; 230 css="ltVideoDailymot"; 231 } 232 insertFlash( link, css, width, height ); 233 } 234 235 function insertFlash( file, css, width, height ) { 236 237 var html = ''; 238 239 html += '' 240 + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" mce_src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ' 241 + 'width="' + width + '" height="' + height + '" ' 242 + 'border="0" alt="' + file + '" title="' + file + '" class="'+css+'" />'; 243 244 tinyMCEPopup.execCommand("mceInsertContent", true, html); 245 tinyMCE.selectedInstance.repaint(); 246 247 tinyMCEPopup.close(); 248 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |