<commit_before>function Dialog (dialog_obj) {
	var VK = 'https://vk.com/';
			
	this.init = function(dialog_obj){
		for (var p in dialog_obj) {
			if (p !== 'message') {
				this[p] = dialog_obj[p];
			}
		}

		this.messages = [];
		this.isGroup  = this.chat_id !== undefined;

		if (this.isGroup) {
			this.id = this.chat_id;
			this.url = VK + 'im?sel=c' + this.id;
		} else {
			this.id = this.user_id;
			this.url = VK + 'im?sel=' + this.id;
		}
		if(dialog_obj.message.length === 0) {
			this.addMess(dialog_obj);
		} else {
			this.addMess(dialog_obj.message);
		}
	};

	this.addMess = function(mess_array){
		if (mess_array.length === undefined) {
			mess_array = [mess_array];
		}
		for (var i = mess_array.length; i--;) {
			// Добавляем сообщение к диалогу
			this.messages.push(new Message(mess_array[i], this));
		};
		// Сортируем
		this.messages.sort(function (mess_first, mess_second) {
			return mess_second.date - mess_first.date;
		});

		return true;
	};

	
	this.addHeader = function (options) {
		options = jQuery.extend({
			class: '',
			photo: '',
			title: window.pop.geti18n('attr.chat'),
			messages: ''
		}, options);
		return '<div class="header ' + options.class + '">' + options.photo + '<span class="name">' + options.title + '</span><span class="mess-container">' + options.messages + '</span></div>';
	};

	this.getHtml = function () {
		var html = '', i;
		if (!this.isGroup) {
			for (i = this.messages.length; i--;) {
				if (this.messages[i].out === 0) {
					html += this.messages[i].getHtml();
				} else {
					this.messages[i].from_id = window.pop.current.id;
					html += this.messages[i].getHtml('compact');
				}
			}
			var author = window.pop.profiles[this.id];
			return this.addHeader({
				class: author.online === 1 ? 'online' : '',
				photo: author.ava({size: 50}),
				title: author.name,
				messages: html
			});
		} else {
			for (i = this.messages.length; i--;) {
				if (this.messages[i+1] == undefined || this.messages[i].from_id != this.messages[i+1].from_id) {
					html += this.messages[i].getHtml('compact');
				} else {
					html += this.messages[i].getHtml();
				}
			}
			return this.addHeader({
				class: 'group',
				photo: this.getGroupPhoto(),
				title: this.title,
				messages: html
			});
		};
	};

	this.getGroupPhoto = function () {
		// var group_photo = '';
		if (this.chat_active === undefined) {
			this.chat_active = [ this.from_id ];
		}
		if (this.chat_active.length > 4) {
			this.chat_active = this.chat_active.slice(0,4);
		}
		switch (this.chat_active.length) {
			case 1 : return '<div class="ava group-photo">' + window.pop.profiles[this.chat_active[0]].ava({size:50}) + '</div>'; break;
			case 2 : return '<div class="ava group-photo"><div class="ava-half">' + window.pop.profiles[this.chat_active[0]].ava({size:50}) + '</div><div class="ava-half">' + window.pop.profiles[this.chat_active[1]].ava({size:50}) + '</div></div>'; break;<commit_msg>Исправлен баг с груповыми фото<commit_after>function Dialog (dialog_obj) {
	var VK = 'https://vk.com/';
			
	this.init = function(dialog_obj){
		for (var p in dialog_obj) {
			if (p !== 'message') {
				this[p] = dialog_obj[p];
			}
		}

		this.messages = [];
		this.isGroup  = this.chat_id !== undefined;

		if (this.isGroup) {
			this.id = this.chat_id;
			this.url = VK + 'im?sel=c' + this.id;
		} else {
			this.id = this.user_id;
			this.url = VK + 'im?sel=' + this.id;
		}
		if(dialog_obj.message.length === 0) {
			this.addMess(dialog_obj);
		} else {
			this.addMess(dialog_obj.message);
		}
	};

	this.addMess = function(mess_array){
		if (mess_array.length === undefined) {
			mess_array = [mess_array];
		}
		for (var i = mess_array.length; i--;) {
			// Добавляем сообщение к диалогу
			this.messages.push(new Message(mess_array[i], this));
		};
		// Сортируем
		this.messages.sort(function (mess_first, mess_second) {
			return mess_second.date - mess_first.date;
		});

		return true;
	};

	
	this.addHeader = function (options) {
		options = jQuery.extend({
			class: '',
			photo: '',
			title: window.pop.geti18n('attr.chat'),
			messages: ''
		}, options);
		return '<div class="header ' + options.class + '">' + options.photo + '<span class="name">' + options.title + '</span><span class="mess-container">' + options.messages + '</span></div>';
	};

	this.getHtml = function () {
		var html = '', i;
		if (!this.isGroup) {
			for (i = this.messages.length; i--;) {
				if (this.messages[i].out === 0) {
					html += this.messages[i].getHtml();
				} else {
					this.messages[i].from_id = window.pop.current.id;
					html += this.messages[i].getHtml('compact');
				}
			}
			var author = window.pop.profiles[this.id];
			return this.addHeader({
				class: author.online === 1 ? 'online' : '',
				photo: author.ava({size: 50}),
				title: author.name,
				messages: html
			});
		} else {
			for (i = this.messages.length; i--;) {
				if (this.messages[i+1] == undefined || this.messages[i].from_id != this.messages[i+1].from_id) {
					html += this.messages[i].getHtml('compact');
				} else {
					html += this.messages[i].getHtml();
				}
			}
			return this.addHeader({
				class: 'group',
				photo: this.getGroupPhoto(),
				title: this.title,
				messages: html
			});
		};
	};

	this.getGroupPhoto = function () {
		if (this.photo_50) {
			return '<div class="ava group-photo"><img src="' + this.photo_50 + '"></div>';
		}
		if (this.chat_active === undefined) {
			this.chat_active = [ this.from_id ];
		}

		this.chat_active = this.chat_active.slice(0,4);
		
		switch (this.chat_active.length) {
			case 1 : return '<div class="ava group-photo">' + window.pop.profiles[this.chat_active[0]].ava({size:50}) + '</div>'; break;
			case 2 : return '<div class="ava group-photo"><div class="ava-half">' + window.pop.profiles[this.chat_active[0]].ava({size:50}) + '</div><div class="ava-half">' + window.pop.profiles[this.chat_active[1]].ava({size:50}) + '</div></div>'; break;
{'fraction_non_alphanumeric': 0.19700286243475332, 'fraction_numerical': 0.00825054723017343, 'mean_word_length': 3.197879858657244, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 35, 'https://': 2, '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': '4353227', 'n_tokens_mistral': 2550, 'n_tokens_neox': 2170, 'n_words': 393}