2013-10-08 00:43:09 +00:00
|
|
|
var models = angular.module('weechatModels', []);
|
2013-10-08 00:42:19 +00:00
|
|
|
|
2013-10-08 00:43:09 +00:00
|
|
|
models.factory('models', ['colors', function(colors) {
|
2013-10-08 00:42:19 +00:00
|
|
|
|
2013-10-08 00:43:09 +00:00
|
|
|
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
|
|
|
|
}
|
2013-10-08 00:42:19 +00:00
|
|
|
|
|
|
|
|
2013-10-08 00:43:09 +00:00
|
|
|
}]);
|