<fim-prefix>(id, scope) {
	$.get( "/sightings/viewSightings/" + id + "/" + scope, function(data) {
		$("#sightingsData").html(data);
	});
}

function checkRolePerms() {
	if ($("#RolePermission").val() == '0' || $("#RolePermission").val() == '1') {
		$('.readonlydisabled').prop('checked', false);
		$('.readonlydisabled').hide();
	} else {
		$('.readonlydisabled').show();
		$('.permFlags').show();
	}
	if ($("#RolePermSiteAdmin").prop('checked')) {
		$('.checkbox').prop('checked', true);
	}
}

// clicking on an element with this class will select all of its contents in a
// single click
$('.quickSelect').click(function() {
	var range = document.createRange();
	var selection = window.getSelection();
	range.selectNodeContents(this);
	selection.removeAllRanges();
	selection.addRange(range);
});

function updateMISP() {
	$.get( "/servers/update", function(data) {
		$("#confirmation_box").html(data);
		openPopup("#confirmation_box");
	});
}

function submitMISPUpdate() {
	var formData = $('#PromptForm').serialize();
	$.ajax({
		beforeSend: function (XMLHttpRequest) {
			$(".loading").show();
		},
		data: formData,
		success:function (data, textStatus) {
			$('#gitResult').text(data);
			$('#gitResult').removeClass('hidden');
		},
		complete:function() {
			$(".loading").hide();
			$("#confirmation_box").fadeOut();
			$("#gray_out").fadeOut();
		},
		type:"post",
		cache: false,
		url:"/servers/update",
	});
}

$(".cortex-json").click(function() {
	var cortex_data = $(this).data('cortex-json');
	// BUG: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
	// cortex_data = JSON.stringify(cortex_data, null, 2);
	// FIXED: 
<fim-middle>	cortex_data = htmlEncode(JSON.stringify(cortex_data, null, 2));
	var popupHtml = '<pre class="simplepre">' + cortex_data + '</pre>';
	popupHtml += '<div class="close-icon useCursorPointer" onClick="cl<fix-suffix>oseScreenshot();"></div>';
	$('#screenshot_box').html(popupHtml);
	$('#screenshot_box').show();
	$('#screenshot_box').css({'padding': '5px'});
	left = ($(window).width() / 2) - ($('#screenshot_box').width() / 2);
	if (($('#screenshot_box').height() + 250) > $(window).height()) {
		$('#screenshot_box').height($(window).height() - 250);
		$('#screenshot_box').css("overflow-y", "scroll");
		$('#screenshot_box').css("overflow-x", "hidden");
	}
	$('#screenshot_box').css({'left': left + 'px'});
	$("#gray_out").fadeIn();
});

// Show $(id) if the enable parameter evaluates to true. Hide it otherwise
function checkAndEnable(id, enable) {
	if (enable) {
		$(id).show();
	} else {
		$(id).hide();
	}
}

// Show and enable checkbox $(id) if the enable parameter evaluates to true. Hide and disable it otherwise.
function checkAndEnableCheckbox(id, enable) {
	if (enable) {
		$(id).removeAttr("disabled");
		$(id).prop('checked', true);
	} else {
		$(id).prop('checked', false);
		$(id).attr("disabled", <|endoftext|>