<commit_before>osmium_commit_load = function(toggletype, toggleindex, toggledirection, 
							  transferdrone, transferquantity, transferfrom) {
	$("img#vloadoutbox_spinner").css('visibility', 'visible');

	var opts = {
		loadoutid: $('div#vloadoutbox').data('loadoutid'),
		pid: $('div#vloadoutbox').data('presetid'),
		cpid: $('div#vloadoutbox').data('cpid'),
		dpid: $('div#vloadoutbox').data('dpid'),
		toggletype: toggletype,
		toggleindex: toggleindex,
		toggledirection: toggledirection,
		transferdrone: transferdrone,
		transferquantity: transferquantity,
		transferfrom: transferfrom
	};

	$('div#vloadoutbox > div.slots.stateful > ul > li[data-state]').each(function() {
		opts[$(this).data('slottype') + $(this).data('index')] = $(this).data('state');
	});

	$('div#inspace > ul > li[data-count]').each(function() {
		var key = 'droneinspace' + $(this).data('typeid');
		var count = $(this).data('count');

		if(key in opts) opts[key] += count;
		else opts[key] = count;
	});

	$.getJSON('../src/json/view_loadout_alter.php', opts, function(json) {
		if($.type(json['preset']) === 'object') {
			$("div#vloadoutbox > div.slots > ul > li > span.charge").empty();

			for(var type in json['preset']) {
				for(var index in json['preset'][type]) {
					var charge = $("div#vloadoutbox > div.slots > ul > li").filter(function() {
						return $(this).data('slottype') == type && $(this).data('index') == index;
					}).find('span.charge');

					charge.append(',<br />');
					charge.append("<img src='http://image.eveonline.com/Type/" 
								  + json['preset'][type][index]['typeid'] + "_32.png' alt='' />");
					charge.append(json['preset'][type][index]['typename']);
				}
			}
		}

		if($.type(json['states']) === 'object') {
			for(var type in json['states']) {
				for(var index in json['states'][type]) {
					var li = $("div#vloadoutbox > div.slots > ul > li").filter(function() {
						return $(this).data('slottype') == type && $(this).data('index') == index;
					});
					li.data('state', json['states'][type][index]['state']);
					li.find('a.toggle')
						.attr('title', json['states'][type][index]['name'] + '; click to toggle')
						.find('img')
						.attr('alt', json['states'][type][index]['name'])
						.attr('src', '../static/icons/' + json['states'][type][index]['image']);
				}
			}
		}

		if($.type(json['ranges']) === 'object') {
			for(var type in json['ranges']) {
				for(var index in json['ranges'][type]) {
					var li = $("div#vloadoutbox > div.slots > ul > li").filter(function() {
						return $(this).data('slottype') == type && $(this).data('index') == index;
					});
					li.find('span.range').text(json['ranges'][type][index][0])
						.attr('title', json['ranges'][type][index][1]);
				}
			}
		}

		var used_bandwidth = 0;
		var total_bandwidth;
		$("div#inbay > ul, div#inspace > ul").empty();
		for(var i = 0; i < json['drones'].length; ++i) {
			var drone = json['drones'][i];
			if(drone['quantityinbay'] > 0) {
				$("div#inbay > ul").append(
					"<li data-typeid='"
						+ drone['typeid'] + "' data-count='"
						+ drone['quantityinbay'] + "'><img alt='' src='http://image.eveonline.com/Type/" 
						+ drone['typeid'] + "_32.png' />"
						+ drone['typename'] + " <strong>×"
						+ drone['quantityinbay'] + "</strong></li>");
			}
			if(drone['quantityinspace'] > 0) {
				$("div#inspace > ul").append(
					"<li data-typeid='"
						+ drone['typeid'] + "' data-count='"
						+ drone['quantityinspace'] + "'><img alt='' src='http://image.eveonline.com/Type/" 
						+ drone['typeid'] + "_32.png' />"
						+ drone['typename'] + " <strong>×"
						+ drone['quantityinspace'] + "</strong></li>");
				used_bandwidth += drone['quantityinspace'] * drone['bandwidth'], 10;
			}
		}

		total_bandwidth = json['dronebandwidth'];
		$("span#dronebandwidth").text(used_bandwidth + " / " + total_bandwidth);
		if(used_bandwidth > total_bandwidth) {
			$("span#dronebandwidth").addClass('overflow');
		} else {
			$("span#dronebandwidth").removeClass('overflow');
		}
		
		if($("div#inbay > ul > li").length === 0) {
			$("div#inbay > ul").append("<li><em>(no drones in bay)</em></li>");
		}
		if($("div#inspace > ul > li").length === 0) {
			$("div#inspace > ul").append("<li><em>(no drones in space)</em></li>");
		}

		$("div#computed_attributes").html(json['attributes']);
		osmium_fattribs_load();

		$("img#vloadoutbox_spinner").css('visibility', 'hidden');
	});
};

$(function() {
	$('ul#vpresets > li > a').click(function() {
		$('ul#vpresets > li > a.active').removeClass('active');
		$(this).addClass('active');
		osmium_commit_load(null, null);
		return false;
	});

	$('div#vloadoutbox > div.slots.stateful > ul > li > a.toggle').click(function(obj) {
		osmium_commit_load($(this).parent().data('slottype'), $(this).parent().data('index'), true, null, null, null);
		obj.stopPropagation();
		obj.preventDefault();
		return false;
	}).bind('contextmenu', function(obj) {
		osmium_commit_load($(this).parent().data('slottype'), $(this).parent().data('index'), false, null, null, null);
		obj.stopPropagation();
		obj.preventDefault();
		return false;
	});

	$(document).on('dblclick', 'div#inbay > ul > li', function() {
		osmium_commit_load(null, null, null, $(this).data('typeid'), 1, 'bay');		<commit_msg>Fix: keep meta section when reloading fit.<commit_after>osmium_commit_load = function(toggletype, toggleindex, toggledirection, 
							  transferdrone, transferquantity, transferfrom) {
	$("img#vloadoutbox_spinner").css('visibility', 'visible');

	var opts = {
		loadoutid: $('div#vloadoutbox').data('loadoutid'),
		pid: $('div#vloadoutbox').data('presetid'),
		cpid: $('div#vloadoutbox').data('cpid'),
		dpid: $('div#vloadoutbox').data('dpid'),
		toggletype: toggletype,
		toggleindex: toggleindex,
		toggledirection: toggledirection,
		transferdrone: transferdrone,
		transferquantity: transferquantity,
		transferfrom: transferfrom
	};

	$('div#vloadoutbox > div.slots.stateful > ul > li[data-state]').each(function() {
		opts[$(this).data('slottype') + $(this).data('index')] = $(this).data('state');
	});

	$('div#inspace > ul > li[data-count]').each(function() {
		var key = 'droneinspace' + $(this).data('typeid');
		var count = $(this).data('count');

		if(key in opts) opts[key] += count;
		else opts[key] = count;
	});

	$.getJSON('../src/json/view_loadout_alter.php', opts, function(json) {
		if($.type(json['preset']) === 'object') {
			$("div#vloadoutbox > div.slots > ul > li > span.charge").empty();

			for(var type in json['preset']) {
				for(var index in json['preset'][type]) {
					var charge = $("div#vloadoutbox > div.slots > ul > li").filter(function() {
						return $(this).data('slottype') == type && $(this).data('index') == index;
					}).find('span.charge');

					charge.append(',<br />');
					charge.append("<img src='http://image.eveonline.com/Type/" 
								  + json['preset'][type][index]['typeid'] + "_32.png' alt='' />");
					charge.append(json['preset'][type][index]['typename']);
				}
			}
		}

		if($.type(json['states']) === 'object') {
			for(var type in json['states']) {
				for(var index in json['states'][type]) {
					var li = $("div#vloadoutbox > div.slots > ul > li").filter(function() {
						return $(this).data('slottype') == type && $(this).data('index') == index;
					});
					li.data('state', json['states'][type][index]['state']);
					li.find('a.toggle')
						.attr('title', json['states'][type][index]['name'] + '; click to toggle')
						.find('img')
						.attr('alt', json['states'][type][index]['name'])
						.attr('src', '../static/icons/' + json['states'][type][index]['image']);
				}
			}
		}

		if($.type(json['ranges']) === 'object') {
			for(var type in json['ranges']) {
				for(var index in json['ranges'][type]) {
					var li = $("div#vloadoutbox > div.slots > ul > li").filter(function() {
						return $(this).data('slottype') == type && $(this).data('index') == index;
					});
					li.find('span.range').text(json['ranges'][type][index][0])
						.attr('title', json['ranges'][type][index][1]);
				}
			}
		}

		var used_bandwidth = 0;
		var total_bandwidth;
		$("div#inbay > ul, div#inspace > ul").empty();
		for(var i = 0; i < json['drones'].length; ++i) {
			var drone = json['drones'][i];
			if(drone['quantityinbay'] > 0) {
				$("div#inbay > ul").append(
					"<li data-typeid='"
						+ drone['typeid'] + "' data-count='"
						+ drone['quantityinbay'] + "'><img alt='' src='http://image.eveonline.com/Type/" 
						+ drone['typeid'] + "_32.png' />"
						+ drone['typename'] + " <strong>×"
						+ drone['quantityinbay'] + "</strong></li>");
			}
			if(drone['quantityinspace'] > 0) {
				$("div#inspace > ul").append(
					"<li data-typeid='"
						+ drone['typeid'] + "' data-count='"
						+ drone['quantityinspace'] + "'><img alt='' src='http://image.eveonline.com/Type/" 
						+ drone['typeid'] + "_32.png' />"
						+ drone['typename'] + " <strong>×"
						+ drone['quantityinspace'] + "</strong></li>");
				used_bandwidth += drone['quantityinspace'] * drone['bandwidth'], 10;
			}
		}

		total_bandwidth = json['dronebandwidth'];
		$("span#dronebandwidth").text(used_bandwidth + " / " + total_bandwidth);
		if(used_bandwidth > total_bandwidth) {
			$("span#dronebandwidth").addClass('overflow');
		} else {
			$("span#dronebandwidth").removeClass('overflow');
		}
		
		if($("div#inbay > ul > li").length === 0) {
			$("div#inbay > ul").append("<li><em>(no drones in bay)</em></li>");
		}
		if($("div#inspace > ul > li").length === 0) {
			$("div#inspace > ul").append("<li><em>(no drones in space)</em></li>");
		}

		var meta = $("div#computed_attributes > section#vmeta");
		$("div#computed_attributes").html(json['attributes']).prepend(meta);
		osmium_fattribs_load();

		$("img#vloadoutbox_spinner").css('visibility', 'hidden');
	});
};

$(function() {
	$('ul#vpresets > li > a').click(function() {
		$('ul#vpresets > li > a.active').removeClass('active');
		$(this).addClass('active');
		osmium_commit_load(null, null);
		return false;
	});

	$('div#vloadoutbox > div.slots.stateful > ul > li > a.toggle').click(function(obj) {
		osmium_commit_load($(this).parent().data('slottype'), $(this).parent().data('index'), true, null, null, null);
		obj.stopPropagation();
		obj.preventDefault();
		return false;
	}).bind('contextmenu', function(obj) {
		osmium_commit_load($(this).parent().data('slottype'), $(this).parent().data('index'), false, null, null, null);
		obj.stopPropagation();
		obj.preventDefault();
		return false;
	});

	$(document).on('dblclick', 'div#inbay > ul > li', function() {
		osmium_commit_load(null, null, null, $(this).data('typeid'), 1, 'bay');		
{'fraction_non_alphanumeric': 0.24155088246338716, 'fraction_numerical': 0.0031918888471648517, 'mean_word_length': 4.204201270151441, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 126, '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': '3839763', 'n_tokens_mistral': 4425, 'n_tokens_neox': 3754, 'n_words': 592}