This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the suffix related to the number for ex. (1st, 2nd, 3rd, 4th) | |
* @param {Number} number Number to find the suffix for. | |
* @return {String} Suffix string to append to be appended to number. | |
*/ | |
function getNumberSuffix(number) { | |
var numberConvertedToString = (number + ''); | |
var lastDigit = numberConvertedToString.charAt(numberConvertedToString.length - 1); | |
if (lastDigit === '1') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var monthFullNameArray = ["","January","February","March","April","May","June","July","August","September","October","November","December"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns value of specified URL parameter. | |
* @param {String} name Query parameter to return value of. | |
* @return {String} String of query parameter or null / 0. | |
*/ | |
getUrlParameter = function(name){ | |
var results = new RegExp('[\\?&]' + name + '=([^&#?]*)').exec(window.location.href); | |
if (results==null){ return null; } | |
else { return results[1] || 0; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* UI to sort rows of data by clicking on their parent title. | |
* titleDomObject should have children - one of which has the 'descending' or 'ascending' class. | |
* @param {jQuery Object} titleDomObject Contains one or more children with the 'descending' or 'ascending' class, and the text of the html to be sorted. | |
* @param {Function} sortCallback Callback should re-render the contents of the titles based on the child that was clicked. | |
*/ | |
function setupSortingHandlers(titleDomObject,sortCallback) { | |
var sortAscending = true; | |
titleElements = titleDomObject.children(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Prevents the default action of submit when hitting enter on form input. | |
* @param {jQuery Object} domElement DOM form element on which to block the enter event. | |
* @return {jQuery Object} Return input object for chaining. | |
*/ | |
function preventFormSubmitOnEnter(domElement){ | |
domElement.keydown(function(event){ | |
if ( event.keyCode == 13 ){ //Keycode 13 is the 'enter' key. | |
event.preventDefault(); //Ignore it when pressed... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates a simple date string from a Date object. | |
* @param {Date} dateVariable Any date object. | |
* @return {String} String representation of date in format mm-dd-yyyy | |
*/ | |
function convertDateToString(date) { | |
var day = date.getDate(); | |
var month = date.getMonth() + 1; //Months are zero based | |
var year = date.getFullYear(); | |
return month + "-" + day + "-" + year ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Build a SOLR query using kay-value pairs from queryObject. | |
* @param {Object} queryObject Object conaining the name and value for each search parameter. | |
* @return {String} Query string to be appended to URL | |
*/ | |
function buildSOLRQuery(queryObject) { | |
var queryString = ''; | |
for (key in queryObject) { | |
if (queryObject[key] !== '') { | |
queryString += (queryString ? ' AND ' : '') + //If queryString is not empty, add '&' at the beginning |
NewerOlder