Sends line to proper buffer

This commit is contained in:
David Cormier 2013-07-30 09:22:37 -04:00
parent 33119f292d
commit dd62e07d08
2 changed files with 16 additions and 6 deletions

View file

@ -185,6 +185,7 @@ weechat.factory('connection', ['$rootScope', 'colors', function($scope, colors)
buffers = {}; buffers = {};
for (var i = 0; i < hdaObject['content'].length; i++) { for (var i = 0; i < hdaObject['content'].length; i++) {
content = hdaObject['content'][i]; content = hdaObject['content'][i];
content['lines'] = [];
console.log('content', content); console.log('content', content);
var pointer = content['pointers'][0]; var pointer = content['pointers'][0];
buffers[pointer] = content; buffers[pointer] = content;
@ -197,9 +198,11 @@ weechat.factory('connection', ['$rootScope', 'colors', function($scope, colors)
var handleBufferLineAdded = function(message) { var handleBufferLineAdded = function(message) {
var prefix = colors.parse(message['objects'][0]['content'][0]['prefix']); var prefix = colors.parse(message['objects'][0]['content'][0]['prefix']);
var message = colors.parse(message['objects'][0]['content'][0]['message']); var text = colors.parse(message['objects'][0]['content'][0]['message']);
var buffer_line = _.union(prefix, message); var buffer = message['objects'][0]['content'][0]['buffer'];
$scope.buffer.push(buffer_line); var buffer_line = _.union(prefix, text);
console.log('BUFFER: ', $scope.buffers[buffer]);
$scope.buffers[buffer]['lines'].push(buffer_line);
} }
var sendMessage = function(message) { var sendMessage = function(message) {
@ -222,14 +225,20 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', 'connection', functio
$rootScope.buffer = [] $rootScope.buffer = []
$rootScope.buffers = {} $rootScope.buffers = {}
$rootScope.activeBuffer = null;
$scope.hostport = "localhost:9001" $scope.hostport = "localhost:9001"
$scope.proto = "weechat" $scope.proto = "weechat"
$scope.password = "" $scope.password = ""
$scope.setActiveBuffer = function(key) {
console.log('change buffer');
$rootScope.activeBuffer = $rootScope.buffers[key];
};
$scope.sendMessage = function() { $scope.sendMessage = function() {
connection.sendMessage($scope.command); connection.sendMessage($scope.command);
$scope.command = ""; $scope.command = "";
}, };
$scope.connect = function() { $scope.connect = function() {
connection.connect($scope.hostport, $scope.proto, $scope.password); connection.connect($scope.hostport, $scope.proto, $scope.password);

View file

@ -38,10 +38,11 @@
</form> </form>
</div> </div>
<div ng-show="connected"> <div ng-show="connected">
<div ng-repeat="(key, content) in buffers"> <div ng-repeat="(key, content) in buffers">
{{ content.full_name }} <a ng-click="setActiveBuffer(key)">{{ content.full_name }}</a>
</div> </div>
<div ng-repeat="bufferline in buffer"> <div ng-repeat="bufferline in activeBuffer.lines">
<p> <p>
<span ng-repeat="part in bufferline" class="text"> <span ng-repeat="part in bufferline" class="text">
{{ part.text }} {{ part.text }}