<commit_before>
/******************** list init *******************************/
/*
	new init method
	
	collect all possible urls -> either default listUrl or attr "listUrl" in search inpout text field
	 to make a new list possible -> add listUrl attribute to search input text field in boxes page!
	 default listUrl in template can also be "", then we scan for search input text filed with set url, otherwise we initialize
	 the text fields with genericCreateAutocompleteWithoutList!
 */

var map_autocomplete_instance = null;
var minLengthTypeAhead = 3;

var isSuccess = false;

/** init the lists for selecting problems, diagnoses etc.*/
$(function() {
	function log( message ) {
		$( "<div>" ).text( message ).prependTo( "#log" );
		$( "#log" ).scrollTop( 0 );
	}
	
	/* collect all possible urls */
	var my_listUrl = listUrl; // should be listUrl
	var inputUrls = new Array();
	inputUrls[my_listUrl] =  new Array();
	$(".search input.f_text").each(function(index, value) {
  		var my_id = $(this).attr("id");
    	var my_url = $(this).attr("listUrl");
    	if (my_url) {
			if (!inputUrls[my_url]) {
				inputUrls[my_url] = new Array();
			}
			inputUrls[my_url].push(my_id);
		}
		else {
			inputUrls[my_listUrl].push(my_id);
		}
	});
	
	/* no loop over all urls and the assigned list of ids (search input text fields for autocomplete */
	for (var key in inputUrls) {
		loadListAndAssign(key,inputUrls[key]);
	}
	 
	/*$.ajax({ //list for problems (list view)
		url: listUrl, // url: listNursingUrl,
		dataType: "json",
		success: function( data ) {
			genericCreateAutocomplete("problems", data);
			genericCreateAutocomplete("ddx", data);
			genericCreateAutocomplete("tests", data);
			genericCreateAutocomplete("patho", data, 6, false);
			genericCreateAutocomplete("mng", data);
			genericCreateAutocomplete("nddx", data);
			genericCreateAutocomplete("nmng", data);
			genericCreateAutocomplete("info", data);
			genericCreateAutocomplete("naim", data);
			genericCreateAutocomplete("act_search");
			genericCreateAutocomplete("ctxt_search");
		}
	});
	
	genericCreateAutocompleteWithoutList("problems", listUrl);
	genericCreateAutocompleteWithoutList("patho", listUrl);
	genericCreateAutocompleteWithoutList("ddx", listUrl);
	genericCreateAutocompleteWithoutList("tests", listUrl);
	genericCreateAutocompleteWithoutList("mng", listUrl);
	genericCreateAutocompleteWithoutList("act_search",listUrl);
	genericCreateAutocompleteWithoutList("ctxt_search", listUrl);
	*/
});

var exact_item_label = "";
var exact_item_value = "";

/**
	key = url or empty
	list of id of seach input text field
	go thru and init autocomplete
 */
function loadListAndAssign(key, list) {
	if (key && key != "" && key != "#") {
		$.ajax({ //list for problems (list view)
			url: key, // url: listNursingUrl,
			dataType: "json",
			success: function( data ) {
				for (let i = 0; i < list.length; i++) {
					loop = list[i];
					console.log("list.js: " + key + " -> " + loop);
					genericCreateAutocomplete(loop, data);
				}
			},
			error: function (jqXHR) {
    			for (let i = 0; i < list.length; i++) {
					loop = list[i];
					console.log("list.js: " + key + " -> " + loop);
					genericCreateAutocompleteWithoutList(loop, key);
				}
			}
		});
	}
	else {
		for (let i = 0; i < list.length; i++) {
			loop = list[i];
			console.log("list.js: " + key + " -> " + loop);
			genericCreateAutocompleteWithoutList(loop, key);
		}
	}
}

/**
	add item by id -> uses either specific add<> method or generic addItem
 */
function genericAddItem(ui, id) {
	// choose correct add??? function by id!
	if (id=="problems") { 	addProblem(ui.item.value, ui.item.label, $("#" + id).val());}
	else if (id=="ddx") { 	addDiagnosis(ui.item.value, ui.item.label, $("#" + id).val()); }
	else if (id=="tests") { addTest(ui.item.value, ui.item.label, $("#" + id).val()); }
	else if (id=="patho") { addPatho(ui.item.value, ui.item.label, $("#" + id).val()); }
	else if (id=="mng") { 	addManagement(ui.item.value, ui.item.label, $("#" + id).val()); }
	else if (id=="nddx") { 	addItem(ui.item.value, ui.item.label,  $("#" + id).val(), "Nddx"); }
	else if (id=="nmng") { 	addItem(ui.item.value, ui.item.label,  $("#" + id).val(), "Mmng"); }
	else if (id=="info") { 	addItem(ui.item.value, ui.item.label,  $("#" + id).val(), "Info"); }
	else if (id=="naim") { 	addItem(ui.item.value, ui.item.label,  $("#" + id).val(), "Naim"); }
	else if (id=="act_search") { addActor(ui.item.value, ui.item.label,  $("#" + id).val()); }
	else if (id=="ctxt_search") { addContext(ui.item.value, ui.item.label,  $("#" + id).val()); }
}

/**
	init search input text filed with empty list
 */
function genericCreateAutocompleteWithoutList(in_id, in_listUrl) {
	// lookup parameters by id!
	if (typeof in_id !== 'string') {
		in_id = "" + in_id;
	}
	var in_bind = "enter" + ((in_id && in_id.length>0) ? in_id.charAt(0).toUpperCase() + in_id.slice(1) : in_id);
	if (in_id=="problems") 	{ in_bind = "enterProb"; }
	else if (in_id=="ddx") 	{ in_bind = "enterDDX"; }
	else if (in_id=="tests") {in_bind = "enterTest"; }
	else if (in_id=="patho") {in_bind = "enterPatho"; }
	else if (in_id=="mng") { in_bind = "enterMng"; }
	else if (in_id=="nddx") {}
	else if (in_id=="nmng") {}
	else if (in_id=="info") {}
	else if (in_id=="naim") {}
	else if (in_id=="act_search") { in_bind = "enterActor";}
	else if (in_id=="ctxt_search") { in_bind = "enterContext"; }
	
	$("#" + in_id).bind(in_bind, function(e) {
		addContext(-999, "-999", $("#" + in_id).val());	 
    });
    
    $("#" + in_id).keyup(function(e){<commit_msg>modified genericCreateAutocompleteWithoutList bind event name<commit_after>
/******************** list init *******************************/
/*
	new init method
	
	collect all possible urls -> either default listUrl or attr "listUrl" in search inpout text field
	 to make a new list possible -> add listUrl attribute to search input text field in boxes page!
	 default listUrl in template can also be "", then we scan for search input text filed with set url, otherwise we initialize
	 the text fields with genericCreateAutocompleteWithoutList!
 */

var map_autocomplete_instance = null;
var minLengthTypeAhead = 3;

var isSuccess = false;

/** init the lists for selecting problems, diagnoses etc.*/
$(function() {
	function log( message ) {
		$( "<div>" ).text( message ).prependTo( "#log" );
		$( "#log" ).scrollTop( 0 );
	}
	
	/* collect all possible urls */
	var my_listUrl = listUrl; // should be listUrl
	var inputUrls = new Array();
	inputUrls[my_listUrl] =  new Array();
	$(".search input.f_text").each(function(index, value) {
  		var my_id = $(this).attr("id");
    	var my_url = $(this).attr("listUrl");
    	if (my_url) {
			if (!inputUrls[my_url]) {
				inputUrls[my_url] = new Array();
			}
			inputUrls[my_url].push(my_id);
		}
		else {
			inputUrls[my_listUrl].push(my_id);
		}
	});
	
	/* no loop over all urls and the assigned list of ids (search input text fields for autocomplete */
	for (var key in inputUrls) {
		loadListAndAssign(key,inputUrls[key]);
	}
	 
	/*$.ajax({ //list for problems (list view)
		url: listUrl, // url: listNursingUrl,
		dataType: "json",
		success: function( data ) {
			genericCreateAutocomplete("problems", data);
			genericCreateAutocomplete("ddx", data);
			genericCreateAutocomplete("tests", data);
			genericCreateAutocomplete("patho", data, 6, false);
			genericCreateAutocomplete("mng", data);
			genericCreateAutocomplete("nddx", data);
			genericCreateAutocomplete("nmng", data);
			genericCreateAutocomplete("info", data);
			genericCreateAutocomplete("naim", data);
			genericCreateAutocomplete("act_search");
			genericCreateAutocomplete("ctxt_search");
		}
	});
	
	genericCreateAutocompleteWithoutList("problems", listUrl);
	genericCreateAutocompleteWithoutList("patho", listUrl);
	genericCreateAutocompleteWithoutList("ddx", listUrl);
	genericCreateAutocompleteWithoutList("tests", listUrl);
	genericCreateAutocompleteWithoutList("mng", listUrl);
	genericCreateAutocompleteWithoutList("act_search",listUrl);
	genericCreateAutocompleteWithoutList("ctxt_search", listUrl);
	*/
});

var exact_item_label = "";
var exact_item_value = "";

/**
	key = url or empty
	list of id of seach input text field
	go thru and init autocomplete
 */
function loadListAndAssign(key, list) {
	if (key && key != "" && key != "#") {
		$.ajax({ //list for problems (list view)
			url: key, // url: listNursingUrl,
			dataType: "json",
			success: function( data ) {
				for (let i = 0; i < list.length; i++) {
					loop = list[i];
					console.log("list.js: " + key + " -> " + loop);
					genericCreateAutocomplete(loop, data);
				}
			},
			error: function (jqXHR) {
    			for (let i = 0; i < list.length; i++) {
					loop = list[i];
					console.log("list.js: " + key + " -> " + loop);
					genericCreateAutocompleteWithoutList(loop, key);
				}
			}
		});
	}
	else {
		for (let i = 0; i < list.length; i++) {
			loop = list[i];
			console.log("list.js: " + key + " -> " + loop);
			genericCreateAutocompleteWithoutList(loop, key);
		}
	}
}

/**
	add item by id -> uses either specific add<> method or generic addItem
 */
function genericAddItem(ui, id) {
	// choose correct add??? function by id!
	if (id=="problems") { 	addProblem(ui.item.value, ui.item.label, $("#" + id).val());}
	else if (id=="ddx") { 	addDiagnosis(ui.item.value, ui.item.label, $("#" + id).val()); }
	else if (id=="tests") { addTest(ui.item.value, ui.item.label, $("#" + id).val()); }
	else if (id=="patho") { addPatho(ui.item.value, ui.item.label, $("#" + id).val()); }
	else if (id=="mng") { 	addManagement(ui.item.value, ui.item.label, $("#" + id).val()); }
	else if (id=="nddx") { 	addItem(ui.item.value, ui.item.label,  $("#" + id).val(), "Nddx"); }
	else if (id=="nmng") { 	addItem(ui.item.value, ui.item.label,  $("#" + id).val(), "Mmng"); }
	else if (id=="info") { 	addItem(ui.item.value, ui.item.label,  $("#" + id).val(), "Info"); }
	else if (id=="naim") { 	addItem(ui.item.value, ui.item.label,  $("#" + id).val(), "Naim"); }
	else if (id=="act_search") { addActor(ui.item.value, ui.item.label,  $("#" + id).val()); }
	else if (id=="ctxt_search") { addContext(ui.item.value, ui.item.label,  $("#" + id).val()); }
}

/**
	init search input text filed with empty list
 */
function genericCreateAutocompleteWithoutList(in_id, in_listUrl) {
	// lookup parameters by id!
	if (typeof in_id !== 'string') {
		in_id = "" + in_id;
	}
	var in_bind = "enter" + ((in_id && in_id.length>0) ? in_id.charAt(0).toUpperCase() + in_id.slice(1) : in_id);
	 /*if (in_id=="problems") 	{ in_bind = "enterProb"; }
	else if (in_id=="ddx") 	{ in_bind = "enterDDX"; }
	else if (in_id=="tests") {in_bind = "enterTest"; }
	else if (in_id=="patho") {in_bind = "enterPatho"; }
	else if (in_id=="mng") { in_bind = "enterMng"; }
	else if (in_id=="nddx") {}
	else if (in_id=="nmng") {}
	else if (in_id=="info") {}
	else if (in_id=="naim") {}
	else if (in_id=="act_search") { in_bind = "enterActor";}
	else if (in_id=="ctxt_search") { in_bind = "enterContext"; }*/
	
	// define new event, that's why name (in_bind) is not as crocial'
	$("#" + in_id).bind(in_bind, function(e) {
		addContext(-999, "-999", $("#" + in_id).val());	 
    });
    
    // now trigge the event!
    $("#" + in_id).keyup(function(e){
{'fraction_non_alphanumeric': 0.19265973518172932, 'fraction_numerical': 0.002665955745134631, 'mean_word_length': 4.124772313296903, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, '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': '1666674', 'n_tokens_mistral': 4286, 'n_tokens_neox': 3981, 'n_words': 942}