diff --git a/index.html b/index.html index 9f791c9..00961ab 100644 --- a/index.html +++ b/index.html @@ -47,7 +47,12 @@ {{ part.text }} -
+
+
+
+
+
+
diff --git a/js/websockets.js b/js/websockets.js index b73ffd0..d10c466 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -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 '' + } + 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 '' } return null; - } var eventHandlers = {