|
|
|
@ -101,8 +101,53 @@ weechat.factory('colors', [function($scope) { |
|
|
|
|
|
|
|
|
|
}]); |
|
|
|
|
|
|
|
|
|
weechat.factory('pluginManager', ['youtubePlugin', function(youtubePlugin) { |
|
|
|
|
|
|
|
|
|
weechat.factory('handlers', ['$rootScope', 'colors', function($rootScope, colors) { |
|
|
|
|
var plugins = [youtubePlugin] |
|
|
|
|
|
|
|
|
|
var hookPlugin = function(plugin) { |
|
|
|
|
plugins.push(plugin); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var contentForMessage = function(message) { |
|
|
|
|
|
|
|
|
|
console.log('Message: ', message); |
|
|
|
|
var content = []; |
|
|
|
|
for (var i = 0; i < plugins.length; i++) { |
|
|
|
|
var pluginContent = plugins[i].contentForMessage(message); |
|
|
|
|
if (pluginContent) { |
|
|
|
|
content.push(pluginContent); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log('Content: ', content); |
|
|
|
|
return content; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
hookPlugin: hookPlugin, |
|
|
|
|
contentForMessage: contentForMessage |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}]); |
|
|
|
|
|
|
|
|
|
weechat.factory('youtubePlugin', [function() { |
|
|
|
|
var contentForMessage = function(message) { |
|
|
|
|
if (message.indexOf('youtube.com') != -1) { |
|
|
|
|
var index = message.indexOf("?v="); |
|
|
|
|
var token = message.substr(index+3); |
|
|
|
|
return '<iframe width="560" height="315" src="http://www.youtube.com/embed/' + token + '" frameborder="0" allowfullscreen></iframe>' |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
contentForMessage: contentForMessage |
|
|
|
|
} |
|
|
|
|
}]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($rootScope, colors, pluginManager) { |
|
|
|
|
|
|
|
|
|
var handleBufferLineAdded = function(message) { |
|
|
|
|
var buffer_line = {} |
|
|
|
@ -111,11 +156,16 @@ weechat.factory('handlers', ['$rootScope', 'colors', function($rootScope, colors |
|
|
|
|
var buffer = message['objects'][0]['content'][0]['buffer']; |
|
|
|
|
var message = _.union(prefix, text); |
|
|
|
|
buffer_line['message'] = message; |
|
|
|
|
buffer_line['metadata'] = findMetaData(text[0]['text']); |
|
|
|
|
|
|
|
|
|
if (!_isActiveBuffer(buffer)) { |
|
|
|
|
$rootScope.buffers[buffer]['notification'] = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var additionalContent = pluginManager.contentForMessage(text[0]['text']); |
|
|
|
|
if (additionalContent) { |
|
|
|
|
buffer_line['metadata'] = additionalContent; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$rootScope.buffers[buffer]['lines'].push(buffer_line); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -172,7 +222,6 @@ weechat.factory('handlers', ['$rootScope', 'colors', function($rootScope, colors |
|
|
|
|
return '<iframe width="560" height="315" src="http://www.youtube.com/embed/' + token + '" frameborder="0" allowfullscreen></iframe>' |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var eventHandlers = { |
|
|
|
|