Commit 158f3f00 authored by JC Brand's avatar JC Brand

utils/html: expose more methods

parent ef1f16c1
...@@ -94,9 +94,9 @@ function checkFileTypes (types, url) { ...@@ -94,9 +94,9 @@ function checkFileTypes (types, url) {
return !!types.filter(ext => filename.endsWith(ext)).length; return !!types.filter(ext => filename.endsWith(ext)).length;
} }
const isAudioURL = url => checkFileTypes(['.ogg', '.mp3', '.m4a'], url); u.isAudioURL = url => checkFileTypes(['.ogg', '.mp3', '.m4a'], url);
const isImageURL = url => checkFileTypes(['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff', '.svg'], url); u.isImageURL = url => checkFileTypes(['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff', '.svg'], url);
const isVideoURL = url => checkFileTypes(['.mp4', '.webm'], url); u.isVideoURL = url => checkFileTypes(['.mp4', '.webm'], url);
function getFileName (uri) { function getFileName (uri) {
try { try {
...@@ -146,11 +146,11 @@ u.getOOBURLMarkup = function (_converse, url) { ...@@ -146,11 +146,11 @@ u.getOOBURLMarkup = function (_converse, url) {
if (uri === null) { if (uri === null) {
return url; return url;
} }
if (isVideoURL(uri)) { if (u.isVideoURL(uri)) {
return tpl_video({url}) return tpl_video({url})
} else if (isAudioURL(uri)) { } else if (u.isAudioURL(uri)) {
return renderAudioURL(_converse, uri); return renderAudioURL(_converse, uri);
} else if (isImageURL(uri)) { } else if (u.isImageURL(uri)) {
return renderImageURL(_converse, uri); return renderImageURL(_converse, uri);
} else { } else {
return renderFileURL(_converse, uri); return renderFileURL(_converse, uri);
...@@ -197,7 +197,7 @@ u.renderImageURLs = function (_converse, el) { ...@@ -197,7 +197,7 @@ u.renderImageURLs = function (_converse, el) {
return Promise.all( return Promise.all(
list.map(url => list.map(url =>
new Promise((resolve) => { new Promise((resolve) => {
if (isImageURL(url)) { if (u.isImageURL(url)) {
return isImage(url).then(img => { return isImage(url).then(img => {
const i = new Image(); const i = new Image();
i.src = img.src; i.src = img.src;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment