From 4a6f8d0c9824d3c1b3ba47731575aeaebaffe1aa Mon Sep 17 00:00:00 2001 From: 0ip Date: Tue, 29 Nov 2011 21:06:23 +0100 Subject: [PATCH] Added YouTube + Vimeo support --- static/js/domline.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/static/js/domline.js b/static/js/domline.js index c3da98e7e..aabc5de18 100644 --- a/static/js/domline.js +++ b/static/js/domline.js @@ -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 + '
'; 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 + '

'; + break; + case 5: + var vimeo_id = href.match(/[http|https]\:\/\/vimeo\.com\/(\d{8})/)[1]; + txt = 'https://vimeo.com/' + vimeo_id; + extraOpenTags = extraOpenTags + '

'; + break; // if nothing applies, consider it as a normal link default: extraOpenTags = extraOpenTags + '';