<commit_before>$( document ).ready(function() {
/* remove temporarily as we don't have funder templates 
removed by wshi on Feb 9, 2015
	$("#project_funder_id").change(function () {
		update_template_options();
		update_guidance_options();
		if ($(this).val().length > 0) {
			$("#other-funder-name").hide();
			$("#project_funder_name").val("");
		}
		else {
			$("#other-funder-name").show();
		}
		$("#institution-control-group").show();
		$("#create-plan-button").show();
		$("#confirm-funder").text($("#project_funder_id").select2('data').text);
	});

	$("#no-funder").click(function(e) {
		e.preventDefault();
		$("#project_funder_id").select2("val", "");
		update_template_options();
		update_guidance_options();
		$("#institution-control-group").show();
		$("#create-plan-button").show();
		$("#other-funder-name").show();
		$("#confirm-funder").text(get_locale_string())
	});

	$("#project_funder_name").change(function(){
		$("#confirm-funder").text($(this).val());
	});
*/
	$("#project_institution_id").change(function () {
                
                $("#confirm-funder").text(get_locale_string());
                $("#project_funder_id").select2("val", "");
                $("#create-plan-button").show();
		update_template_options();
		update_guidance_options();
		$("#confirm-institution").text($("#project_institution_id").select2('data').text);
	});

	$("#no-institution").click(function() {
		$("#project_institution_id").select2("val", "");
		update_template_options();
		update_guidance_options();
		$("#confirm-institution").text(get_locale_string());
	});

        $("#create-plan-button").click(function() {
                update_template_options();
                update_guidance_options();
        });

	$("#project_dmptemplate_id").change(function (f) {
		update_guidance_options();
		$("#confirm-template").text($("#project_dmptemplate_id :selected").text());
	});

	$("#project-confirmation-dialog").on("show", function(){
		if ($("#confirm-institution").text() == "") {
			$("#confirm-institution").text(get_locale_string());
		}
		if ($("#confirm-funder").text() == "") {
			$("#confirm-funder").text(get_locale_string());
		}
		if ($("#confirm-template").text() == "") {
			$("#confirm-template").closest("div").hide();
		}
		else {
			$("#confirm-template").closest("div").show();
		}
		$("#confirm-guidance").empty();
		$("input:checked").each(function(){
			$("#confirm-guidance").append("<li id='confirm-"+$(this).attr("id")+"'>"+$(this).parent().text()+"</li>");
		});
		$('.select2-choice').hide();
	});

	$("#new-project-cancelled").click(function (){
		$("#project-confirmation-dialog").modal("hide");
		$('.select2-choice').show();
	});

	$("#new-project-confirmed").click(function (){
		$("#new_project").submit();
	});

    //for the default template alert
	$("#default-template-confirmation-dialog").on("show", function(){
		$('.select2-choice').hide();
	});

	$("#default-template-cancelled").click(function (){
		$("#default-template-confirmation-dialog").modal("hide");
		$('.select2-choice').show();
	});

	$("#default-template-confirmed").click(function (){
		$("#default_tag").val('true');
		$("#new_project").submit();
	});


	function update_template_options() {
		var options = {};
		var funder = $("#project_funder_id").select2('val');
		var institution = $("#project_institution_id").select2('val');
                var portage;
                $("#project_institution_id option").each(function(){
                   if($(this).text() == "Portage"){
                     portage = ($(this).val());
                   }
               }); 
                if (institution == "") {
                  institution = portage;
                }
		$.ajax({
			type: 'GET',
                        url: "possible_templates.json?institution="+institution,
/* temporarily change the url to disable funder dropdown menu
			url: "possible_templates.json?institution="+institution+"&funder="+funder,
*/
			dataType: 'json',
			async: false, //Needs to be synchronous, otherwise end up mixing up answers
			success: function(data) {
				options = data;
			}
		});
		select_element = $("#project_dmptemplate_id");
		select_element.find("option").remove();
		var count = 0;
		for (var id in options) {
			if (count == 0) {
				select_element.append("<option value='"+id+"' selected='selected'>"+options[id]+"</option>");
			}
			else {
				select_element.append("<option value='"+id+"'>"+options[id]+"</option>");
			}
			count++;
		}<commit_msg>hardcoded the portage institution id in the javascript. need an elegant solution after the launch<commit_after>$( document ).ready(function() {
/* remove temporarily as we don't have funder templates 
removed by wshi on Feb 9, 2015
	$("#project_funder_id").change(function () {
		update_template_options();
		update_guidance_options();
		if ($(this).val().length > 0) {
			$("#other-funder-name").hide();
			$("#project_funder_name").val("");
		}
		else {
			$("#other-funder-name").show();
		}
		$("#institution-control-group").show();
		$("#create-plan-button").show();
		$("#confirm-funder").text($("#project_funder_id").select2('data').text);
	});

	$("#no-funder").click(function(e) {
		e.preventDefault();
		$("#project_funder_id").select2("val", "");
		update_template_options();
		update_guidance_options();
		$("#institution-control-group").show();
		$("#create-plan-button").show();
		$("#other-funder-name").show();
		$("#confirm-funder").text(get_locale_string())
	});

	$("#project_funder_name").change(function(){
		$("#confirm-funder").text($(this).val());
	});
*/
	$("#project_institution_id").change(function () {
                
                $("#confirm-funder").text(get_locale_string());
                $("#project_funder_id").select2("val", "");
                $("#create-plan-button").show();
		update_template_options();
		update_guidance_options();
		$("#confirm-institution").text($("#project_institution_id").select2('data').text);
	});

	$("#no-institution").click(function() {
		$("#project_institution_id").select2("val", "");
		update_template_options();
		update_guidance_options();
		$("#confirm-institution").text(get_locale_string());
	});

        $("#create-plan-button").click(function() {
                update_template_options();
                update_guidance_options();
        });

	$("#project_dmptemplate_id").change(function (f) {
		update_guidance_options();
		$("#confirm-template").text($("#project_dmptemplate_id :selected").text());
	});

	$("#project-confirmation-dialog").on("show", function(){
		if ($("#confirm-institution").text() == "") {
			$("#confirm-institution").text(get_locale_string());
		}
		if ($("#confirm-funder").text() == "") {
			$("#confirm-funder").text(get_locale_string());
		}
		if ($("#confirm-template").text() == "") {
			$("#confirm-template").closest("div").hide();
		}
		else {
			$("#confirm-template").closest("div").show();
		}
		$("#confirm-guidance").empty();
		$("input:checked").each(function(){
			$("#confirm-guidance").append("<li id='confirm-"+$(this).attr("id")+"'>"+$(this).parent().text()+"</li>");
		});
		$('.select2-choice').hide();
	});

	$("#new-project-cancelled").click(function (){
		$("#project-confirmation-dialog").modal("hide");
		$('.select2-choice').show();
	});

	$("#new-project-confirmed").click(function (){
		$("#new_project").submit();
	});

    //for the default template alert
	$("#default-template-confirmation-dialog").on("show", function(){
		$('.select2-choice').hide();
	});

	$("#default-template-cancelled").click(function (){
		$("#default-template-confirmation-dialog").modal("hide");
		$('.select2-choice').show();
	});

	$("#default-template-confirmed").click(function (){
		$("#default_tag").val('true');
		$("#new_project").submit();
	});


	function update_template_options() {
		var options = {};
		var funder = $("#project_funder_id").select2('val');
		var institution = $("#project_institution_id").select2('val');
                var portage;
                $("#project_institution_id option").each(function(){
                   if($(this).text() == "Portage"){
                     portage = ($(this).val());
                   }
               }); 
                if (institution == "") {
                  institution = portage;
                }
                if (institution == "") {
                  institution = '8';
                }
		$.ajax({
			type: 'GET',
                        url: "possible_templates.json?institution="+institution,
/* temporarily change the url to disable funder dropdown menu
			url: "possible_templates.json?institution="+institution+"&funder="+funder,
*/
			dataType: 'json',
			async: false, //Needs to be synchronous, otherwise end up mixing up answers
			success: function(data) {
				options = data;
			}
		});
		select_element = $("#project_dmptemplate_id");
		select_element.find("option").remove();
		var count = 0;
		for (var id in options) {
			if (count == 0) {
				select_element.append("<option value='"+id+"' selected='selected'>"+options[id]+"</option>");
			}
			else {
				select_element.append("<option value='"+id+"'>"+options[id]+"</option>");
			}
			count++;
		}
{'fraction_non_alphanumeric': 0.23297686599738104, 'fraction_numerical': 0.0042557835006547355, 'mean_word_length': 3.751166407465008, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '5430163', 'n_tokens_mistral': 3041, 'n_tokens_neox': 2840, 'n_words': 370}