Add BufferLine model
This commit is contained in:
parent
e874912e7c
commit
8adbcc1176
|
@ -50,7 +50,7 @@
|
||||||
</span>
|
</span>
|
||||||
<div ng-repeat="bufferline in activeBuffer.lines">
|
<div ng-repeat="bufferline in activeBuffer.lines">
|
||||||
|
|
||||||
<span ng-repeat="part in bufferline.message" class="text {{ part.fg }}">
|
<span ng-repeat="part in bufferline.content" class="text {{ part.fg }}">
|
||||||
{{ part.text }}
|
{{ part.text }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,6 @@ weechat.factory('pluginManager', ['youtubePlugin', 'urlPlugin', 'imagePlugin', f
|
||||||
|
|
||||||
var contentForMessage = function(message) {
|
var contentForMessage = function(message) {
|
||||||
|
|
||||||
console.log('Message: ', message);
|
|
||||||
var content = [];
|
var content = [];
|
||||||
for (var i = 0; i < plugins.length; i++) {
|
for (var i = 0; i < plugins.length; i++) {
|
||||||
var pluginContent = plugins[i].contentForMessage(message);
|
var pluginContent = plugins[i].contentForMessage(message);
|
||||||
|
@ -133,7 +132,6 @@ weechat.factory('pluginManager', ['youtubePlugin', 'urlPlugin', 'imagePlugin', f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Content: ', content);
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,31 +198,56 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($
|
||||||
$rootScope.closeBuffer(buffer_pointer);
|
$rootScope.closeBuffer(buffer_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
var handleBufferLineAdded = function(message) {
|
|
||||||
var buffer_line = {}
|
|
||||||
|
function BufferLine(weechatBufferLine) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parse the text elements from the buffer line added
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function parseLineAddedTextElements(message) {
|
||||||
var prefix = colors.parse(message['objects'][0]['content'][0]['prefix']);
|
var prefix = colors.parse(message['objects'][0]['content'][0]['prefix']);
|
||||||
var text = colors.parse(message['objects'][0]['content'][0]['message']);
|
|
||||||
var buffer = message['objects'][0]['content'][0]['buffer'];
|
var buffer = message['objects'][0]['content'][0]['buffer'];
|
||||||
var message = _.union(prefix, text);
|
text_elements = _.union(prefix, text);
|
||||||
message =_.map(message, function(message) {
|
text_elements =_.map(text_elements, function(text_element) {
|
||||||
if ('fg' in message) {
|
if ('fg' in text_element) {
|
||||||
message['fg'] = colors.prepareCss(message['fg']);
|
text_element['fg'] = colors.prepareCss(text_element['fg']);
|
||||||
}
|
}
|
||||||
return message;
|
// TODO: parse background as well
|
||||||
|
|
||||||
|
return text_element;
|
||||||
});
|
});
|
||||||
buffer_line['message'] = message;
|
return text_elements;
|
||||||
|
|
||||||
if (!_isActiveBuffer(buffer)) {
|
|
||||||
$rootScope.buffers[buffer]['notification'] = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var buffer = message['objects'][0]['content'][0]['buffer'];
|
||||||
|
var timestamp = message['objects'][0]['content'][0]['date'];
|
||||||
|
var text = colors.parse(message['objects'][0]['content'][0]['message']);
|
||||||
|
var content = parseLineAddedTextElements(message);
|
||||||
var additionalContent = pluginManager.contentForMessage(text[0]['text']);
|
var additionalContent = pluginManager.contentForMessage(text[0]['text']);
|
||||||
|
|
||||||
if (additionalContent) {
|
return {
|
||||||
buffer_line['metadata'] = additionalContent;
|
metadata: additionalContent,
|
||||||
|
content: content,
|
||||||
|
timestamp: timestamp,
|
||||||
|
buffer: buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
$rootScope.buffers[buffer]['lines'].push(buffer_line);
|
}
|
||||||
|
|
||||||
|
var handleBufferLineAdded = function(message) {
|
||||||
|
var buffer_line = {}
|
||||||
|
|
||||||
|
message = new BufferLine(message);
|
||||||
|
|
||||||
|
if (!_isActiveBuffer(message.buffer)) {
|
||||||
|
$rootScope.buffers[message.buffer]['notification'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rootScope.buffers[message.buffer]['lines'].push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue