From 8c6d2ccfb2ea78060df8154b1d931f8eefa0235d Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Tue, 4 Jun 2013 22:47:02 -0400 Subject: [PATCH] Add imgur album embedding --- channel.js | 19 +++++++++++++------ www/assets/js/functions.js | 10 ++++++++++ www/assets/js/media.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/channel.js b/channel.js index cdef75a3..aa4b60e4 100644 --- a/channel.js +++ b/channel.js @@ -952,12 +952,13 @@ function mediaUpdate(chan, id) { } function isLive(type) { - return type == "li" - || type == "tw" - || type == "jt" - || type == "rt" - || type == "jw" - || type == "us"; + return type == "li" // Livestream.com + || type == "tw" // Twitch.tv + || type == "jt" // Justin.tv + || type == "rt" // RTMP + || type == "jw" // JWPlayer + || type == "us" // Ustream.tv + || type == "im";// Imgur album } Channel.prototype.queueAdd = function(media, idx) { @@ -1050,6 +1051,12 @@ Channel.prototype.enqueue = function(data, user) { this.autoTemp(media, user); this.queueAdd(media, idx); break; + case "im": + var media = new Media(data.id, "Imgur Album", "--:--", "im"); + media.queueby = user ? user.name : ""; + this.autoTemp(media, user); + this.queueAdd(media, idx); + break; default: break; } diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js index d344b813..e13310cf 100644 --- a/www/assets/js/functions.js +++ b/www/assets/js/functions.js @@ -669,6 +669,8 @@ function parseVideoURL(url){ return [parseVimeo(url), "vi"]; else if(url.indexOf("dailymotion.com") != -1) return [parseDailymotion(url), "dm"]; + else if(url.indexOf("imgur.com") != -1) + return [parseImgur(url), "im"]; } function parseYTURL(url) { @@ -743,6 +745,14 @@ function parseDailymotion(url) { return null; } +function parseImgur(url) { + var m = url.match(/imgur\.com\/a\/([a-zA-Z0-9]+)/); + if(m) { + return m[1]; + } + return null; +} + function closePoll() { if($("#pollcontainer .active").length != 0) { var poll = $("#pollcontainer .active"); diff --git a/www/assets/js/media.js b/www/assets/js/media.js index 401bead5..1a8cf6a4 100644 --- a/www/assets/js/media.js +++ b/www/assets/js/media.js @@ -51,6 +51,9 @@ var Media = function(data) { case "us": this.initUstream(); break; + case "im": + this.initImgur(); + break; default: this.nullPlayer(); break; @@ -467,6 +470,31 @@ Media.prototype.initUstream = function() { this.seek = function() { } } +Media.prototype.initImgur = function() { + var iframe = $("