<commit_before>/* global Backbone */
var models = {};

models.Attachment = Backbone.Model.extend({

	initialize: function () {
		this.set('id', _.uniqueId());

		var s = this.get('fileName');
		if(s.charAt(0) === '/') {
			s = s.substr(1);
		}

		this.set('displayName',s);
	}
});

models.Attachments = Backbone.Collection.extend({
	model: models.Attachment
});

models.MessageFlags = Backbone.Model.extend({
	defaults: {
		answered: false
	}
});

models.Message = Backbone.Model.extend({
	defaults: {
		flags: [],
		active: false
	},

	initialize: function() {
		this.set('flags', new models.MessageFlags(this.get('flags')));
		this.listenTo(this.get('flags'), 'change', this._transformEvent);
	},

	_transformEvent: function() {
		this.trigger('change');
		this.trigger('change:flags', this);
	},

	toJSON: function() {
		var data = Backbone.Model.prototype.toJSON.call(this);
		if (data.flags && data.flags.toJSON) {
			data.flags = data.flags.toJSON();
		}
		if (!data.id) {
			data.id = this.cid;
		}
		return data;
	}
});

models.MessageList = Backbone.Collection.extend({
	model: models.Message
});

models.Folder = Backbone.Model.extend({
	defaults: {
		open: false
	},

	toggleOpen: function() {
		this.set({open: !this.get('open')});
	}
});

models.FolderList = Backbone.Collection.extend({
	model: models.Folder
});

models.Account = Backbone.Model.extend({
	defaults: {
		folders: []
	},

	initialize: function() {
		this.set('folders', new models.FolderList(this.get('folders')));
	},

	toJSON: function() {
		var data = Backbone.Model.prototype.toJSON.call(this);<commit_msg>new messages are now inserted in the right place<commit_after>/* global Backbone */
var models = {};

models.Attachment = Backbone.Model.extend({

	initialize: function () {
		this.set('id', _.uniqueId());

		var s = this.get('fileName');
		if(s.charAt(0) === '/') {
			s = s.substr(1);
		}

		this.set('displayName',s);
	}
});

models.Attachments = Backbone.Collection.extend({
	model: models.Attachment
});

models.MessageFlags = Backbone.Model.extend({
	defaults: {
		answered: false
	}
});

models.Message = Backbone.Model.extend({
	defaults: {
		flags: [],
		active: false
	},

	initialize: function() {
		this.set('flags', new models.MessageFlags(this.get('flags')));
		this.listenTo(this.get('flags'), 'change', this._transformEvent);
	},

	_transformEvent: function() {
		this.trigger('change');
		this.trigger('change:flags', this);
	},

	toJSON: function() {
		var data = Backbone.Model.prototype.toJSON.call(this);
		if (data.flags && data.flags.toJSON) {
			data.flags = data.flags.toJSON();
		}
		if (!data.id) {
			data.id = this.cid;
		}
		return data;
	}
});

models.MessageList = Backbone.Collection.extend({
	model: models.Message,

	comparator: function(message) {
		return message.get("dateInt") * -1;
	}
});

models.Folder = Backbone.Model.extend({
	defaults: {
		open: false
	},

	toggleOpen: function() {
		this.set({open: !this.get('open')});
	}
});

models.FolderList = Backbone.Collection.extend({
	model: models.Folder
});

models.Account = Backbone.Model.extend({
	defaults: {
		folders: []
	},

	initialize: function() {
		this.set('folders', new models.FolderList(this.get('folders')));
	},

	toJSON: function() {
		var data = Backbone.Model.prototype.toJSON.call(this);
{'fraction_non_alphanumeric': 0.18911523259349347, 'fraction_numerical': 0.0015202189115232593, 'mean_word_length': 4.0928792569659445, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3358987', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1151, 'n_words': 198}