Merge pull request #2 from tmatth/url_plugin

js: added url plugin
This commit is contained in:
David Cormier 2013-10-01 17:06:04 -07:00
commit dfbb3948dc

View file

@ -101,9 +101,9 @@ weechat.factory('colors', [function($scope) {
}]);
weechat.factory('pluginManager', ['youtubePlugin', function(youtubePlugin) {
weechat.factory('pluginManager', ['youtubePlugin', 'urlPlugin', function(youtubePlugin, urlPlugin) {
var plugins = [youtubePlugin]
var plugins = [youtubePlugin, urlPlugin]
var hookPlugin = function(plugin) {
plugins.push(plugin);
@ -147,6 +147,23 @@ weechat.factory('youtubePlugin', [function() {
}
}]);
weechat.factory('urlPlugin', [function() {
var contentForMessage = function(message) {
var prefix = 'http://';
var linkIndex = message.indexOf(prefix);
if (linkIndex != -1) {
var token = message.substr(linkIndex);
return '<a href="' + token + '">' + token + '</a>';
}
return null;
}
return {
contentForMessage: contentForMessage
}
}]);
weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($rootScope, colors, pluginManager) {