$(function() {
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(prefix) {
return this.slice(0, prefix.length) == prefix;
};
}
if (!String.prototype.endsWith) {
String.prototype.endsWith = function(search) {
return this.substring(this.length - search.length, this.length) === search;
};
}
if (!Object.values) {
Object.values = function (obj) {
return Object.keys(obj).map(function (e) {
return obj[e];
});
}
}
String.prototype.escapeJsonChars = function() {
return this.replace(/\n/g, "\\n")
.replace(/\'/g, "\\'")
.replace(/\"/g, '\\"')
.replace(/\&/g, "\\&")
.replace(/\r/g, "\\r")
.replace(/\t/g, "\\t")
.replace(/\b/g, "\\b")
.replace(/\f/g, "\\f");
};
String.prototype.escapeXmlChars = function() {
return this.replace(/\'/g, "'")
.replace(/\"/g, '"')
.replace(/\&/g, "&")
.replace(//g, ">");
};
String.prototype.asciiCharsOnly = function() {
return this.replace(/[^\x20-\x7E]/g, "");
};
String.prototype.escapeCsvChars = function() {
return this.replace(/"/g, '""');
};
});
var helpPanel;
function openFieldLevelHelp(pageId, fieldName) {
$.getJSON( "/sevis/action/common/getHelpContent", { "pageId": pageId, "fieldName": fieldName } )
.done(function( data ) {
if (data === undefined) {
data = {
title: 'SEVIS Help',
content: 'Help not currently available'
}
} else if (typeof data == "string" && data.indexOf("Session Time Out") > -1) {
data = {
title: 'SEVIS Help',
content: '
Your session has timed out. Please
log back in and try again.
'
}
}
if (helpPanel === undefined) {
helpPanel = $.jsPanel({
theme: "primary",
position: "center right",
size: {
width: function(){ return $(window).width()/4 },
height: function(){ return $(window).height()/2 }
},
overflow: { horizontal: 'hidden', vertical: 'scroll' },
onclosed: function() { helpPanel = undefined; }
});
} else {
helpPanel.reposition("center right")
}
output = "" + data.content + "
"
helpPanel.header.title.html(data.title);
helpPanel.content.html(output);
$(".jsPanel-title").focus()
});
}
function openFieldLevelHelpOnKeyUp(event, pageId, fieldName) {
if (event.type === 'click') {
openFieldLevelHelp(pageId, fieldName);
} else if(event.type === 'keypress'){
var code = event.charCode || event.keyCode;
if ((code === 32) || (code === 13)) {
event.preventDefault();
openFieldLevelHelp(pageId, fieldName);
}
}
}
function msover() {
}
function msout() {
}
function escapeXmlForExcel(unsafe) {
data = unsafe;
// dollar sign followed immed by apostrophe breaks excel export for some crazy reason so add a space between
if (data.indexOf("$'") > -1) {
data = data.replace(/\$'/g, "$ '");
}
return data.replace(/[<>&'"`]/g, function (c) {
switch (c) {
case '<': return '<';
case '>': return '>';
case '&': return '&';
case '\'': return '\'';
case '"': return '\"';
case '`': return '\'';
}
});
}
function escapeLessThanGreaterThan(unsafe) {
return unsafe.replace(/[<>]/g, function (c) {
switch (c) {
case '<': return '\'';
case '>': return '\"';
}
});
}