<commit_before>/**
* Templates
*/
Meteor.subscribe('users');
Meteor.subscribe('messages');

Meteor.startup(function() {
	var notification = new Audio("http://freesound.org/data/previews/235/235911_2391840-lq.mp3");

	var startup = false;
	Messages.find().observe({
		added: function(record) {
			if (startup === true && record.userId !== Meteor.userId()) {
				notification.play();
			}
		}
	});

	setTimeout(function() {
		startup = true;
	}, 1000);

	Accounts.ui.config({
		passwordSignupFields: 'USERNAME_AND_OPTIONAL_EMAIL'
	});

	UserPresence.awayTime = 60000;
	UserPresence.awayOnWindowBlur = false;
	UserPresence.start();

	var messages = $('.messages');
	messages.scrollTop(messages.height());
});

UI.body.events({
	'click .statusDefault': function(e) {
		var status = e.target.innerHTML;
		if (status != Meteor.user().statusDefault) {
			Meteor.call('UserPresence:setDefaultStatus', status);
		}
	}
});

Template.registerHelper('getUserStatusDefault', function() {
	var user = Meteor.user();
	return (user && user.statusDefault) || 'online';
});

Template.registerHelper('getUserStatus', function(userId) {
	if (userId) {
		var user = Meteor.users.findOne({_id: userId});
	} else {
		var user = Meteor.user();
	}
	return user && user.status;
});

Template.registerHelper('logged', function(userId) {
	return Meteor.userId() != null;
});

Template.registerHelper('getUserName', function(userId) {
	if (userId === Meteor.userId()) {
		return 'me';
	};

	var user = Meteor.users.findOne({_id: userId});
	return user && user.username;
});

Template.registerHelper('getClassForSelfUser', function(userId) {
	return userId === Meteor.userId() ? 'self-user' : '';
});

Template.messages.helpers({
	messages: function() {
		return Messages.find({}, {sort: {time: 1}});
	}
});

Template.message.rendered = function() {
	var messages = $('.messages');
	messages.scrollTop($('.messages > table').height());
};

Template.users.helpers({
	users: function() {
		return Meteor.users.find({}, {sort: {username: 1}});
	}
});

Template.input.events = {
	'keydown input#input' : function (event) {
		if (event.which == 13) { // 13 is the enter key event
			if (Meteor.user()) {
				var userId = Meteor.user()._id;
			} else {
				var userId = '';
			}
			var input = document.getElementById('input');

			if (input.value != '') {
				Messages.insert({
					userId: userId,
					message: input.value,
					time: Date.now()
				});

				input.value = '';
			}
		}
	}
}
<commit_msg>Use new Date instead Date.now()<commit_after>/**
* Templates
*/
Meteor.subscribe('users');
Meteor.subscribe('messages');

Meteor.startup(function() {
	var notification = new Audio("http://freesound.org/data/previews/235/235911_2391840-lq.mp3");

	var startup = false;
	Messages.find().observe({
		added: function(record) {
			if (startup === true && record.userId !== Meteor.userId()) {
				notification.play();
			}
		}
	});

	setTimeout(function() {
		startup = true;
	}, 1000);

	Accounts.ui.config({
		passwordSignupFields: 'USERNAME_AND_OPTIONAL_EMAIL'
	});

	UserPresence.awayTime = 60000;
	UserPresence.awayOnWindowBlur = false;
	UserPresence.start();

	var messages = $('.messages');
	messages.scrollTop(messages.height());
});

UI.body.events({
	'click .statusDefault': function(e) {
		var status = e.target.innerHTML;
		if (status != Meteor.user().statusDefault) {
			Meteor.call('UserPresence:setDefaultStatus', status);
		}
	}
});

Template.registerHelper('getUserStatusDefault', function() {
	var user = Meteor.user();
	return (user && user.statusDefault) || 'online';
});

Template.registerHelper('getUserStatus', function(userId) {
	if (userId) {
		var user = Meteor.users.findOne({_id: userId});
	} else {
		var user = Meteor.user();
	}
	return user && user.status;
});

Template.registerHelper('logged', function(userId) {
	return Meteor.userId() != null;
});

Template.registerHelper('getUserName', function(userId) {
	if (userId === Meteor.userId()) {
		return 'me';
	};

	var user = Meteor.users.findOne({_id: userId});
	return user && user.username;
});

Template.registerHelper('getClassForSelfUser', function(userId) {
	return userId === Meteor.userId() ? 'self-user' : '';
});

Template.messages.helpers({
	messages: function() {
		return Messages.find({}, {sort: {time: 1}});
	}
});

Template.message.rendered = function() {
	var messages = $('.messages');
	messages.scrollTop($('.messages > table').height());
};

Template.users.helpers({
	users: function() {
		return Meteor.users.find({}, {sort: {username: 1}});
	}
});

Template.input.events = {
	'keydown input#input' : function (event) {
		if (event.which == 13) { // 13 is the enter key event
			if (Meteor.user()) {
				var userId = Meteor.user()._id;
			} else {
				var userId = '';
			}
			var input = document.getElementById('input');

			if (input.value != '') {
				Messages.insert({
					userId: userId,
					message: input.value,
					time: new Date()
				});

				input.value = '';
			}
		}
	}
}

{'fraction_non_alphanumeric': 0.18676885841064947, 'fraction_numerical': 0.01290843081887858, 'mean_word_length': 4.154885654885655, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3660004', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1694, 'n_words': 317}