mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
Basic support for different media types
This commit is contained in:
parent
054af3da77
commit
2e2cba82a3
1 changed files with 34 additions and 3 deletions
|
@ -152,12 +152,43 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
||||||
{
|
{
|
||||||
if (href)
|
if (href)
|
||||||
{
|
{
|
||||||
if(!~href.indexOf("http")) // if the url doesn't include http or https etc prefix it.
|
|
||||||
|
// if the url doesn't include http or https prefix it
|
||||||
|
if(!~href.indexOf("http"))
|
||||||
{
|
{
|
||||||
href = "http://"+href;
|
href = "http://"+href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check extension and decide, whether it's media (image,audio,video) or a simple link
|
||||||
|
var href_ext = href.slice(-4);
|
||||||
|
var mtype = null;
|
||||||
|
|
||||||
|
// images
|
||||||
|
if (href_ext==".jpg" || href_ext==".png" || href_ext==".gif" || href_ext==".svg") { mtype = 1; }
|
||||||
|
|
||||||
|
// music
|
||||||
|
if (href_ext==".mp3" || href_ext==".wav" || href_ext==".oga") { mtype = 2; }
|
||||||
|
|
||||||
|
// video
|
||||||
|
if (href_ext==".mp4" || href_ext==".ogv" || href_ext==".ogg" || href.slice(-5)==".webm" || href_ext==".mov") { mtype = 3; }
|
||||||
|
|
||||||
|
switch (mtype) {
|
||||||
|
case 1:
|
||||||
|
extraOpenTags = extraOpenTags + '<img src="' + href.replace(/\"/g, '"') + '"><br>';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
extraOpenTags = extraOpenTags + '<audio controls preload="metadata" src="' + href.replace(/\"/g, '"') + '"></audio><br>';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
extraOpenTags = extraOpenTags + '<video controls preload="metadata" src="' + href.replace(/\"/g, '"') + '"></video><br>';
|
||||||
|
break;
|
||||||
|
// if nothing applies, consider it as a normal link
|
||||||
|
default:
|
||||||
extraOpenTags = extraOpenTags + '<a href="' + href.replace(/\"/g, '"') + '">';
|
extraOpenTags = extraOpenTags + '<a href="' + href.replace(/\"/g, '"') + '">';
|
||||||
extraCloseTags = '</a>' + extraCloseTags;
|
extraCloseTags = '</a>' + extraCloseTags;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (simpleTags)
|
if (simpleTags)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue