From d513dc2cd2057d32cb58ad34244b43ec4660279c Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 25 May 2013 17:36:36 +0100 Subject: [PATCH] MediaMessages tidy --- client/assets/src/views/mediamessage.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/client/assets/src/views/mediamessage.js b/client/assets/src/views/mediamessage.js index 92419e2..2f80282 100644 --- a/client/assets/src/views/mediamessage.js +++ b/client/assets/src/views/mediamessage.js @@ -55,6 +55,7 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ return $(''); }, + imgur: function () { var that = this; @@ -66,7 +67,7 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ return $('
Loading image..
'); }, - + reddit: function () { var that = this; var matches = (/reddit\.com\/r\/([a-zA-Z0-9_\-]+)\/comments\/([a-z0-9]+)\/([^\/]+)?/gi).exec(this.url); @@ -101,6 +102,8 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ return $('
Loading Reddit thread..
'); }, + + youtube: function () { var ytid = this.$el.data('ytid'); var that = this; @@ -120,15 +123,12 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ if (url.match(/(\.jpe?g|\.gif|\.bmp|\.png)\??$/i)) { html += ''; } - - // is this an imgur link? + + // Is this an imgur link not picked up by the images regex? matches = (/imgur\.com\/[^/]*(?!=\.[^!.]+($|\?))/ig).exec(url); - if (matches) { - if (url.match(/(\.jpe?g|\.gif|\.bmp|\.png)\??$/i)) { - } else { - html += ''; - } - } + if (matches && !url.match(/(\.jpe?g|\.gif|\.bmp|\.png)\??$/i)) { + html += ''; + } // Is it a tweet? matches = (/https?:\/\/twitter.com\/([a-zA-Z0-9_]+)\/status\/([0-9]+)/ig).exec(url); @@ -141,7 +141,7 @@ _kiwi.view.MediaMessage = Backbone.View.extend({ if (matches) { html += ''; } - + // Is youtube? matches = (/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/gi).exec(url); if (matches) { -- 2.25.1