Use dot notation in models
This commit is contained in:
parent
09616a34c4
commit
cbf6bd9920
1 changed files with 27 additions and 27 deletions
54
js/models.js
54
js/models.js
|
@ -10,12 +10,12 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
*/
|
*/
|
||||||
this.Buffer = function(message) {
|
this.Buffer = function(message) {
|
||||||
// weechat properties
|
// weechat properties
|
||||||
var fullName = message['full_name']
|
var fullName = message.full_name
|
||||||
var shortName = message['short_name']
|
var shortName = message.short_name
|
||||||
var title = message['title']
|
var title = message.title
|
||||||
var number = message['number']
|
var number = message.number
|
||||||
var pointer = message['pointers'][0]
|
var pointer = message.pointers[0]
|
||||||
var local_variables = message['local_vars'];
|
var local_variables = message.local_vars;
|
||||||
var notify = 3 // Default 3 == message
|
var notify = 3 // Default 3 == message
|
||||||
var lines = []
|
var lines = []
|
||||||
var nicklist = {}
|
var nicklist = {}
|
||||||
|
@ -38,8 +38,8 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buffer opened message does not include notify level
|
// Buffer opened message does not include notify level
|
||||||
if( message['notify'] != undefined ) {
|
if( message.notify != undefined ) {
|
||||||
notify = message['notify'];
|
notify = message.notify;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -186,8 +186,8 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
* BufferLine class
|
* BufferLine class
|
||||||
*/
|
*/
|
||||||
this.BufferLine = function(message) {
|
this.BufferLine = function(message) {
|
||||||
var buffer = message['buffer'];
|
var buffer = message.buffer;
|
||||||
var date = message['date'];
|
var date = message.date;
|
||||||
var shortTime = $filter('date')(date, 'HH:mm');
|
var shortTime = $filter('date')(date, 'HH:mm');
|
||||||
|
|
||||||
function addClasses(textElements) {
|
function addClasses(textElements) {
|
||||||
|
@ -228,13 +228,13 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var prefix = weeChat.Protocol.rawText2Rich(message['prefix']);
|
var prefix = weeChat.Protocol.rawText2Rich(message.prefix);
|
||||||
addClasses(prefix);
|
addClasses(prefix);
|
||||||
|
|
||||||
var tags_array = message['tags_array'];
|
var tags_array = message.tags_array;
|
||||||
var displayed = message['displayed'];
|
var displayed = message.displayed;
|
||||||
var highlight = message['highlight'];
|
var highlight = message.highlight;
|
||||||
var content = weeChat.Protocol.rawText2Rich(message['message']);
|
var content = weeChat.Protocol.rawText2Rich(message.message);
|
||||||
addClasses(content);
|
addClasses(content);
|
||||||
|
|
||||||
if (highlight) {
|
if (highlight) {
|
||||||
|
@ -245,7 +245,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
|
|
||||||
var rtext = "";
|
var rtext = "";
|
||||||
if(content[0] != undefined) {
|
if(content[0] != undefined) {
|
||||||
rtext = content[0]['text'];
|
rtext = content[0].text;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -304,9 +304,9 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
* Nick class
|
* Nick class
|
||||||
*/
|
*/
|
||||||
this.Nick = function(message) {
|
this.Nick = function(message) {
|
||||||
var prefix = message['prefix'];
|
var prefix = message.prefix;
|
||||||
var visible = message['visible'];
|
var visible = message.visible;
|
||||||
var name = message['name'];
|
var name = message.name;
|
||||||
var colorClasses = nickGetClasses(message);
|
var colorClasses = nickGetClasses(message);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -321,8 +321,8 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
* Nicklist Group class
|
* Nicklist Group class
|
||||||
*/
|
*/
|
||||||
this.NickGroup = function(message) {
|
this.NickGroup = function(message) {
|
||||||
var name = message['name'];
|
var name = message.name;
|
||||||
var visible = message['visible'];
|
var visible = message.visible;
|
||||||
var nicks = [];
|
var nicks = [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -388,7 +388,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
|
|
||||||
var previousBuffer = this.getActiveBuffer();
|
var previousBuffer = this.getActiveBuffer();
|
||||||
|
|
||||||
activeBuffer = _.find(this.model['buffers'], function(buffer) {
|
activeBuffer = _.find(this.model.buffers, function(buffer) {
|
||||||
if (buffer[key] == bufferId) {
|
if (buffer[key] == bufferId) {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -430,8 +430,8 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
* @return the buffer object
|
* @return the buffer object
|
||||||
*/
|
*/
|
||||||
this.getBuffer = function(bufferId) {
|
this.getBuffer = function(bufferId) {
|
||||||
return _.find(this.model['buffers'], function(buffer) {
|
return _.find(this.model.buffers, function(buffer) {
|
||||||
if (buffer['id'] == bufferId) {
|
if (buffer.id == bufferId) {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -445,11 +445,11 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
* @return undefined
|
* @return undefined
|
||||||
*/
|
*/
|
||||||
this.closeBuffer = function(bufferId) {
|
this.closeBuffer = function(bufferId) {
|
||||||
var wasActive = this.model['buffers'][bufferId.id].active;
|
var wasActive = this.model.buffers[bufferId.id].active;
|
||||||
if(wasActive) {
|
if(wasActive) {
|
||||||
var firstBuffer = _.keys(this.model['buffers'])[0];
|
var firstBuffer = _.keys(this.model.buffers)[0];
|
||||||
this.setActiveBuffer(firstBuffer);
|
this.setActiveBuffer(firstBuffer);
|
||||||
}
|
}
|
||||||
delete(this.model['buffers'][bufferId.id]);
|
delete(this.model.buffers[bufferId.id]);
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
Loading…
Reference in a new issue