From c80dc34770692a7c75d865d3499368b422669b35 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Tue, 6 Aug 2013 11:06:42 -0400 Subject: [PATCH] Displays notifications in buffer title --- index.html | 4 ++-- js/websockets.js | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 76728e1..c529fb0 100644 --- a/index.html +++ b/index.html @@ -39,9 +39,9 @@
-
+ {{ content.full_name }} -
+
diff --git a/js/websockets.js b/js/websockets.js index 391b079..b73ffd0 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -112,13 +112,29 @@ weechat.factory('handlers', ['$rootScope', 'colors', function($rootScope, colors var message = _.union(prefix, text); buffer_line['message'] = message; buffer_line['metadata'] = findMetaData(text[0]['text']); + if (!_isActiveBuffer(buffer)) { + $rootScope.buffers[buffer]['notification'] = true; + } + $rootScope.buffers[buffer]['lines'].push(buffer_line); } + /* + * Returns whether or not this buffer is the active buffer + */ + var _isActiveBuffer = function(buffer) { + if ($rootScope.activeBuffer['id'] == buffer) { + return true; + } else { + return false; + } + } + var handleBufferOpened = function(message) { var fullName = message['objects'][0]['content'][0]['full_name'] var buffer = message['objects'][0]['content'][0]['pointers'][0] - $rootScope.buffers[buffer] = { 'lines':[], 'full_name':fullName } + $rootScope.buffers[buffer] = { 'id': buffer, 'lines':[], 'full_name':fullName } + } /* @@ -135,7 +151,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', function($rootScope, colors for (var i = 0; i < bufferInfos.length ; i++) { var bufferInfo = bufferInfos[i]; var pointer = bufferInfo['pointers'][0]; - + bufferInfo['id'] = pointer; bufferInfo['lines'] = []; buffers[pointer] = bufferInfo } @@ -251,6 +267,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', 'connection', functio $scope.password = "" $scope.setActiveBuffer = function(key) { + $rootScope.buffers[key]['notification'] = false; $rootScope.activeBuffer = $rootScope.buffers[key]; };