<commit_before>$(document).ready(function(){
	$("*[data-selectAjax]").select2();

	$("*[data-dateTimePicker]").each(function(){
		if (!$(this).val()) {
			if (typeof $(this).data('default') !== 'undefined') {
				try {
					$(this).datetimepicker({
						format:  'YYYY-MM-DD HH:mm:ss',
					});
				} catch(err) {
					console.log('Error on (() -> '+err);
				}
				
			}
		};
		try {
			$(this).datetimepicker({
				format:  'YYYY-MM-DD HH:mm:ss',
			});
		} catch(err) {
			console.log('Error on datetimepicker() -> '+err);
		}
		
	});

	$("*[data-datePicker]").each(function(){
		try {
			$(this).datetimepicker({
				format: 'YYYY-MM-DD',
			});
		} catch(err) {
			console.log('Error on datetimepicker() -> '+err);
		}
		
	});

	$("*[data-timePicker]").each(function(){
		try {
			$(this).datetimepicker({
				format:  'HH:mm:ss',
			});
		} catch(err) {
			console.log('Error on datetimepicker() -> '+err);
		}
	});

	$("*[data-moment]").each(function(){
		momentFromNow($(this));
	});

	$("*[data-nicescroll]").each(function(){
		try {
			$(this).niceScroll();
		} catch(err) {
			console.log('Error on niceScroll() -> '+err);
		}
	});

	$("*[data-repeat]").each(function(){
		appendRepeatButton($(this));
		appendRemoveButton($(this).data('name'));
	});

	$("*[data-group]").each(function(){
		groupButton($(this));
	});

	$(".repeatButton").click(function(){
		repeatElement($("[data-name='"+$(this).data("repeat-element")+"']:last"));
		return false;
	});

	$(".row-remove-key").click(function(){
		removeFormGroupRow($(this));
		return false;
	});

	$("[data-group-add]").click(function(){
		groupAdd($(this));
	});

	$("[data-group-remove]").click(function(){
		groupRemove($(this));
	});

});

function momentFromNow(element)
{
	time = element.data('moment');
	fromNow = moment(time).fromNow();
	element.html(fromNow);
}

// @todo
function conditionalApi()
{
}

function removeFormGroupRow(element)
{
	element.closest('.form-group').remove();
}

function appendRepeatButton(element)
{
	element.after('<button data-repeat-element="'+element.data('name')+'" class="btn btn-labeled btn-success repeatButton"><span class="btn-label fa fa-plus"></span>Add More</button>');
}

function appendRemoveButton(name)
{
	placeholder = name+'[placeholder]';
	$("[name*='"+name+"']").each(function(){
		if(typeof $(this).attr('data-hidden-placeholder') == 'undefined') {
			$('<span class="row-remove-key fa-times"></span>').appendTo($(this).closest(".row"));
		}
	});

}

function repeatElement(element)
{
	append = element.clone().find(':input').each(function() {
		this.name = this.name.replace(/\[(\d+)\]/, function(str,p1) {
			return '[' + (parseInt(p1,10)+1) + ']';
		});
		this.id = this.name;
		this.value = "";

		if(typeof($(this).data("old")) !== 'undefined') {
			$(this).data("old", "");
		}

	}).end();

	append.find('.select2-container').remove();
	append.find('.not-in-repeat').remove();
	append.find('.link-to-relation').attr('href', '').addClass('disabled').removeClass('link-to-relation');

	append.find("[data-selectAjax]").select2();

	element.after(append);

	append.find(".row-remove-key").each(function(){
		$(this).click(function() {
			removeFormGroupRow($(this));
		});
	});

	return false;
}

function groupButton(field)
{
	field.after('<span data-group-add style="cursor: pointer; position: absolute; top: 3px; color: green; right: 20px; background-color: #eee; width: 15px; height: 15px; font-size: 15px; text-align: center;">+</span>');
	field.after('<span data-group-remove style="cursor: pointer; position: absolute; top: 19px; color: red; right: 20px; background-color: #eee; width: 15px; height: 15px; font-size: 15px; text-align: center;">-</span>');
}
<commit_msg>Clean scripts.js<commit_after>$(document).ready(function(){
	$("*[data-selectAjax]").select2();

	$("*[data-dateTimePicker]").each(function(){
		if (!$(this).val()) {
			if (typeof $(this).data('default') !== 'undefined') {
				try {
					$(this).datetimepicker({
						format:  'YYYY-MM-DD HH:mm:ss',
					});
				} catch(err) {
					console.log('Error on (() -> '+err);
				}
			}
		};
		try {
			$(this).datetimepicker({
				format:  'YYYY-MM-DD HH:mm:ss',
			});
		} catch(err) {
			console.log('Error on datetimepicker() -> '+err);
		}
	});

	$("*[data-datePicker]").each(function(){
		try {
			$(this).datetimepicker({
				format: 'YYYY-MM-DD',
			});
		} catch(err) {
			console.log('Error on datetimepicker() -> '+err);
		}
		
	});

	$("*[data-timePicker]").each(function(){
		try {
			$(this).datetimepicker({
				format:  'HH:mm:ss',
			});
		} catch(err) {
			console.log('Error on datetimepicker() -> '+err);
		}
	});

	$("*[data-moment]").each(function(){
		momentFromNow($(this));
	});

	$("*[data-nicescroll]").each(function(){
		try {
			$(this).niceScroll();
		} catch(err) {
			console.log('Error on niceScroll() -> '+err);
		}
	});

	$("*[data-repeat]").each(function(){
		appendRepeatButton($(this));
		appendRemoveButton($(this).data('name'));
	});

	$("*[data-group]").each(function(){
		groupButton($(this));
	});

	$(".repeatButton").click(function(){
		repeatElement($("[data-name='"+$(this).data("repeat-element")+"']:last"));
		return false;
	});

	$(".row-remove-key").click(function(){
		removeFormGroupRow($(this));
		return false;
	});

	$("[data-group-add]").click(function(){
		groupAdd($(this));
	});

	$("[data-group-remove]").click(function(){
		groupRemove($(this));
	});

});

function momentFromNow(element)
{
	time = element.data('moment');
	fromNow = moment(time).fromNow();
	element.html(fromNow);
}

// @todo
function conditionalApi()
{
}

function removeFormGroupRow(element)
{
	element.closest('.form-group').remove();
}

function appendRepeatButton(element)
{
	element.after('<button data-repeat-element="'+element.data('name')+'" class="btn btn-labeled btn-success repeatButton"><span class="btn-label fa fa-plus"></span>Add More</button>');
}

function appendRemoveButton(name)
{
	placeholder = name+'[placeholder]';
	$("[name*='"+name+"']").each(function(){
		if(typeof $(this).attr('data-hidden-placeholder') == 'undefined') {
			$('<span class="row-remove-key fa-times"></span>').appendTo($(this).closest(".row"));
		}
	});
}

function repeatElement(element)
{
	append = element.clone().find(':input').each(function() {
		this.name = this.name.replace(/\[(\d+)\]/, function(str,p1) {
			return '[' + (parseInt(p1,10)+1) + ']';
		});

		this.id = this.name;
		this.value = "";

		if(typeof($(this).data("old")) !== 'undefined') {
			$(this).data("old", "");
		}

	}).end();

	append.find('.select2-container').remove();
	append.find('.not-in-repeat').remove();
	append.find('.link-to-relation').attr('href', '').addClass('disabled').removeClass('link-to-relation');
	append.find("[data-selectAjax]").select2();

	element.after(append);

	append.find(".row-remove-key").each(function(){
		$(this).click(function() {
			removeFormGroupRow($(this));
		});
	});

	return false;
}

function groupButton(field)
{
	field.after('<span data-group-add style="cursor: pointer; position: absolute; top: 3px; color: green; right: 20px; background-color: #eee; width: 15px; height: 15px; font-size: 15px; text-align: center;">+</span>');
	field.after('<span data-group-remove style="cursor: pointer; position: absolute; top: 19px; color: red; right: 20px; background-color: #eee; width: 15px; height: 15px; font-size: 15px; text-align: center;">-</span>');
}

{'fraction_non_alphanumeric': 0.2524337479718767, 'fraction_numerical': 0.007301243915630071, 'mean_word_length': 4.578431372549019, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 33, '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': '3432718', 'n_tokens_mistral': 2917, 'n_tokens_neox': 2616, 'n_words': 369}