diff --git a/js/plugins.js b/js/plugins.js index d725c79..58dc939 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -49,52 +49,39 @@ plugins.service('plugins', function() { }]); -plugins.factory('youtubePlugin', [function() { +plugins.factory('userPlugins', function() { + + var youtubePlugin = new Plugin(function(message) { - var contentForMessage = function(message) { if (message.indexOf('youtube.com') != -1) { var index = message.indexOf("?v="); var token = message.substr(index+3); return '' } + return null; - } + }); - return { - contentForMessage: contentForMessage, - exclusive: true - } - -}]); - -plugins.factory('urlPlugin', [function() { - var contentForMessage = function(message) { + var urlPlugin = new Plugin(function(message) { var urlPattern = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/; var url = message.match(urlPattern); if (url) { return '' + message + ''; } return null; - } - return { - contentForMessage: contentForMessage, - exclusive: false - } -}]); + }); -plugins.factory('imagePlugin', [function() { - var contentForMessage = function(message) { - var urls = message.match(/https?:\/\/[^\s]*\.(jpg|png|gif)\b/) - if (urls != null) { - var url = urls[0]; /* Actually parse one url per message */ - return ''; + var imagePlugin = new Plugin(function(message) { + var urls = message.match(/https?:\/\/[^\s]*\.(jpg|png|gif)\b/) + if (urls != null) { + var url = urls[0]; /* Actually parse one url per message */ + return ''; } return null; - } + }); return { - contentForMessage: contentForMessage + plugins: [youtubePlugin, urlPlugin, imagePlugin] } -}]); - +});