<commit_before>(function() {
	if (getVisiblePage() == "dossier_advanced") {
		$("input[type='submit']").attr("class", "button").css("font-size", "12px");
	} else if (getVisiblePage() == "dossier" && isSettingEnabled("fancy_dossier_theme")) {
		if (isAntiquityTheme()) {
			$("#main").html("<div id='content'>" + $("#main").html() + "</div>");
		}
		$("#content").html("<h1>" + getUserNation().replaceAll("_", " ").toTitleCase() + "'s Dossier</h1>");
		
		var advanced = "<i style='position: absolute; top: 135px; left: 500px;'><a href='page=dossier_advanced'>(Advanced)</a></i>";
		$("#content").html("<div id='nation_dossier'><h1>National Dossier</h1>" + advanced + "</div><div id='region_dossier'><h1>Regional Dossier</h1>" + advanced + "</div>");
		$("#nation_dossier").append("<button id='refresh_ndossier' title='Refresh Dossier' style='right: 400px' class='button clear-dossier'>Refresh</button>");
		$("#nation_dossier").append("<button id='switch_to_region_dossier' title='Switch to Region Dossier' style='right: 200px' class='button clear-dossier'>View Regional Dossier</button>");
		$("#nation_dossier").append("<button id='clear_national_dossier' title='Clear Dossier' class='button danger clear-dossier'>Clear National Dossier</button>");
		
		$("#region_dossier").append("<button id='refresh_rdossier' title='Refresh Dossier' style='right: 400px' class='button clear-dossier'>Refresh</button>");
		$("#region_dossier").append("<button id='switch_to_nation_dossier' title='Switch to Nation Dossier' style='right: 205px' class='button clear-dossier'>View National Dossier</button>");
		$("#region_dossier").append("<button id='clear_regional_dossier' title='Clear Dossier' class='button danger clear-dossier'>Clear Regional Dossier</button>");
		$("#region_dossier").hide();
		
		$("#clear_national_dossier, #clear_regional_dossier").click(function(event) {
			var isRegional = $(this).attr("id") == "clear_regional_dossier";
			$.post("page=dossier", (isRegional ? "clear_rdossier=REMOVE+ALL" : "clear_dossier=REMOVE+ALL"), function(html) {
				var dossier = $((isRegional ? "#region_dossier" : "#nation_dossier"));
				dossier.find(".dossier_element").remove();
				dossier.find(".info").remove();
				dossier.append("<p class='info'>" + $(html).find(".info").html() + "</p>");
				setTimeout(function() {
					dossier.find(".info").animate({ height: 'toggle', 'min-height': 'toggle' }, 800);
					setTimeout(function() { dossier.find(".info").remove(); }, 1000);
				}, 10000);
				currentNationPage = 0;
				endNationDossier = false;
				loadDossierPage(isRegional, true);
			});
		});
		
		$("#refresh_ndossier").click(function() {
			currentNationPage = 0;
			endNationDossier = false;
			$("#nation_dossier").find(".dossier_element").remove();
			loadDossierPage(false, false);
		});
		
		$("#refresh_rdossier").click(function() {
			currentRegionPage = 0;
			endRegionDossier = false;
			$("#region_dossier").find(".dossier_element").remove();
			loadDossierPage(true, false);
		});
		
		$("#switch_to_region_dossier").click(function() {
			$("#nation_dossier").hide();
			$("#region_dossier").show();
			$("#refresh_rdossier").click();
		});
		
		$("#switch_to_nation_dossier").click(function() {
			$("#region_dossier").hide();
			$("#nation_dossier").show();
			$("#refresh_ndossier").click();
		});

		$(document.body).click(function(event) {
			var target;
			if ($(event.target).attr("class") == "dossier_element") {
				target = $(event.target).attr("id");
			} else {
				target = $(event.target).parents(".dossier_element").attr("id");
			}
			if (target && target != "last_nation_element") {
				if ($("#nation_dossier:visible").length == 1) {
					if (typeof $(event.target).attr("id") != "undefined" && $(event.target).attr("id").startsWith("remove-")) {
						console.log("Removing: " + target);
						$.post("page=dossier", "nation=" + target + "&action=remove", function() { });
						$("#nation_dossier").find("#" + target).animate({ height: 'toggle', 'min-height': 'toggle' }, 800);
					} else if (typeof $(event.target).attr("id") != "undefined" && $(event.target).attr("id").startsWith("input-alias-")) {
						return;
					} else if (typeof $(event.target).attr("id") != "undefined" && $(event.target).attr("id").startsWith("alias-")) {
						var nation = $(event.target).attr("id").split("alias-")[1];
						console.log("Alias for: " + nation);
						if (getNationAlias(nation) == null) {
							//$(event.target).attr("src", "http://capitalistparadise.com/nationstates/static/remove-alias.png");
							if ($("#input-alias-" + nation).length == 0) {
								$(event.target).parent().find(".wa_status, .last_activity").hide();
								$("<input id='input-alias-" + nation + "' type='text' placeholder='Alias' style='height: 22px; font-size: 15px;width:250px;margin-left: 10px;'>").insertAfter($(event.target));
								$("#input-alias-" + nation).on('keydown', function(e) {
									if (e.which == 13) {
										var value = $("#input-alias-" + nation).val();
										$("#input-alias-" + nation).remove();
										if (value.length > 0) {
											console.log("Setting nation alias of " + nation + " to : " + value);
											setNationAlias(nation, value);
											$("#alias-" + nation).attr("src", "http://capitalistparadise.com/nationstates/static/remove-alias.png");
											$("#alias-" + nation).attr("title", "Remove Alias");
											$("#nation-link-" + nation).css("text-decoration", "line-through");
											$("#nation-alias-" + nation).children("pre").html("  " + value);
											$(event.target).parent().find(".wa_status, .last_activity").show();
											window.onresize();
										}
									}
								});
								$("#input-alias-" + nation).focus();
							}
						} else {
							setNationAlias(nation, null);
							$(event.target).attr("src", "http://capitalistparadise.com/nationstates/static/alias.png");
							$(event.target).attr("title", "Set Alias");
							$("#nation-link-" + nation).css("text-decoration", "");
							$("#nation-alias-" + nation).children("pre").html("");
							window.onresize();
						}
					} else {
						if (typeof $("#iframe-" + target).html() == "undefined") {
							$("#nation_dossier").find("#" + target).html($("#" + target).html() + "<div id='iframe-" + target + "' class='nation-frame'><iframe style='width: 100%; height: 495px;' src='http://nationstates.net/nation=" + target + "?hideBanner=true&hideFooter=true&hidePanel=true&hideFlag=true'/></div>");
							$("#nation_dossier").find("#iframe-" + target).hide();
						}
						$("#nation_dossier").find("#iframe-" + target).animate({ height: 'toggle'}, 800);
					}
				} else {
					if (typeof $(event.target).attr("id") != "undefined" && $(event.target).attr("id").startsWith("remove-")) {
						$.post("page=dossier", "remove_region_" + target + "=on&remove_from_region_dossier=Remove+Marked+Regions", function() { });
						$("#region_dossier").find("#" + target).animate({ height: 'toggle', 'min-height': 'toggle' }, 800);
					} else {
						if (typeof $("#iframe-" + target).html() == "undefined") {
							$("#region_dossier").find("#" + target).html($("#" + target).html() + "<div id='iframe-" + target + "' class='nation-frame'><iframe style='width: 100%; height: 495px;' src='http://nationstates.net/region=" + target + "?hideBanner=true&hideFooter=true&hidePanel=true&hideFlag=true'/></div>");
							$("#region_dossier").find("#iframe-" + target).hide();
						}
						$("#region_dossier").find("#iframe-" + target).animate({ height: 'toggle'}, 800);
					}
				}
			}
		});

		var currentRegionPage = 0;
		var endRegionDossier = false;
		
		var currentNationPage = 0;
		var endNationDossier = false;
		loadDossierPage = function(region, animate) {
			if ((region && endRegionDossier) || (!region && endNationDossier)) {
				return;
			}
			var targets = [];
			$.get("page=dossier?start=" + (currentNationPage * 15), function(html) {
				var dossierHtml = "";
				if (region) {
					$(html).find("table").find("tbody").find("tr").each(function() {
						if ($(this).children().length == 4) {
							var region = $($(this).children()[1]).find("a").attr("href").substring(7);
							var nations = $($(this).children()[2]).html();<commit_msg>Fix dossier bug with dead regions<commit_after>(function() {
	if (getVisiblePage() == "dossier_advanced") {
		$("input[type='submit']").attr("class", "button").css("font-size", "12px");
	} else if (getVisiblePage() == "dossier" && isSettingEnabled("fancy_dossier_theme")) {
		if (isAntiquityTheme()) {
			$("#main").html("<div id='content'>" + $("#main").html() + "</div>");
		}
		$("#content").html("<h1>" + getUserNation().replaceAll("_", " ").toTitleCase() + "'s Dossier</h1>");
		
		var advanced = "<i style='position: absolute; top: 135px; left: 500px;'><a href='page=dossier_advanced'>(Advanced)</a></i>";
		$("#content").html("<div id='nation_dossier'><h1>National Dossier</h1>" + advanced + "</div><div id='region_dossier'><h1>Regional Dossier</h1>" + advanced + "</div>");
		$("#nation_dossier").append("<button id='refresh_ndossier' title='Refresh Dossier' style='right: 400px' class='button clear-dossier'>Refresh</button>");
		$("#nation_dossier").append("<button id='switch_to_region_dossier' title='Switch to Region Dossier' style='right: 200px' class='button clear-dossier'>View Regional Dossier</button>");
		$("#nation_dossier").append("<button id='clear_national_dossier' title='Clear Dossier' class='button danger clear-dossier'>Clear National Dossier</button>");
		
		$("#region_dossier").append("<button id='refresh_rdossier' title='Refresh Dossier' style='right: 400px' class='button clear-dossier'>Refresh</button>");
		$("#region_dossier").append("<button id='switch_to_nation_dossier' title='Switch to Nation Dossier' style='right: 205px' class='button clear-dossier'>View National Dossier</button>");
		$("#region_dossier").append("<button id='clear_regional_dossier' title='Clear Dossier' class='button danger clear-dossier'>Clear Regional Dossier</button>");
		$("#region_dossier").hide();
		
		$("#clear_national_dossier, #clear_regional_dossier").click(function(event) {
			var isRegional = $(this).attr("id") == "clear_regional_dossier";
			$.post("page=dossier", (isRegional ? "clear_rdossier=REMOVE+ALL" : "clear_dossier=REMOVE+ALL"), function(html) {
				var dossier = $((isRegional ? "#region_dossier" : "#nation_dossier"));
				dossier.find(".dossier_element").remove();
				dossier.find(".info").remove();
				dossier.append("<p class='info'>" + $(html).find(".info").html() + "</p>");
				setTimeout(function() {
					dossier.find(".info").animate({ height: 'toggle', 'min-height': 'toggle' }, 800);
					setTimeout(function() { dossier.find(".info").remove(); }, 1000);
				}, 10000);
				currentNationPage = 0;
				endNationDossier = false;
				loadDossierPage(isRegional, true);
			});
		});
		
		$("#refresh_ndossier").click(function() {
			currentNationPage = 0;
			endNationDossier = false;
			$("#nation_dossier").find(".dossier_element").remove();
			loadDossierPage(false, false);
		});
		
		$("#refresh_rdossier").click(function() {
			currentRegionPage = 0;
			endRegionDossier = false;
			$("#region_dossier").find(".dossier_element").remove();
			loadDossierPage(true, false);
		});
		
		$("#switch_to_region_dossier").click(function() {
			$("#nation_dossier").hide();
			$("#region_dossier").show();
			$("#refresh_rdossier").click();
		});
		
		$("#switch_to_nation_dossier").click(function() {
			$("#region_dossier").hide();
			$("#nation_dossier").show();
			$("#refresh_ndossier").click();
		});

		$(document.body).click(function(event) {
			var target;
			if ($(event.target).attr("class") == "dossier_element") {
				target = $(event.target).attr("id");
			} else {
				target = $(event.target).parents(".dossier_element").attr("id");
			}
			if (target && target != "last_nation_element") {
				if ($("#nation_dossier:visible").length == 1) {
					if (typeof $(event.target).attr("id") != "undefined" && $(event.target).attr("id").startsWith("remove-")) {
						console.log("Removing: " + target);
						$.post("page=dossier", "nation=" + target + "&action=remove", function() { });
						$("#nation_dossier").find("#" + target).animate({ height: 'toggle', 'min-height': 'toggle' }, 800);
					} else if (typeof $(event.target).attr("id") != "undefined" && $(event.target).attr("id").startsWith("input-alias-")) {
						return;
					} else if (typeof $(event.target).attr("id") != "undefined" && $(event.target).attr("id").startsWith("alias-")) {
						var nation = $(event.target).attr("id").split("alias-")[1];
						console.log("Alias for: " + nation);
						if (getNationAlias(nation) == null) {
							//$(event.target).attr("src", "http://capitalistparadise.com/nationstates/static/remove-alias.png");
							if ($("#input-alias-" + nation).length == 0) {
								$(event.target).parent().find(".wa_status, .last_activity").hide();
								$("<input id='input-alias-" + nation + "' type='text' placeholder='Alias' style='height: 22px; font-size: 15px;width:250px;margin-left: 10px;'>").insertAfter($(event.target));
								$("#input-alias-" + nation).on('keydown', function(e) {
									if (e.which == 13) {
										var value = $("#input-alias-" + nation).val();
										$("#input-alias-" + nation).remove();
										if (value.length > 0) {
											console.log("Setting nation alias of " + nation + " to : " + value);
											setNationAlias(nation, value);
											$("#alias-" + nation).attr("src", "http://capitalistparadise.com/nationstates/static/remove-alias.png");
											$("#alias-" + nation).attr("title", "Remove Alias");
											$("#nation-link-" + nation).css("text-decoration", "line-through");
											$("#nation-alias-" + nation).children("pre").html("  " + value);
											$(event.target).parent().find(".wa_status, .last_activity").show();
											window.onresize();
										}
									}
								});
								$("#input-alias-" + nation).focus();
							}
						} else {
							setNationAlias(nation, null);
							$(event.target).attr("src", "http://capitalistparadise.com/nationstates/static/alias.png");
							$(event.target).attr("title", "Set Alias");
							$("#nation-link-" + nation).css("text-decoration", "");
							$("#nation-alias-" + nation).children("pre").html("");
							window.onresize();
						}
					} else {
						if (typeof $("#iframe-" + target).html() == "undefined") {
							$("#nation_dossier").find("#" + target).html($("#" + target).html() + "<div id='iframe-" + target + "' class='nation-frame'><iframe style='width: 100%; height: 495px;' src='http://nationstates.net/nation=" + target + "?hideBanner=true&hideFooter=true&hidePanel=true&hideFlag=true'/></div>");
							$("#nation_dossier").find("#iframe-" + target).hide();
						}
						$("#nation_dossier").find("#iframe-" + target).animate({ height: 'toggle'}, 800);
					}
				} else {
					if (typeof $(event.target).attr("id") != "undefined" && $(event.target).attr("id").startsWith("remove-")) {
						$.post("page=dossier", "remove_region_" + target + "=on&remove_from_region_dossier=Remove+Marked+Regions", function() { });
						$("#region_dossier").find("#" + target).animate({ height: 'toggle', 'min-height': 'toggle' }, 800);
					} else {
						if (typeof $("#iframe-" + target).html() == "undefined") {
							$("#region_dossier").find("#" + target).html($("#" + target).html() + "<div id='iframe-" + target + "' class='nation-frame'><iframe style='width: 100%; height: 495px;' src='http://nationstates.net/region=" + target + "?hideBanner=true&hideFooter=true&hidePanel=true&hideFlag=true'/></div>");
							$("#region_dossier").find("#iframe-" + target).hide();
						}
						$("#region_dossier").find("#iframe-" + target).animate({ height: 'toggle'}, 800);
					}
				}
			}
		});

		var currentRegionPage = 0;
		var endRegionDossier = false;
		
		var currentNationPage = 0;
		var endNationDossier = false;
		loadDossierPage = function(region, animate) {
			if ((region && endRegionDossier) || (!region && endNationDossier)) {
				return;
			}
			var targets = [];
			$.get("page=dossier?start=" + (currentNationPage * 15), function(html) {
				var dossierHtml = "";
				if (region) {
					$(html).find("table").find("tbody").find("tr").each(function() {
						if ($(this).children().length == 4) {
							var regionElement = $($(this).children()[1]);
							var region = regionElement.text();
							if (regionElement.find("a").length > 0) {
								region = regionElement.find("a").attr("href").substring(7);
							}
							var nations = $($(this).children()[2]).html();
{'fraction_non_alphanumeric': 0.23115336020696708, 'fraction_numerical': 0.010649178749774382, 'mean_word_length': 4.222117499214577, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 80, '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': '5948124', 'n_tokens_mistral': 6769, 'n_tokens_neox': 5293, 'n_words': 830}