From 8dcc48082d1708fa6ad5c5ada073dd51e9cecf12 Mon Sep 17 00:00:00 2001 From: Louis T Date: Sun, 23 Mar 2014 19:06:08 -0400 Subject: [PATCH] Add Spotify to mediamessage.js WITHOUT breaking prawnsalad's changes --- client/src/views/mediamessage.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/client/src/views/mediamessage.js b/client/src/views/mediamessage.js index 93907b1..f7f09d4 100644 --- a/client/src/views/mediamessage.js +++ b/client/src/views/mediamessage.js @@ -166,10 +166,31 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ } }, { + /** + * Add a media message type to append HTML after a matching URL + * match() should return true if it wants to handle this URL + * buildHtml() should return the HTML string to append after the URL in the message + */ + addType: function(match, buildHtml) { + if (typeof match !== 'function' || typeof buildHtml !== 'function') + return; + + this.types = this.types || []; + this.types.push({match: match, buildHtml: buildHtml}); + }, + + // Build the closed media HTML from a URL buildHtml: function (url) { var html = '', matches; + _.each(this.types || [], function(type) { + if (!type.match(url)) + return; + + html += type.buildHtml(url); + }); + // Is it an image? if (url.match(/(\.jpe?g|\.gif|\.bmp|\.png)\??$/i)) { html += ''; -- 2.25.1