websocket.js: fix a few obvious indentations

This commit is contained in:
Philippe Proulx 2013-10-19 14:11:01 -04:00
parent 1e66b16da9
commit 2e421f8361
1 changed files with 43 additions and 43 deletions

View File

@ -59,9 +59,9 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', functi
} }
var handleBufferLineAdded = function(message) { var handleBufferLineAdded = function(message) {
message['objects'][0]['content'].forEach(function(l) { message['objects'][0]['content'].forEach(function(l) {
handleLine(l, false); handleLine(l, false);
}); });
} }
var handleBufferOpened = function(message) { var handleBufferOpened = function(message) {
@ -93,34 +93,34 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', functi
* (lineinfo) messages are specified by this client. It is request after bufinfo completes * (lineinfo) messages are specified by this client. It is request after bufinfo completes
*/ */
var handleLineInfo = function(message) { var handleLineInfo = function(message) {
var lines = message['objects'][0]['content'].reverse(); var lines = message['objects'][0]['content'].reverse();
lines.forEach(function(l) { lines.forEach(function(l) {
handleLine(l, true); handleLine(l, true);
}); });
} }
/* /*
* Handle answers to hotlist request * Handle answers to hotlist request
*/ */
var handleHotlistInfo = function(message) { var handleHotlistInfo = function(message) {
if (message.objects.length == 0) { if (message.objects.length == 0) {
return; return;
} }
var hotlist = message['objects'][0]['content']; var hotlist = message['objects'][0]['content'];
hotlist.forEach(function(l) { hotlist.forEach(function(l) {
var buffer = models.getBuffer(l.buffer); var buffer = models.getBuffer(l.buffer);
// 1 is message // 1 is message
buffer.unread += l.count[1]; buffer.unread += l.count[1];
// 2 is ? // 2 is ?
buffer.unread += l.count[2]; buffer.unread += l.count[2];
// 3 is highlight // 3 is highlight
buffer.notification += l.count[3]; buffer.notification += l.count[3];
/* Since there is unread messages, we can guess /* Since there is unread messages, we can guess
* what the last read line is and update it accordingly * what the last read line is and update it accordingly
*/ */
var unreadSum = _.reduce(l.count, function(memo, num){ return memo + num; }, 0); var unreadSum = _.reduce(l.count, function(memo, num){ return memo + num; }, 0);
buffer.lastSeen = buffer.lines.length - 1 - unreadSum; buffer.lastSeen = buffer.lines.length - 1 - unreadSum;
}); });
} }
var handleEvent = function(event) { var handleEvent = function(event) {
@ -254,7 +254,7 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
$rootScope.connected = true; $rootScope.connected = true;
}); });
}); });
} }
websocket.onclose = function (evt) { websocket.onclose = function (evt) {
$log.info("Disconnected from relay"); $log.info("Disconnected from relay");
@ -293,8 +293,8 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
} }
var disconnect = function() { var disconnect = function() {
console.log(this.websocket); console.log(this.websocket);
this.websocket.close(); this.websocket.close();
} }
var sendMessage = function(message) { var sendMessage = function(message) {
@ -454,18 +454,18 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}; };
$scope.hasUnread = function(buffer) { $scope.hasUnread = function(buffer) {
// if search is set, return every buffer // if search is set, return every buffer
if($scope.search && $scope.search != "") { if($scope.search && $scope.search != "") {
return true;
}
if($scope.onlyUnread) {
// Always show current buffer in list
if (models.getActiveBuffer() == buffer) {
return true; return true;
} }
return buffer.unread > 0 || buffer.notification > 0; if($scope.onlyUnread) {
} // Always show current buffer in list
return true; if (models.getActiveBuffer() == buffer) {
return true;
}
return buffer.unread > 0 || buffer.notification > 0;
}
return true;
}; };
$rootScope.switchToActivityBuffer = function() { $rootScope.switchToActivityBuffer = function() {
@ -518,13 +518,13 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
var code = $event.keyCode ? $event.keyCode : $event.charCode; var code = $event.keyCode ? $event.keyCode : $event.charCode;
// Handle escape // Handle escape
if(code == 27) { if(code == 27) {
$event.preventDefault(); $event.preventDefault();
$scope.search = ''; $scope.search = '';
} // Handle enter } // Handle enter
else if (code == 13) { else if (code == 13) {
$event.preventDefault(); $event.preventDefault();
// TODO Switch to first matching buffer and reset query // TODO Switch to first matching buffer and reset query
$scope.search = ''; $scope.search = '';
} }
} }