mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 14:47:12 -04:00
Added YouTube + Vimeo support
This commit is contained in:
parent
6fcc3a24f1
commit
4a6f8d0c98
1 changed files with 15 additions and 0 deletions
|
@ -171,6 +171,11 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
|||
|
||||
// video
|
||||
if (href_ext==".mp4" || href_ext==".ogv" || href_ext==".ogg" || href.slice(-5)==".webm" || href_ext==".mov") { mtype = 3; }
|
||||
|
||||
// YouTube
|
||||
if (href.match(/[http|https]\:\/\/www\.youtube\.com\/watch\?v=([A-z0-9-_]{11})/) != null) { mtype = 4; }
|
||||
// Vimeo
|
||||
if (href.match(/[http|https]\:\/\/vimeo\.com\/(\d{8})/) != null) { mtype = 5; }
|
||||
|
||||
switch (mtype) {
|
||||
case 1:
|
||||
|
@ -182,6 +187,16 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
|||
case 3:
|
||||
extraOpenTags = extraOpenTags + '<video controls preload="metadata" src="' + href.replace(/\"/g, '"') + '"></video><br>';
|
||||
break;
|
||||
case 4:
|
||||
var youtube_id = href.match(/[http|https]\:\/\/www\.youtube\.com\/watch\?v=([A-z0-9-_]{11})/)[1];
|
||||
txt = 'https://www.youtube.com/watch?v=' + youtube_id;
|
||||
extraOpenTags = extraOpenTags + '<div style="height:385px"><iframe width=640 height=385 src="https://www.youtube.com/embed/' + youtube_id + '"></iframe></div><br>';
|
||||
break;
|
||||
case 5:
|
||||
var vimeo_id = href.match(/[http|https]\:\/\/vimeo\.com\/(\d{8})/)[1];
|
||||
txt = 'https://vimeo.com/' + vimeo_id;
|
||||
extraOpenTags = extraOpenTags + '<div style="height:338px"><iframe width=640 height=338 src="https://player.vimeo.com/video/' + vimeo_id + '?title=0&byline=0&portrait=0"></iframe></div><br>';
|
||||
break;
|
||||
// if nothing applies, consider it as a normal link
|
||||
default:
|
||||
extraOpenTags = extraOpenTags + '<a href="' + href.replace(/\"/g, '"') + '">';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue