Skip to content

Commit e2e18af

Browse files
committed
RedGifs Embed Feature
1 parent 05f4464 commit e2e18af

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

dist/app.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -1374,10 +1374,13 @@ var LinkSummary = (function () {
13741374
if (youTubeID) {
13751375
summaryHTML += "<a class=\"preview-container blck\" \n\t\t\t\t\t\t\t\thref=\"" + linkURL + "\" \n\t\t\t\t\t\t\t\ttarget=\"_blank\">\n\t\t\t\t\t\t <img class=\"video-preview\" \n\t\t\t\t\t\t src=\"//img.youtube.com/vi/" + youTubeID + "/hqdefault.jpg\"/>\n\t\t\t\t\t\t </a>";
13761376
} else {
1377-
// if it's a Gfycat link
1377+
// if it's a Gfycat or RedGifs link
13781378
var gfycatID = getGfycatIDfromURL(linkURL);
1379+
var redGifsID = getRedGifsIDfromURL(linkURL);
13791380
if (gfycatID) {
13801381
summaryHTML += "<div style='position:relative; padding-bottom:56.69%'>" + "<iframe src='https://gfycat.com/ifr/" + gfycatID + "' frameborder='0' scrolling='no' width='100%' height='100%' style='position:absolute;top:0;left:0;' allowfullscreen></iframe>" + "</div>";
1382+
} else if (redGifsID) {
1383+
summaryHTML += "<div style='position:relative; padding-bottom:56.69%'>" + "<iframe src='https://redgifs.com/ifr/" + redGifsID + "' frameborder='0' scrolling='no' width='100%' height='100%' style='position:absolute;top:0;left:0;' allowfullscreen></iframe>" + "</div>";
13811384
}
13821385
}
13831386
}
@@ -1459,6 +1462,22 @@ var LinkSummary = (function () {
14591462
}
14601463
};
14611464

1465+
var getRedGifsIDfromURL = function getRedGifsIDfromURL(url) {
1466+
console.log(url);
1467+
var matching = url.match(/redgifs.com\/(?:(?:ifr|watch)\/)(\w+)/i);
1468+
console.log(matching);
1469+
if (!matching) {
1470+
return '';
1471+
} else {
1472+
if (matching && matching.length > 1) {
1473+
console.log(matching[1]);
1474+
return matching[1];
1475+
} else {
1476+
return null;
1477+
}
1478+
}
1479+
};
1480+
14621481
var initListeners = function initListeners() {
14631482
UI.el.detailWrap.on('click', '.js-img-preview', function (ev) {
14641483
ev.preventDefault();

0 commit comments

Comments
 (0)