From: portshner Date: Fri, 24 May 2013 21:06:59 +0000 (-0300) Subject: Update mediamessage.js X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9ff10506a4c541f7603d7f4bbdc2d32858427371;p=KiwiIRC.git Update mediamessage.js Add youtube support to MediaType/MediaMessage --- 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 +});