-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlibrary.js
More file actions
26 lines (21 loc) · 1.25 KB
/
library.js
File metadata and controls
26 lines (21 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(function(module) {
"use strict";
var Soundcloud = {},
embed = '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/$1/$2&show_artwork=true"></iframe>',
embeds = '<iframe width="100%" height="410" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/$1/sets/$2&show_artwork=true"></iframe>'
var embedtrack = /<a href="(?:https?:\/\/)?(?:www\.)?(?:soundcloud\.com)\/?([\w\-_]+)\/([\w\-_]+)" (?:rel="nofollow")?>.+<\/a>/g;
var embedset = /<a href="(?:https?:\/\/)?(?:www\.)?(?:soundcloud\.com)\/?([\w\-_]+)\/sets\/([\w\-_]+)" (?:rel="nofollow")?>.+<\/a>/g;
Soundcloud.parsePost = function(data, callback) {
if (!data || !data.postData || !data.postData.content) {
return callback(null, data);
}
if (data.postData.content.match(embedtrack)) {
data.postData.content = data.postData.content.replace(embedtrack, embed);
}
if (data.postData.content.match(embedset)) {
data.postData.content = data.postData.content.replace(embedset, embeds);
}
callback(null, data);
};
module.exports = Soundcloud;
}(module));