parent
c538d759b8
commit
ebecc5faae
@ -1,7 +1,47 @@ |
||||
var models = angular.module('weechat-models'); |
||||
var models = angular.module('weechatModels', []); |
||||
|
||||
models.factory('models', function() { |
||||
models.factory('models', ['colors', function(colors) { |
||||
|
||||
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 buffer = message['objects'][0]['content'][0]['buffer']; |
||||
text_elements = _.union(prefix, text); |
||||
text_elements =_.map(text_elements, function(text_element) { |
||||
if ('fg' in text_element) { |
||||
text_element['fg'] = colors.prepareCss(text_element['fg']); |
||||
} |
||||
// TODO: parse background as well
|
||||
|
||||
return text_element; |
||||
}); |
||||
return text_elements; |
||||
} |
||||
|
||||
|
||||
var buffer = message['objects'][0]['content'][0]['buffer']; |
||||
var date = message['objects'][0]['content'][0]['date']; |
||||
var text = colors.parse(message['objects'][0]['content'][0]['message']); |
||||
var content = parseLineAddedTextElements(message); |
||||
|
||||
return { |
||||
content: content, |
||||
date: date, |
||||
buffer: buffer, |
||||
text: text[0]['text'], |
||||
} |
||||
|
||||
} |
||||
|
||||
return { |
||||
BufferLine: BufferLine |
||||
} |
||||
|
||||
|
||||
}); |
||||
}]); |
||||
|
Loading…
Reference in new issue