<commit_before>$(document).ready(function() {

$('#add_hike').hide();
$('#edit_hike').hide();

function get_hikes() {
	var url = "inc/call_db.inc.php?view=admin_list";
	$.ajax({
		method: "GET",
		url: url,
		dataType: 'json'
	}).done(function(data) {
		for (var i=0; i < data.rows.length; i++) {
			var lat = data.rows[i].key.lat;
			var lng = data.rows[i].key.lng;
			var hike_id = data.rows[i].id;
			var rev = data.rows[i].value.rev;

			var output = "<section class=\"admin_list_item\">";
			output += "<h3>" + data.rows[i].value.name + "</h3>";
			output += "<h4> Area: </h4>" + data.rows[i].value.area;
			output += "<h4> Date: </h4>" + data.rows[i].value.date;
			output += "<button class=\"edit\">Edit</button>";
			output += "<button class=\"delete\">Delete</button>";
			output += "</section>";
			$('#hike_list').append(output);
			add_handlers(lat, lng, hike_id, rev);
		} //end for

		function add_handlers(lat, lng, hike_id, rev) {
			var edit_button = $('#hike_list section:last-of-type .edit');
			var delete_button = $('#hike_list section:last-of-type .delete');

			$(edit_button).click(function() {
				$('#edit_hike').show();
				edit_hike(lat, lng, hike_id);
			});

			$(delete_button).click(function() {
				delete_hike(hike_id, rev);
			});
		}
	})
}

function delete_hike(hike_id, rev) {
	var url = "inc/delete_hike.inc.php";

	$.ajax({
		method: "POST",
		url: url,
		data: {id: hike_id, rev: rev}
	}).done(function(data){
		console.log(data);
	});
}

function edit_hike(lat, lng, hike_id) {
	var url = "inc/call_db.inc.php?view=full_hike_info&lat=" + lat + "&lng=" + lng;
	$.ajax({
		method: "GET",
		url: url,
		dataType: 'json'
	}).done(function(data) {
		var hike_id = data.rows[0].id;<commit_msg>Added deletion confirmation<commit_after>$(document).ready(function() {

$('#add_hike').hide();
$('#edit_hike').hide();

function get_hikes() {
	var url = "inc/call_db.inc.php?view=admin_list";
	$.ajax({
		method: "GET",
		url: url,
		dataType: 'json'
	}).done(function(data) {
		for (var i=0; i < data.rows.length; i++) {
			var lat = data.rows[i].key.lat;
			var lng = data.rows[i].key.lng;
			var hike_id = data.rows[i].id;
			var rev = data.rows[i].value.rev;

			var output = "<section class=\"admin_list_item\">";
			output += "<h3>" + data.rows[i].value.name + "</h3>";
			output += "<h4> Area: </h4>" + data.rows[i].value.area;
			output += "<h4> Date: </h4>" + data.rows[i].value.date;
			output += "<button class=\"edit\">Edit</button>";
			output += "<button class=\"delete\">Delete</button>";
			output += "</section>";
			$('#hike_list').append(output);
			add_handlers(lat, lng, hike_id, rev);
		} //end for

		function add_handlers(lat, lng, hike_id, rev) {
			var edit_button = $('#hike_list section:last-of-type .edit');
			var delete_button = $('#hike_list section:last-of-type .delete');

			$(edit_button).click(function() {
				$('#edit_hike').show();
				edit_hike(lat, lng, hike_id);
			});

			$(delete_button).click(function() {
				var delete_ok = confirm("Are you sure you want to delete this hike?");
				if (delete_ok == true) {
					delete_hike(hike_id, rev);
				}
			});
		}
	})
}

function delete_hike(hike_id, rev) {
	var url = "inc/delete_hike.inc.php";

	$.ajax({
		method: "POST",
		url: url,
		data: {id: hike_id, rev: rev}
	}).done(function(data){
		console.log(data);
	});
}

function edit_hike(lat, lng, hike_id) {
	var url = "inc/call_db.inc.php?view=full_hike_info&lat=" + lat + "&lng=" + lng;
	$.ajax({
		method: "GET",
		url: url,
		dataType: 'json'
	}).done(function(data) {
		var hike_id = data.rows[0].id;
{'fraction_non_alphanumeric': 0.22032951689472213, 'fraction_numerical': 0.004468025691147724, 'mean_word_length': 3.7887700534759357, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 27, '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': '6831569', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1413, 'n_words': 273}