js: added url plugin

This commit is contained in:
Tristan Matthews 2013-10-01 20:03:05 -04:00
parent 951abf878b
commit 90c874dbde
1 changed files with 19 additions and 2 deletions

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) {