Displays buffer content in main window
Handles the weechat _buffer_line_added event and displays every new line in the main buffer.
This commit is contained in:
parent
4bebd3af79
commit
0df3112d8d
3 changed files with 36 additions and 13 deletions
|
@ -23,9 +23,6 @@ var Protocol = function() {
|
|||
return key.split(':');
|
||||
});
|
||||
var i;
|
||||
console.log("Keys: ", keys);
|
||||
console.log("Paths: ", paths);
|
||||
console.log("Count: ", count);
|
||||
for (i = 0; i < count; i++) {
|
||||
var tmp = {};
|
||||
|
||||
|
@ -33,8 +30,6 @@ var Protocol = function() {
|
|||
return getPointer();
|
||||
});
|
||||
|
||||
console.log("Pointers: ", tmp.pointers);
|
||||
|
||||
keys.forEach(function(key) {
|
||||
tmp[key[0]] = runType(key[1]);
|
||||
});
|
||||
|
@ -45,7 +40,7 @@ var Protocol = function() {
|
|||
|
||||
function getPointer() {
|
||||
var l = getChar();
|
||||
console.log("Length: ", l);
|
||||
|
||||
var pointer = getSlice(l)
|
||||
var parsed_data = new Uint8Array(pointer);
|
||||
return _uiatos(parsed_data);
|
||||
|
@ -122,7 +117,7 @@ var Protocol = function() {
|
|||
}
|
||||
|
||||
self.parse = function() {
|
||||
console.log(new Uint8Array(self.data));
|
||||
|
||||
var header = getHeader();
|
||||
var id = getId();
|
||||
var objects = [];
|
||||
|
|
|
@ -25,18 +25,23 @@ weechat.factory('connection', ['$rootScope', function($scope) {
|
|||
$scope.connected = true;
|
||||
$scope.$apply();
|
||||
}
|
||||
|
||||
websocket.onclose = function (evt) {
|
||||
console.log("disconnected", "Disconnected");
|
||||
$scope.connected = false;
|
||||
}
|
||||
|
||||
websocket.onmessage = function (evt) {
|
||||
console.log("recv", "⇒ " + evt.data);
|
||||
protocol.setData(evt.data);
|
||||
console.log(protocol.parse());
|
||||
protocol.setData(evt.data);
|
||||
message = protocol.parse()
|
||||
console.log(evt);
|
||||
$scope.commands.push("RECV: " + evt.data + " TYPE:" + evt.type) ;
|
||||
data = evt.data;
|
||||
parseMessage(message);
|
||||
data = evt.data;
|
||||
$scope.$apply();
|
||||
}
|
||||
|
||||
|
||||
websocket.onerror = function (evt) {
|
||||
console.log("error", "ERROR: " + evt.data);
|
||||
}
|
||||
|
@ -44,10 +49,31 @@ weechat.factory('connection', ['$rootScope', function($scope) {
|
|||
this.websocket = websocket;
|
||||
}
|
||||
|
||||
var parseMessage = function(message) {
|
||||
console.log(message['id']);
|
||||
if (message['id'] == '_buffer_line_added') {
|
||||
types[message['id']](message);
|
||||
}
|
||||
console.log(message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var handleBufferLineAdded = function(message) {
|
||||
var buffer_line = message['objects'][0]['content'][0]['message'];
|
||||
$scope.buffer.push(buffer_line);
|
||||
}
|
||||
|
||||
var sendMessage = function(message) {
|
||||
message = message + "\n"
|
||||
doSend(message);
|
||||
}
|
||||
|
||||
var types = {
|
||||
_buffer_line_added: handleBufferLineAdded
|
||||
}
|
||||
|
||||
return {
|
||||
connect: connect,
|
||||
sendMessage: sendMessage
|
||||
|
@ -57,6 +83,8 @@ weechat.factory('connection', ['$rootScope', function($scope) {
|
|||
weechat.controller('WeechatCtrl', ['$rootScope', '$scope', 'connection', function ($rootScope, $scope, connection) {
|
||||
$rootScope.commands = []
|
||||
|
||||
$rootScope.buffer = []
|
||||
|
||||
$scope.hostport = "localhost:9001"
|
||||
$scope.proto = "weechat"
|
||||
$scope.password = ""
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
</form>
|
||||
</div>
|
||||
<div ng-show="connected">
|
||||
<div ng-repeat="command in commands">
|
||||
{{ command }}
|
||||
<div ng-repeat="bufferline in buffer">
|
||||
{{ bufferline }}
|
||||
</div>
|
||||
<form ng-submit="sendMessage()">
|
||||
<input type="text" ng-model="command"></input>
|
||||
|
|
Loading…
Reference in a new issue