<commit_before>//
// main js function:
//
// What it does:
// 1) Capture user interaction
// 2) send label to back-end (`flask_server.label()`)

function select_orientation(o){

	$('#orientation li').eq(0)
		.css("color", "black")
		.css("font-weight", "normal");
	$('#orientation li').eq(1)
		.css("color", "black")
		.css("font-weight", "normal");
	$('#orientation li').eq(2)
		.css("color", "black")
		.css("font-weight", "normal");
	$('#orientation li').eq(3)
		.css("color", "black")
		.css("font-weight", "normal");
	$('#orientation li').eq(o)
		.css("color", "red")
		.css("font-weight", "bold");
}

function select_document_type(doc_types, dt){

	$.each(doc_types, function(i){
		$('#document_type li').eq(i)
			.css("color", "black")
			.css("font-weight", "normal");
		
		if (doc_types[i] == dt){
			$('#document_type li').eq(i)
			.css("color", "red")
			.css("font-weight", "bold")
		}
	})
}

function select_bb(bbs_names, bb_idx){

	$.each(bbs_names, function(i){
		$('#bounding_box_colors li').eq(i)
			.css("color", "black")
			.css("font-weight", "normal");
		
		if (i == bb_idx){
			$('#bounding_box_colors li').eq(i)
				.css("color", "red")
			.	css("font-weight", "bold");
		}
	})
}



$(document).ready(function(){

	var images = {{ images }};
	var image_idx = 0;
	
	var bounding_boxes = [];
	var document_type = 0;
	var orientation = 0;
	var selected_bb = 0;

	var canvas = document.getElementById('ex_canvas');
    var ctx = canvas.getContext("2d");

	var doc_types = ['Notebook', 'Form', 'Receipt', 'Letter'];
	var orientations = ['Up', 'Right', 'Down', 'Left'];
	var bbs_names = ['Document', 
					 'Title', 
					 'Subtitle', 
					 'Text region', 
					 'List', 
					 'Table', 
					 'Drawing/diagram', 
					 'Formula', 
					 'Separation-line / Structure'];
	
	var bbs_colors = ['white', 
					  'orange', 
					  'pink', 
					  'red', 
					  'brown', 
					  'gray', 
					  'green', 
					  'yellow', 
					  'purple'];

	$.each(doc_types, function(i){

		var doc_type_legend = document.getElementById('document_type');
		var key_value = i+1;
		
		var li = $('<li/>')
			.attr("class", "btn btn-a btn-sm smooth")
			.css("background-color", 'white')
			.css("border", "3px solid black")
			.text(doc_types[i] + ' (key: ' + key_value + ')')
			.appendTo(doc_type_legend);
	})


	$.each(orientations, function(i){
		
		var orientation_legend = document.getElementById('orientation');
		var key_value = doc_types.length+i+1;	
		
		var li = $('<li/>')
			.attr("class", "btn btn-a btn-sm smooth")
			.css("background-color", 'white')
			.css("border", "3px solid black")
			.text(orientations[i] + ' (key: ' + key_value + ')')
			.css('margin-bottom', '1%')
			.appendTo(orientation_legend);
	})

	$.each(bbs_names, function(i){
		var bbs_legend = document.getElementById('bounding_box_colors');
<commit_msg>Make doc type and doc orientation buttons clickable.<commit_after>//
// main js function:
//
// What it does:
// 1) Capture user interaction
// 2) send label to back-end (`flask_server.label()`)

function select_orientation(o){

	$('#orientation li').eq(0)
		.css("color", "black")
		.css("font-weight", "normal");
	$('#orientation li').eq(1)
		.css("color", "black")
		.css("font-weight", "normal");
	$('#orientation li').eq(2)
		.css("color", "black")
		.css("font-weight", "normal");
	$('#orientation li').eq(3)
		.css("color", "black")
		.css("font-weight", "normal");
	$('#orientation li').eq(o)
		.css("color", "red")
		.css("font-weight", "bold");
}

function select_document_type(doc_types, dt){

	$.each(doc_types, function(i){
		$('#document_type li').eq(i)
			.css("color", "black")
			.css("font-weight", "normal");
		
		if (doc_types[i] == dt){
			$('#document_type li').eq(i)
			.css("color", "red")
			.css("font-weight", "bold")
		}
	})
}

function select_bb(bbs_names, bb_idx){

	$.each(bbs_names, function(i){
		$('#bounding_box_colors li').eq(i)
			.css("color", "black")
			.css("font-weight", "normal");
		
		if (i == bb_idx){
			$('#bounding_box_colors li').eq(i)
				.css("color", "red")
			.	css("font-weight", "bold");
		}
	})
}



$(document).ready(function(){

	var images = {{ images }};
	var image_idx = 0;
	
	var bounding_boxes = [];
	var document_type = 0;
	var orientation = 0;
	var selected_bb = 0;

	var canvas = document.getElementById('ex_canvas');
    var ctx = canvas.getContext("2d");

	var doc_types = ['Notebook', 'Form', 'Receipt', 'Letter'];
	var orientations = ['Up', 'Right', 'Down', 'Left'];
	var bbs_names = ['Document', 
					 'Title', 
					 'Subtitle', 
					 'Text region', 
					 'List', 
					 'Table', 
					 'Drawing/diagram', 
					 'Formula', 
					 'Separation-line / Structure'];
	
	var bbs_colors = ['white', 
					  'orange', 
					  'pink', 
					  'red', 
					  'brown', 
					  'gray', 
					  'green', 
					  'yellow', 
					  'purple'];

	$.each(doc_types, function(i){

		var doc_type_legend = document.getElementById('document_type');
		var key_value = i+1;
		
		var li = $('<li/>')
			.attr("class", "btn btn-a btn-sm smooth")
			.css("background-color", 'white')
			.css("border", "3px solid black")
			.text(doc_types[i] + ' (key: ' + key_value + ')')
			.appendTo(doc_type_legend);


		li.mousedown(function (e) {
			document_type = i;
			select_document_type(doc_types, doc_types[i]);
		});
	})


	$.each(orientations, function(i){
		
		var orientation_legend = document.getElementById('orientation');
		var key_value = doc_types.length+i+1;	
		
		var li = $('<li/>')
			.attr("class", "btn btn-a btn-sm smooth")
			.css("background-color", 'white')
			.css("border", "3px solid black")
			.text(orientations[i] + ' (key: ' + key_value + ')')
			.css('margin-bottom', '1%')
			.appendTo(orientation_legend);

		li.mousedown(function (e) {
			console.log('click on ' + bbs_names[i])
			orientation = i;
			select_orientation(orientation);
		});

	})

	$.each(bbs_names, function(i){
		var bbs_legend = document.getElementById('bounding_box_colors');

{'fraction_non_alphanumeric': 0.21502851392150285, 'fraction_numerical': 0.005367326400536733, 'mean_word_length': 3.44005956813105, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5987428', 'n_tokens_mistral': 2571, 'n_tokens_neox': 2150, 'n_words': 437}