<commit_before>function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

function doAssignmentAjax(action, title, errText,
			  edah, block) {    
    var values = {};
    values[action] = 1;
    values["edah"] = edah;
    values["block"] = block;
    	$.ajax({
                url: 'levelingAjax.php',
                    type: 'post',
                    data: values,
                    success: function(data) {
		    if (action == "reassign") {
			// Fade and then reload with new data (for multiple clicks).
			$( "#results:visible" ).removeAttr( "style" ).fadeOut();
		    }
		    $( "#results" ).html(function() {
				    txt = "<h3>" + title + "</h3>";
				    txt += "<ul>";
				    txt += "<li><b>Chugim under min</b>: ";
				    txt += data.under_min_list;
				    txt += "</li>";
				    txt += "<li><b>Chugim over max</b>: ";
				    txt += data.over_max_list;
				    txt += "</li>";
				    txt += "<li><b>Assignment Stats</b>:<br>";
				    txt += data.statstxt;
				    txt += "</li></ul>";
				    return txt;
			});
		    $( "#results" ).show("slide", 500);
		    $( "#results" ).attr('disabled', false);
		},
		    error: function(xhr, desc, err) {
		    errMsg = "The system was unable to ";
		    errMsg += errText;
		    errMsg += ". If the problem persists, please contact the administrator.  Error: ";
		    errMsg += err;
		    $( "#results" ).text(errMsg);
		    $( "#results" ).show("slide", 250 );
		}
	    });
}

// Get the current match and chug info for this edah/block, and display it by group. 
// Also, display chugim with no matches, because the user needs the ability to drag
// to them.
function getAndDisplayCurrentMatches() {
        var edah = getParameterByName("edah");
        var block = getParameterByName("block");
	var succeeded = false;
	var camperId2Group2PrefList;
	var prefClasses = ["li_first_choice", "li_second_choice", "li_third_choice", "li_fourth_choice"];
	$.ajax({
                url: 'levelingAjax.php',
                    type: 'post',
                    data:{ matches_and_prefs: 1,
			edah_id: edah, 
			block_id: block },
                    success: function(json) {
		    succeeded = true;
		    // Display a field for each chug.  The chug fields should be grouped
		    // by group (aleph, bet, gimel).  Each field should contain camper containers,
		    // according to how campers are currently matched.
		    // Camper containers should be labeled with the camper's name, and colored according
		    // to the pref level of the assignment.  They should be draggable between chug fields,
		    // but only within the enclosing group (i.e., when changing the aleph assignment for
		    // a camper, it should be possible to move within aleph choices only).  Also, the tooltip
		    // for the camper boxes should show an ordered list of chugim, top to bottom.  
		    // "B-zhe moi!  This, I know from nothing!" - <NAME>.
		    var html = "";
		    var groupId2Name = json["groupId2Name"];
		    var groupId2ChugId2MatchedCampers = json["groupId2ChugId2MatchedCampers"];
		    camperId2Group2PrefList = json["camperId2Group2PrefList"];
		    var chugId2Beta = json["chugId2Beta"];
		    var camperId2Name = json["camperId2Name"];
		    $.each(groupId2ChugId2MatchedCampers,
			   function(groupId, chugId2MatchedCampers) {
			       // Add a holder for each group (aleph, bet, gimel).
			       var groupName = groupId2Name[groupId];
			       html += "<div class=\"groupholder\" name=\"" + groupId + "\" >\n";
			       html += "<h3>" + groupName + " assignments</h3>\n";
			       // Within each group, add a holder for campers, and then populate with
			       // campers.
			       $.each(chugId2MatchedCampers,
				      function(chugId, matchedCampers) {
					  // Add a chug holder, and put camper holders inside it.
					  var chugName = chugId2Beta[chugId]["name"];
					  var chugMin = chugId2Beta[chugId]["min_size"];
					  var chugMax = chugId2Beta[chugId]["max_size"];
					  html += "<div name=\"" + chugId + "\" class=\"ui-widget ui-helper-clearfix chugholder\">\n";
					  html += "<h4>" + chugName + " (min = " + chugMin + ", max = " + chugMax + ")</h4>";
					  html += "<ul class=\"gallery ui-helper-reset ui-helper-clearfix\">";
					  $.each(matchedCampers,
						 function(index, camperId) {
						     var camperName = camperId2Name[camperId];
						     var prefListText = "";
						     var prefClass = prefClasses[prefClasses.length - 1];
						     if (camperId in camperId2Group2PrefList) {
							 var group2PrefList = camperId2Group2PrefList[camperId];
							 if (groupId in group2PrefList) {
							     var prefList = group2PrefList[groupId];
							     $.each(prefList, function(index, prefChugId) {
								     var listNum = index + 1;
								     if (prefListText == "") {
									 prefListText += "Preferences:\n";
								     }
								     if (prefChugId in chugId2Beta) {
									 prefListText += listNum + ". " + chugId2Beta[prefChugId]["name"] + "\n";
								     }
								     if (prefChugId == chugId) {
									 if (index < prefClasses.length) {
									     prefClass = prefClasses[index];
									 } else {
									     prefClass = prefClasses[prefClasses.length - 1];
									 }
								     }
								 });<commit_msg>fix small bug<commit_after>function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

function doAssignmentAjax(action, title, errText,
			  edah, block) {    
    var values = {};
    values[action] = 1;
    values["edah"] = edah;
    values["block"] = block;
    	$.ajax({
                url: 'levelingAjax.php',
                    type: 'post',
                    data: values,
                    success: function(data) {
		    if (action == "reassign") {
			// Fade and then reload with new data (for multiple clicks).
			$( "#results:visible" ).removeAttr( "style" ).fadeOut();
		    }
		    $( "#results" ).html(function() {
				    txt = "<h3>" + title + "</h3>";
				    txt += "<ul>";
				    txt += "<li><b>Chugim under min</b>: ";
				    txt += data.under_min_list;
				    txt += "</li>";
				    txt += "<li><b>Chugim over max</b>: ";
				    txt += data.over_max_list;
				    txt += "</li>";
				    txt += "<li><b>Assignment Stats</b>:<br>";
				    txt += data.statstxt;
				    txt += "</li></ul>";
				    return txt;
			});
		    $( "#results" ).show("slide", 500);
		    $( "#results" ).attr('disabled', false);
		},
		    error: function(xhr, desc, err) {
		    errMsg = "The system was unable to ";
		    errMsg += errText;
		    errMsg += ". If the problem persists, please contact the administrator.  Error: ";
		    errMsg += err;
		    $( "#results" ).text(errMsg);
		    $( "#results" ).show("slide", 250 );
		}
	    });
}

// Get the current match and chug info for this edah/block, and display it by group. 
// Also, display chugim with no matches, because the user needs the ability to drag
// to them.
function getAndDisplayCurrentMatches() {
        var edah = getParameterByName("edah");
        var block = getParameterByName("block");
	var succeeded = false;
	var camperId2Group2PrefList;
	var prefClasses = ["li_first_choice", "li_second_choice", "li_third_choice", "li_fourth_choice"];
	$.ajax({
                url: 'levelingAjax.php',
                    type: 'post',
                    data:{ matches_and_prefs: 1,
			edah_id: edah, 
			block_id: block },
                    success: function(json) {
		    succeeded = true;
		    // Display a field for each chug.  The chug fields should be grouped
		    // by group (aleph, bet, gimel).  Each field should contain camper containers,
		    // according to how campers are currently matched.
		    // Camper containers should be labeled with the camper's name, and colored according
		    // to the pref level of the assignment.  They should be draggable between chug fields,
		    // but only within the enclosing group (i.e., when changing the aleph assignment for
		    // a camper, it should be possible to move within aleph choices only).  Also, the tooltip
		    // for the camper boxes should show an ordered list of chugim, top to bottom.  
		    // "B-zhe moi!  This, I know from nothing!" - <NAME>.
		    var html = "";
		    var groupId2Name = json["groupId2Name"];
		    var groupId2ChugId2MatchedCampers = json["groupId2ChugId2MatchedCampers"];
		    camperId2Group2PrefList = json["camperId2Group2PrefList"];
		    var chugId2Beta = json["chugId2Beta"];
		    var camperId2Name = json["camperId2Name"];
		    $.each(groupId2ChugId2MatchedCampers,
			   function(groupId, chugId2MatchedCampers) {
			       // Add a holder for each group (aleph, bet, gimel).
			       var groupName = groupId2Name[groupId];
			       html += "<div class=\"groupholder\" name=\"" + groupId + "\" >\n";
			       html += "<h3>" + groupName + " assignments</h3>\n";
			       // Within each group, add a holder for campers, and then populate with
			       // campers.
			       $.each(chugId2MatchedCampers,
				      function(chugId, matchedCampers) {
					  // Add a chug holder, and put camper holders inside it.
					  var chugName = chugId2Beta[chugId]["name"];
					  var chugMin = chugId2Beta[chugId]["min_size"];
					  var chugMax = chugId2Beta[chugId]["max_size"];
					  if (chugMax == "0") {
					      chugMax = "no limit";
					  }
					  html += "<div name=\"" + chugId + "\" class=\"ui-widget ui-helper-clearfix chugholder\">\n";
					  html += "<h4>" + chugName + " (min = " + chugMin + ", max = " + chugMax + ")</h4>";
					  html += "<ul class=\"gallery ui-helper-reset ui-helper-clearfix\">";
					  $.each(matchedCampers,
						 function(index, camperId) {
						     var camperName = camperId2Name[camperId];
						     var prefListText = "";
						     var prefClass = prefClasses[prefClasses.length - 1];
						     if (camperId in camperId2Group2PrefList) {
							 var group2PrefList = camperId2Group2PrefList[camperId];
							 if (groupId in group2PrefList) {
							     var prefList = group2PrefList[groupId];
							     $.each(prefList, function(index, prefChugId) {
								     var listNum = index + 1;
								     if (prefListText == "") {
									 prefListText += "Preferences:\n";
								     }
								     if (prefChugId in chugId2Beta) {
									 prefListText += listNum + ". " + chugId2Beta[prefChugId]["name"] + "\n";
								     }
								     if (prefChugId == chugId) {
									 if (index < prefClasses.length) {
									     prefClass = prefClasses[index];
									 } else {
									     prefClass = prefClasses[prefClasses.length - 1];
									 }
								     }
								 });
{'fraction_non_alphanumeric': 0.14548086492355017, 'fraction_numerical': 0.009499683343888538, 'mean_word_length': 2.251176470588235, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 53, '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': '481057', 'n_tokens_mistral': 4181, 'n_tokens_neox': 3375, 'n_words': 906}