<commit_before>$(function() {
	$('.event').click(function(){
		var id = $(this).attr('val');
		$('.subevent').addClass('hidden');
		$('.subevent-'+id).removeClass('hidden');
		$('.event').removeClass('active');
		$(this).addClass('active');
	});

	$('.save-event').click(function(){
		var name = $('.event-name').val();
		var text = $('.event-text').val();
		var hidden = $('.event-hidden').val();
		$.ajax({
  			url: "/api/create/",
  			type: "POST",
  			data: {'name': name, 'text': text, 'hidden': false, 'type': 'event'},
  			dataType: 'json',
  			success: function(data){
				var h = get_new_event_html(name, text, hidden, data.id);
				$('.event-div').append(h);
			},
		});
	});

	$('.delete-event').click(function(){
		var id = $(this).attr('val');
		var type = $(this).attr('type');
		$.ajax({
  			url: "/api/delete/",
  			type: "GET",
  			data: {'id': id, 'type': type},
  			dataType: 'json'
		});

		$(this).parent().remove();
	});
});

function get_new_event_html(name, text, hidden, id){
	var hidden_str = '';
	if (hidden) {
		hidden_str = 'list-group-item-warning';
	}

	var s = '<a href="#" class="list-group-item event' + hidden_str + ' val="{{event.id}}">';  
	s += name;
    s += '<button type="button" class="btn btn-default btn-xs pull-right delete-event" val="'+id+'">';
    s += '<span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>';
    s += '</button>';
    s += '</a>';
    return s;<commit_msg>delete works for new elements<commit_after>$(function() {
	$('.event').click(function(){
		var id = $(this).attr('val');
		$('.subevent').addClass('hidden');
		$('.subevent-'+id).removeClass('hidden');
		$('.event').removeClass('active');
		$(this).addClass('active');
	});

	$('.save-event').click(function(){
		var name = $('.event-name').val();
		var text = $('.event-text').val();
		var hidden = $('.event-hidden').val();
		$.ajax({
  			url: "/api/create/",
  			type: "POST",
  			data: {'name': name, 'text': text, 'hidden': false, 'type': 'event'},
  			dataType: 'json',
  			success: function(data){
				var h = get_new_event_html(name, text, hidden, data.id);
				$('.event-div').append(h);
			},
		});
	});
});


$(document).on("click",".delete-event", function(){
	var id = $(this).attr('val');
	var type = $(this).attr('type');
	$.ajax({
			url: "/api/delete/",
			type: "GET",
			data: {'id': id, 'type': type},
			dataType: 'json'
	});

	$(this).parent().remove();
});

function get_new_event_html(name, text, hidden, id){
	var hidden_str = '';
	if (hidden) {
		hidden_str = 'list-group-item-warning';
	}

	var s = '<a href="#" class="list-group-item event ' + hidden_str + ' val="{{event.id}}">';  
	s += name;
    s += '<button type="button" class="btn btn-default btn-xs pull-right delete-event" val="'+id+'">';
    s += '<span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>';
    s += '</button>';
    s += '</a>';
    return s;
{'fraction_non_alphanumeric': 0.2674897119341564, 'fraction_numerical': 0.0, 'mean_word_length': 3.6523125996810206, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '6581834', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1042, 'n_words': 214}