Untitled

                Never    
/*! RESOURCE: /scripts/js_includes_customer.js */
/*! RESOURCE: ConnectionUtils */
var ConnectionUtils = {
	getSysConnection: function() {
		var connGR = new GlideRecord("sys_connection");
		connGR.addQuery('active', true);
		connGR.addQuery("connection_alias", g_form.getValue("connection_alias"));
		connGR.addQuery("sys_domain", g_form.getValue("sys_domain"));
		connGR.addQuery("sys_id", "!=", g_form.getUniqueValue());
		connGR.query();
		return connGR;
	},
	doConnection: function(verb) {
		if (g_form.getValue("active") == "false") {
			gsftSubmit(null, g_form.getFormElement(), verb);
		}
		var connGR;
		var performOverride = function() {
			connGR.active = false;
			connGR.update();
			gsftSubmit(null, g_form.getFormElement(), verb);
		};
		var grConnAlias = new GlideRecord("sys_alias");
		if (grConnAlias.get(g_form.getValue("connection_alias"))) {
			if (grConnAlias.multiple_connections == 'true') {
				gsftSubmit(null, g_form.getFormElement(), verb);
			} else {
				connGR = this.getSysConnection();
				if (connGR.next()) {
					var currName = g_form.getValue("name");
					if (connGR.name.toUpperCase() == currName.toUpperCase()) {
						var uniqueErrMsg = new GwtMessage().getMessage("A connection with {0} name already exists, duplicate connection names are not allowed", currName);
						g_form.addErrorMessage(uniqueErrMsg);
						return false;
					}
					var title = new GwtMessage().getMessage("Confirm inactivation");
					var question = new GwtMessage().getMessage("You already have a {0} connection active, {1}.<br/>By making this one active, {2} will become inactive. <br/>Are you sure you want to make {3} the active connection?", connGR.protocol, connGR.name, connGR.name, currName);
					this.confirmOverride(title, question, performOverride);
				} else {
					gsftSubmit(null, g_form.getFormElement(), verb);
				}
			}
		}
	},
	confirmOverride: function(title, question, onPromptComplete) {
		var dialogClass = (window.GlideModal) ? GlideModal : GlideDialogWindow;
		var dialog = new GlideDialogWindow('glide_confirm_basic');
		dialog.setTitle(title);
		dialog.setSize(400, 325);
		dialog.setPreference('title', question);
		dialog.setPreference('onPromptComplete', onPromptComplete);
		dialog.render();
	},
};
/*! RESOURCE: Validate Client Script Functions */
function validateFunctionDeclaration(fieldName, functionName) {
	var code = g_form.getValue(fieldName);
	if (code == "")
		return true;
	code = removeCommentsFromClientScript(code);
	var patternString = "function(\\s+)" + functionName + "((\\s+)|\\(|\\[\r\n])";
	var validatePattern = new RegExp(patternString);
	if (!validatePattern.test(code)) {
		var msg = new GwtMessage().getMessage('Missing function declaration for') + ' ' + functionName;
		g_form.showErrorBox(fieldName, msg);
		return false;
	}
	return true;
}

function validateNoServerObjectsInClientScript(fieldName) {
	var code = g_form.getValue(fieldName);
	if (code == "")
		return true;
	code = removeCommentsFromClientScript(code);
	var doubleQuotePattern = /"[^"\r\n]*"/g;
	code = code.replace(doubleQuotePattern, "");
	var singleQuotePattern = /'[^'\r\n]*'/g;
	code = code.replace(singleQuotePattern, "");
	var rc = true;
	var gsPattern = /(\s|\W)gs\./;
	if (gsPattern.test(code)) {
		var msg = new GwtMessage().getMessage('The object "gs" should not be used in client scripts.');
		g_form.showErrorBox(fieldName, msg);
		rc = false;
	}
	var currentPattern = /(\s|\W)current\./;
	if (currentPattern.test(code)) {
		var msg = new GwtMessage().getMessage('The object "current" should not be used in client scripts.');
		g_form.showErrorBox(fieldName, msg);
		rc = false;
	}
	return rc;
}

function validateUIScriptIIFEPattern(fieldName, scopeName, scriptName) {
	var code = g_form.getValue(fieldName);
	var rc = true;
	if ("global" == scopeName)
		return rc;
	code = removeCommentsFromClientScript(code);
	code = removeSpacesFromClientScript(code);
	code = removeNewlinesFromClientScript(code);
	var requiredStart = "var" + scopeName + "=" + scopeName + "||{};" + scopeName + "." + scriptName + "=(function(){\"usestrict\";";
	var requiredEnd = "})();";
	if (!code.startsWith(requiredStart)) {
		var msg = new GwtMessage().getMessage("Missing closure assignment.");
		g_form.showErrorBox(fieldName, msg);
		rc = false;
	}
	if (!code.endsWith(requiredEnd)) {
		var msg = new GwtMessage().getMessage("Missing immediately-invoked function declaration end.");
		g_form.showErrorBox(fieldName, msg);
		rc = false;
	}
	return rc;
}

function validateNotCallingFunction(fieldName, functionName) {
	var code = g_form.getValue(fieldName);
	var rc = true;
	var reg = new RegExp(functionName, "g");
	var matches;
	code = removeCommentsFromClientScript(code);
	if (code == '')
		return rc;
	matches = code.match(reg);
	rc = (matches && (matches.length == 1));
	if (!rc) {
		var msg = "Do not explicitly call the " + functionName + " function in your business rule. It will be called automatically at execution time.";
		msg = new GwtMessage().getMessage(msg);
		g_form.showErrorBox(fieldName, msg);
	}
	return rc;
}

function removeCommentsFromClientScript(code) {
	var pattern1 = /\/\*(.|[\r\n])*?\*\//g;
	code = code.replace(pattern1, "");
	var pattern2 = /\/\/.*/g;
	code = code.replace(pattern2, "");
	return code;
}

function removeSpacesFromClientScript(code) {
	var pattern = /\s*/g;
	return code.replace(pattern, "");
}

function removeNewlinesFromClientScript(code) {
	var pattern = /[\r\n]*/g;
	return code.replace(pattern, "");
}
/*! RESOURCE: Partner Portal Library */
function enableControlFormField(bindingStateToElementName, formFieldName, enable) {
	var controlElement = g_form.getControl(bindingStateToElementName);
	var isShown = $j(bindingStateToElementName).data(formFieldName + '_isShown');
	if (enable) {
		show(false);
		g_form.setValue(formFieldName, '');
	} else {
		show(true);
	}

	function show(value) {
		if (value === true && isShown) {
			return;
		}
		enableFormField(formFieldName, value);
		$j(bindingStateToElementName).data(formFieldName + '_isShown', value);
	}
}

function enableFormField(formFieldName, value) {
	if (typeof value !== 'boolean') {
		return;
	}
	g_form.setReadonly(formFieldName, !value);
	g_form.setMandatory(formFieldName, value);
	g_form.setVisible(formFieldName, value);
	g_form.setDisplay(formFieldName, value);
}

function disableControl(formFieldName, disable) {
	g_form.setReadOnly(formFieldName, disable);
	g_form.setDisabledControl(g_form.getElement(formFieldName), disable);
}

function disableEmptyFormField(formFieldName) {
	var value = g_form.getValue(formFieldName);
	if (value.length <= 0) {
		enableFormField(formFieldName, false);
	}
}

function checkCheckBox(checkBoxName, value, triggerParentChange) {
	g_form.getNiBox(checkBoxName).checked = value ? true : false;
	setCheckBox(g_form.getNiBox(checkBoxName));
	if (triggerParentChange) {
		$j(g_form.getElement(checkBoxName)).parent().trigger('change');
	}
}

function disableCheckBox(checkboxName, value) {
	var $checkbox = $j(g_form.getNiBox(checkboxName));
	$checkbox.prop("disabled", value ? true : false);
}

function isAttachmentsExist(formControl, message, warnLevel) {
	g_form.hideFieldMsg(formControl);
	var attachments = gel('header_attachment_list_label');
	if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
		g_form.showFieldMsg(formControl, message, warnLevel);
		return false;
	}
	return true;
}

function validateEmail(email, fieldName) {
	var pattern = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;

	function sl_translate() {}
	sl_tr_start = sl_translate;
	sl_tr_end = sl_translate;
	var result = pattern.test(email);
	sl_tr_start();
	var emailErrorMsg = "invalid email format";
	sl_tr_end();
	if (!!fieldName) {
		g_form.hideFieldMsg(fieldName);
		if (!result) {
			g_form.showFieldMsg(fieldName, emailErrorMsg, "error");
		}
	}
	return result;
}

function validateStartDatePriorToEndDate(startDateFieldName, endDateFieldName, format) {
	var startDate = g_form.getValue(startDateFieldName);
	var endDate = g_form.getValue(endDateFieldName);
	var isValid = true;
	g_form.hideFieldMsg(startDateFieldName);
	g_form.hideFieldMsg(endDateFieldName);
	if (startDate.length > 0 && !isValidDateFormat(startDate, format)) {
		g_form.showFieldMsg(startDateFieldName, "Invalid time format", "error");
		isValid = false;
	}
	if (endDate.length > 0 && !isValidDateFormat(endDate, format)) {
		g_form.showFieldMsg(endDateFieldName, "Invalid time format", "error");
		isValid = false;
	}
	if (!isStartDatePriorToEndDate(startDate, endDate, format)) {
		g_form.showFieldMsg(startDateFieldName, "Start date should be on or before end date", "error");
		g_form.showFieldMsg(endDateFieldName, "End date should be on or after start date.", "error");
		isValid = false;
	}
	if (endDate != '' && isEndDatePriortoCurrentdate(endDate) == 'true') {
		g_form.showFieldMsg(endDateFieldName, "Projects completed more than 90 days prior to current date are not eligible for deployment registration", "error");
		isValid = false;
	}
	return isValid;
}

function isEndDatePriortoCurrentdate(endDate) {
	var ga = new GlideAjax('DeploymentRegistrationAJAXUtils');
	ga.addParam('sysparm_name', 'validateEndDate');
	ga.addParam('sysparm_end_date', g_form.getValue('u_estimated_end_date'));
	ga.getXMLWait();
	return ga.getAnswer();
}

function isStartDatePriorToEndDate(startDate, endDate, format) {
	var startDateMs = getDateFromFormat(startDate, format);
	var endDateMs = getDateFromFormat(endDate, format);
	if ((startDate === "" || endDate === "") || startDateMs <= endDateMs)
		return true;
	return false;
}

function isValidDateFormat(date, format) {
	var dateMS = getDateFromFormat(date, format);
	return dateMS !== 0;
}

function refreshCaptcha(imageElementId) {
	if (imageElementId == undefined) {
		imageElementId = 'captcha_image';
	}
	var captchaElem = gel(imageElementId);
	if (captchaElem != undefined) {
		captchaElem.src = "pwd_jcaptcha.do?" + new Date().getTime();
		document.getElementById('captchaValue').value = '';
	}
	return false;
}

function resizeIFrame() {
	var frameChangeTimer = null;
	if (frameChangeTimer != null) {
		clearTimeout(frameChangeTimer);
		frameChangeTimer = null;
	} else {
		frameChangeTimer = window.setTimeout(_frameChanged, 50);
	}
}

function loadUIScript(scriptName, callback) {
	if (!(!!scriptName && scriptName.length > 0 && callback.apply)) {
		return;
	}
	var isScriptLoaded = $j('script[src="' + scriptName + '.jsdbx?cache=$[jvar_stamp]"]').length > 0;
	if (!isScriptLoaded) {
		$j.ajax({
			url: scriptName + ".jsdbx?cache=$[jvar_stamp]",
			dataType: "script",
			cache: true,
			success: function() {
				callback.apply();
			}
		});
	} else {
		callback.apply();
	}
}

function mergeObjects(obj1, obj2) {
	var obj3 = {};
	for (var prop1 in obj1) {
		obj3[prop1] = obj1[prop1];
	}
	for (var prop2 in obj2) {
		obj3[prop2] = obj2[prop2];
	}
	return obj3;
}

function removeSecurityMessage() {
	setTimeout(function() {
		if (window.top.location.href.indexOf('portalapp') > -1) {
			try {
				if (document.getElementsByClassName('list2_body')[0].children[0].children[0].innerHTML.startsWith('Number of rows removed from this list by Security constraints')) {
					document.getElementsByClassName('list2_body')[0].children[0].children[0].setAttribute('style', 'display:none');
				}
			} catch (error) {}
		}
	}, 100);
}
removeSecurityMessage();
/*! RESOURCE: UI Action Context Menu */
function showUIActionContext(event) {
	if (!g_user.hasRole("ui_action_admin"))
		return;
	var element = Event.element(event);
	if (element.tagName.toLowerCase() == "span")
		element = element.parentNode;
	var id = element.getAttribute("gsft_id");
	var mcm = new GwtContextMenu('context_menu_action_' + id);
	mcm.clear();
	mcm.addURL(getMessage('Edit UI Action'), "sys_ui_action.do?sys_id=" + id, "gsft_main");
	contextShow(event, mcm.getID(), 500, 0, 0);
	Event.stop(event);
}
addLoadEvent(function() {
	document.on('contextmenu', '.action_context', function(evt, element) {
		showUIActionContext(evt);
	});
});
/*! RESOURCE: AdjustHeightOfIFrame */
function adjustHeight() {
	try {
		var actualHeight = $j(parent.document.getElementById('gsft_main').contentWindow.document).height();
		var currentHeight = 0;
		if ($j(parent.document.getElementById('gsft_main')).attr('height')) {
			currentHeight = parseInt($j(parent.document.getElementById('gsft_main')).attr('height'));
		} else {
			currentHeight = parseInt($j(parent.document.getElementById('gsft_main')).height());
		}
		if (currentHeight != actualHeight) {
			$j(parent.document.getElementById('gsft_main')).height('auto');
			actualHeight = $j(parent.document.getElementById('gsft_main').contentWindow.document).height();
			$j(parent.document.getElementById('gsft_main')).height(0);
			$j(parent.document.getElementById('gsft_main')).height(actualHeight);
		}
	} catch (e) {
		console.log(e);
	}
}
/*! RESOURCE: ValidateStartEndDates */
function validateStartEndDate(startDateField, endDateField, processErrorMsg) {
	var startDate = g_form.getValue(startDateField);
	var endDate = g_form.getValue(endDateField);
	var format = g_user_date_format;
	if (startDate === "" || endDate === "")
		return true;
	var startDateFormat = getDateFromFormat(startDate, format);
	var endDateFormat = getDateFromFormat(endDate, format);
	if (startDateFormat < endDateFormat)
		return true;
	if (startDateFormat === 0 || endDateFormat === 0) {
		processErrorMsg(new GwtMessage().getMessage("{0} is invalid", g_form.getLabelOf(startDate === 0 ? startDateField : endDateField)));
		return false;
	}
	if (startDateFormat > endDateFormat) {
		processErrorMsg(new GwtMessage().getMessage("{0} must be after {1}", g_form.getLabelOf(endDateField), g_form.getLabelOf(startDateField)));
		return false;
	}
	return true;
}
/*! RESOURCE: PartnerPortalRedirection */
function unsupportedIeVersion() {
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf('msie') != -1) {
		return parseInt(agent.split('msie')[1]) < 9;
	} else {
		return false;
	}
}

function checkRedirection() {
	if (window.top.location.pathname.indexOf('/not_supported.do') < 0 && unsupportedIeVersion()) {
		window.top.location = '/not_supported.do';
	}
	var path = window.top.location.href;
	if (path.indexOf("sysparm_view=sys_ref_list") == -1) {
		var ga = new GlideAjax('PartnerPortalRedirectionAjax');
		ga.addParam('sysparm_name', 'execute');
		ga.addParam('sysparm_path_value', path);
		ga.getXML(parseResponse);
	}
}

function parseResponse(response) {
	try {
		var answer = JSON.parse(response.responseXML.documentElement.getAttribute('answer'));
		if (answer.needRedirect) {
			answer.redirectTo = decodeURIComponent(answer.redirectTo);
			window.top.location = '/' + answer.redirectTo;
		}
	} catch (error) {
		console.log('--------Partner portal redirection---' + error);
	}
}
unsupportedIeVersion();
checkRedirection();
/*! RESOURCE: pdb_HighchartsConfigBuilder */
var HighchartsBuilder = {
	getChartConfig: function(chartOptions, tzOffset) {
		var chartTitle = chartOptions.title.text,
			xAxisTitle = chartOptions.xAxis.title.text,
			xAxisCategories = chartOptions.xAxis.categories,
			yAxisTitle = chartOptions.yAxis.title.text,
			series = chartOptions.series;
		this.convertEpochtoMs(xAxisCategories);
		this.formatDataSeries(xAxisCategories, series);
		var config = {
			chart: {
				type: 'area',
				zoomType: 'x'
			},
			credits: {
				enabled: false
			},
			title: {
				text: chartTitle
			},
			xAxis: {
				type: 'datetime',
				title: {
					text: xAxisTitle,
					style: {
						textTransform: 'capitalize'
					}
				}
			},
			yAxis: {
				reversedStacks: false,
				title: {
					text: yAxisTitle,
					style: {
						textTransform: 'capitalize'
					}
				}
			},
			plotOptions: {
				area: {
					stacking: 'normal'
				},
				series: {
					marker: {
						enabled: true,
						symbol: 'circle',
						radius: 2
					},
					step: 'center'
				}
			},
			tooltip: {
				valueDecimals: 2,
				style: {
					whiteSpace: "wrap",
					width: "200px"
				}
			},
			series: series
		};
		var convertedOffset = -1 * (tzOffset / 60);
		Highcharts.setOptions({
			lang: {
				thousandsSep: ','
			},
			global: {
				timezoneOffset: convertedOffset
			}
		});
		return config;
	},
	convertEpochtoMs: function(categories) {
		categories.forEach(function(point, index, arr) {
			arr[index] *= 1000;
		});
	},
	formatDataSeries: function(categories, series) {
		series.forEach(function(row, index, arr) {
			arr[index].data.forEach(function(innerRow, innerIndex, innerArr) {
				var value = innerRow;
				if (value == "NaN") {
					value = 0;
				}
				var xValue = categories[innerIndex];
				innerArr[innerIndex] = [xValue, value];
			});
		});
	}
};
/*! RESOURCE: /scripts/lib/jquery/jquery_clean.js */
(function() {
	if (!window.jQuery)
		return;
	if (!window.$j_glide)
		window.$j = jQuery.noConflict();
	if (window.$j_glide && jQuery != window.$j_glide) {
		if (window.$j_glide)
			jQuery.noConflict(true);
		window.$j = window.$j_glide;
	}
})();;;

Raw Text