From 9ff10506a4c541f7603d7f4bbdc2d32858427371 Mon Sep 17 00:00:00 2001 From: portshner Date: Fri, 24 May 2013 18:06:59 -0300 Subject: [PATCH] Update mediamessage.js Add youtube support to MediaType/MediaMessage --- client/assets/src/views/mediamessage.js | 29 +++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/client/assets/src/views/mediamessage.js b/client/assets/src/views/mediamessage.js index 5a6d131..c8defe8 100644 --- a/client/assets/src/views/mediamessage.js +++ b/client/assets/src/views/mediamessage.js @@ -89,6 +89,26 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ }); return $('
Loading Reddit thread..
'); + }, + youtube: function () { + var that = this; + + $.ajax({ + url: 'http://query.yahooapis.com/v1/public/yql', + data: { + q: "select * from json where url ='http://www.youtube.com/oembed?url="+ this.url + "&format=json'", + format: "json" + }, + dataType: "jsonp", + success: function (data) { + that.$content.find('.content').html(data["query"]["results"]["json"]["html"]); + }, + error: function (result) { + console.log("Sorry no data found."); + } + }); + + return $('
Loading video..
'); } } @@ -114,7 +134,12 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ if (matches) { html += ''; } - + + // Is youtube? + matches = (/youtube\.com\/watch\?v\=([a-zA-Z0-9_\-]+)?/gi).exec(url); + if (matches) { + html += ''; + } return html; } -}); \ No newline at end of file +}); -- 2.25.1